Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move tags task into rakelib

  • Loading branch information...
commit 068049f665fa74658ff5cc8cb26847c7cab420c5 1 parent 1fe3236
@jimweirich jimweirich authored
Showing with 62 additions and 14 deletions.
  1. +0 −14 Rakefile
  2. +62 −0 rakelib/tags.rake
View
14 Rakefile
@@ -179,20 +179,6 @@ rescue LoadError
# No rcov available
end
-# Tags file ----------------------------------------------------------
-
-namespace "tags" do
- desc "Create a TAGS file"
- task :emacs => "TAGS"
-
- TAGS = ENV['TAGS'] || 'ctags'
-
- file "TAGS" => SRC_RB do
- puts "Making TAGS"
- sh "#{TAGS} -e #{SRC_RB}", :verbose => false
- end
-end
-
# --------------------------------------------------------------------
# Creating a release
View
62 rakelib/tags.rake
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+
+module Tags
+ extend Rake::DSL if defined?(Rake::DSL)
+
+ PROG = ENV['TAGS'] || 'ctags'
+
+ RAKEFILES = FileList['Rakefile', '**/*.rake']
+
+ FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES
+ FILES.exclude('pkg', 'dist')
+
+ PROJECT_DIR = ['.']
+
+ RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems")
+ SYSTEM_DIRS = File.exists?(RVM_GEMDIR) ? RVM_GEMDIR : []
+
+ module_function
+
+ # Convert key_word to --key-word.
+ def keyword(key)
+ k = key.to_s.gsub(/_/, '-')
+ (k.length == 1) ? "-#{k}" : "--#{k}"
+ end
+
+ # Run ctags command
+ def run(*args)
+ opts = {
+ :e => true,
+ :totals => true,
+ :recurse => true,
+ }
+ opts = opts.merge(args.pop) if args.last.is_a?(Hash)
+ command_args = opts.map { |k, v|
+ (v == true) ? keyword(k) : "#{keyword(k)}=#{v}"
+ }.join(" ")
+ sh %{#{Tags::PROG} #{command_args} #{args.join(' ')}}
+ end
+end
+
+namespace "tags" do
+ desc "Generate an Emacs TAGS file"
+ task :emacs, [:all] => Tags::FILES do |t, args|
+ puts "Making Emacs TAGS file"
+ verbose(true) do
+ Tags.run(Tags::PROJECT_DIR)
+ Tags.run(Tags::RAKEFILES,
+ :language_force => "ruby",
+ :append => true)
+ if args.all
+ Tags::SYSTEM_DIRS.each do |dir|
+ Tags.run(dir,
+ :language_force => "ruby",
+ :append => true)
+ end
+ end
+ end
+ end
+end
+
+desc "Generate the TAGS file"
+task :tags, [:all] => ["tags:emacs"]
Please sign in to comment.
Something went wrong with that request. Please try again.