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: 44: if local? then 45: if File.exist? gem then 46: specs << Gem::Format.from_file_by_path(gem).spec rescue nil 47: end 48: 49: if specs.empty? then 50: specs.push(*Gem.source_index.search(/\A#{gem}\z/, options[:version])) 51: end 52: end 53: 54: if remote? then 55: Gem::SourceInfoCache.cache_data.each do |_,sice| 56: specs.push(*sice.source_index.search(gem, options[:version])) 57: end 58: end 59: 60: if specs.empty? then 61: alert_error "Unknown gem '#{gem}'" 62: terminate_interaction 1 63: end 64: 65: output = lambda { |s| say s.to_yaml; say "\n" } 66: 67: if options[:all] then 68: specs.each(&output) 69: else 70: spec = specs.sort_by { |s| s.version }.last 71: output[spec] 72: end 73: end