Skip to content

Instantly share code, notes, and snippets.

@alexg0
Created May 18, 2010 21:15
Show Gist options
  • Save alexg0/405568 to your computer and use it in GitHub Desktop.
Save alexg0/405568 to your computer and use it in GitHub Desktop.
# Generate tags
require 'rubygems'
module Tags
# TODO: add gem dirs
RUBY_DIRS = %w( lib vendor/gems )
GEM_PATHS = Gem.path
def ruby_paths
(RUBY_DIRS + GEM_PATHS).find_all{|d| File.exists? d }
end
module_function :ruby_paths
# exuberant-ctags package is required to use -R switch. On
# ubuntu, if emacs is installed, it's provided etags is higher
# priority then exuberant etags, so may want to run galternatives to
# fix it.
CTAGS_CMD = 'ctags'
ETAGS_CMD = 'etags'
end
namespace 'tags' do
desc 'Make tags for Emacs'
task :emacs do
puts "Making Emacs TAGS file"
sh "#{Tags::ETAGS_CMD} -R #{Tags::ruby_paths.join(' ')}", :verbose => false
end
desc 'Make tags for vi'
task :vi do
puts "Making vi TAGS file"
sh "#{Tags::CTAGS_CMD} -R #{Tags::ruby_paths.join(' ')}", :verbose => false
end
desc 'Make tags for both Emacs and vi'
task :both => [:emacs, :vi]
end
task :tags => ["tags:both"]
task :etags => ["tags:emacs"]
task :ctags => ["tags:vi"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment