Skip to content

Instantly share code, notes, and snippets.

@dolzenko
Created October 18, 2012 08:20
Show Gist options
  • Save dolzenko/3910428 to your computer and use it in GitHub Desktop.
Save dolzenko/3910428 to your computer and use it in GitHub Desktop.
Generate TAGS for project and Gems (from Bundler's Gemfile)
require 'bundler'
bundler_paths = []
raise unless File.exist?('Gemfile.lock')
lockfile_contents = Bundler.read_file('Gemfile.lock')
lockfile = Bundler::LockfileParser.new(lockfile_contents)
bundler_paths = lockfile.specs.map do |spec|
spec.__materialize__
spec.full_gem_path
end
tags_file = "TAGS"
opts = "--extra=+f -e -R -f #{tags_file}"
exclude_dirs = "--exclude=.git --exclude=log --exclude=.svn"
ctag_paths = "* #{bundler_paths.map {|x| x + '/*'}.join(' ')}"
command = "ctags #{opts} #{exclude_dirs} #{ctag_paths} 2> /dev/null"
puts "Processing ctags..."
system command
puts "Wrote ctags to '#{tags_file}' (#{'%.2f' % (File.size(tags_file).to_f / 2**20)} MB)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment