# File lib/rubygems/commands/specification_command.rb, line 11 11: def initialize 12: Gem.load_yaml 13: 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: raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if 70: field and options[:format] == :ruby 71: 72: if local? then 73: if File.exist? gem then 74: specs << Gem::Format.from_file_by_path(gem).spec rescue nil 75: end 76: 77: if specs.empty? then 78: specs.push(*dep.matching_specs) 79: end 80: end 81: 82: if remote? then 83: found = Gem::SpecFetcher.fetcher.fetch dep 84: 85: specs.push(*found.map { |spec,| spec }) 86: end 87: 88: if specs.empty? then 89: alert_error "Unknown gem '#{gem}'" 90: terminate_interaction 1 91: end 92: 93: unless options[:all] then 94: specs = [specs.sort_by { |s| s.version }.last] 95: end 96: 97: specs.each do |s| 98: s = s.send field if field 99: 100: say case options[:format] 101: when :ruby then s.to_ruby 102: when :marshal then Marshal.dump s 103: else s.to_yaml 104: end 105: 106: say "\n" 107: end 108: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.