Class | Gem::Commands::SpecificationCommand |
In: |
lib/rubygems/commands/specification_command.rb
|
Parent: | Gem::Command |
# File lib/rubygems/commands/specification_command.rb, line 13 13: def initialize 14: super 'specification', 'Display gem specification (in yaml)', 15: :domain => :local, :version => Gem::Requirement.default 16: 17: add_version_option('examine') 18: add_platform_option 19: 20: add_option('--all', 'Output specifications for all versions of', 21: 'the gem') do |value, options| 22: options[:all] = true 23: end 24: 25: add_local_remote_options 26: end
# File lib/rubygems/commands/specification_command.rb, line 40 40: def execute 41: specs = [] 42: gem = get_one_gem_name 43: dep = Gem::Dependency.new gem, options[:version] 44: 45: if local? then 46: if File.exist? gem then 47: specs << Gem::Format.from_file_by_path(gem).spec rescue nil 48: end 49: 50: if specs.empty? then 51: specs.push(*Gem.source_index.search(dep)) 52: end 53: end 54: 55: if remote? then 56: found = Gem::SpecFetcher.fetcher.fetch dep 57: 58: specs.push(*found.map { |spec,| spec }) 59: end 60: 61: if specs.empty? then 62: alert_error "Unknown gem '#{gem}'" 63: terminate_interaction 1 64: end 65: 66: output = lambda { |s| say s.to_yaml; say "\n" } 67: 68: if options[:all] then 69: specs.each(&output) 70: else 71: spec = specs.sort_by { |s| s.version }.last 72: output[spec] 73: end 74: end