# 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: :format => :yaml 17: 18: add_version_option('examine') 19: add_platform_option 20: 21: add_option('--all', 'Output specifications for all versions of', 22: 'the gem') do |value, options| 23: options[:all] = true 24: end 25: 26: add_option('--ruby', 'Output ruby format') do |value, options| 27: options[:format] = :ruby 28: end 29: 30: add_option('--yaml', 'Output RUBY format') do |value, options| 31: options[:format] = :yaml 32: end 33: 34: add_option('--marshal', 'Output Marshal format') do |value, options| 35: options[:format] = :marshal 36: end 37: 38: add_local_remote_options 39: end
# File lib/rubygems/commands/specification_command.rb, line 56 56: def execute 57: specs = [] 58: gem = options[:args].shift 59: 60: unless gem then 61: raise Gem::CommandLineError, 62: "Please specify a gem name or file on the command line" 63: end 64: 65: dep = Gem::Dependency.new gem, options[:version] 66: 67: field = get_one_optional_argument 68: 69: if field then 70: field = field.intern 71: 72: if options[:format] == :ruby then 73: raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" 74: end 75: 76: unless Gem::Specification.attribute_names.include? field then 77: raise Gem::CommandLineError, 78: "no field %p on Gem::Specification" % field.to_s 79: end 80: end 81: 82: if local? then 83: if File.exist? gem then 84: specs << Gem::Format.from_file_by_path(gem).spec rescue nil 85: end 86: 87: if specs.empty? then 88: specs.push(*Gem.source_index.search(dep)) 89: end 90: end 91: 92: if remote? then 93: found = Gem::SpecFetcher.fetcher.fetch dep 94: 95: specs.push(*found.map { |spec,| spec }) 96: end 97: 98: if specs.empty? then 99: alert_error "Unknown gem '#{gem}'" 100: terminate_interaction 1 101: end 102: 103: output = lambda do |s| 104: s = s.send field if field 105: 106: say case options[:format] 107: when :ruby then s.to_ruby 108: when :marshal then Marshal.dump s 109: else s.to_yaml 110: end 111: 112: say "\n" 113: end 114: 115: if options[:all] then 116: specs.each(&output) 117: else 118: spec = specs.sort_by { |s| s.version }.last 119: output[spec] 120: end 121: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.