Class: Gem::Commands::RipperTagsCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::RipperTagsCommand
- Defined in:
- lib/rubygems/commands/ripper_tags_command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ RipperTagsCommand
constructor
A new instance of RipperTagsCommand.
Constructor Details
#initialize ⇒ RipperTagsCommand
Returns a new instance of RipperTagsCommand.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubygems/commands/ripper_tags_command.rb', line 5 def initialize super 'ripper_tags', 'Generate ctags for gems with Ruby/Ripper parser' add_option("--emacs", "Generate Emacs TAGS instead Vim tags") do |value, | [:emacs] = true end add_option("--reindex", "Reindex all tags again") do |value, | [:reindex] = true end add_option("--debug", "Enable debugging output") do |value, | [:debug] = true end end |
Class Method Details
.index(spec, ui, reindex, emacs, debug) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rubygems/commands/ripper_tags_command.rb', line 31 def self.index(spec, ui, reindex, emacs, debug) if emacs tag_filename = 'TAGS' format = "emacs" else tag_filename = 'tags' format = "vim" end return unless File.directory?(spec.full_gem_path) tag_file = File.join(spec.full_gem_path, tag_filename) if (!File.directory?(tag_filename) && reindex) || (!File.file?(tag_filename) && !File.directory?(tag_filename)) ui.say "Ripper is generating ctags for #{spec.full_name}" riopt = RipperTags. riopt.tag_relative = "always" riopt.tag_file_name = tag_file riopt.format = format riopt.recursive = true riopt.force = true riopt.files = [spec.full_gem_path] RipperTags.run riopt end rescue Errno::EACCES ui.say "Ripper cannot write to #{tag_file}" rescue => e raise unless ui ui.say "Failed processing ctags for #{spec.full_name} (#{e.class})" if debug ui.say e end end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubygems/commands/ripper_tags_command.rb', line 19 def execute Gem::Specification.each do |spec| self.class.index(spec, ui, [:reindex], [:emacs], [:debug]) end rescue Exception => e if [:debug] || ENV['RIPPER_TAGS_DEBUG'] puts e. puts e.backtrace.join("\n") end raise e end |