14
14
super 'specification', 'Display gem specification (in yaml)',
15
:domain => :local, :version => Gem::Requirement.default
15
:domain => :local, :version => Gem::Requirement.default,
17
18
add_version_option('examine')
18
19
add_platform_option
22
23
options[:all] = true
26
add_option('--ruby', 'Output ruby format') do |value, options|
27
options[:format] = :ruby
30
add_option('--yaml', 'Output RUBY format') do |value, options|
31
options[:format] = :yaml
34
add_option('--marshal', 'Output Marshal format') do |value, options|
35
options[:format] = :marshal
25
38
add_local_remote_options
28
41
def arguments # :nodoc:
29
"GEMFILE name of gem to show the gemspec for"
43
GEMFILE name of gem to show the gemspec for
44
FIELD name of gemspec field to show
32
48
def defaults_str # :nodoc:
33
"--local --version '#{Gem::Requirement.default}'"
49
"--local --version '#{Gem::Requirement.default}' --yaml"
36
52
def usage # :nodoc:
37
"#{program_name} [GEMFILE]"
53
"#{program_name} [GEMFILE] [FIELD]"
42
gem = get_one_gem_name
58
gem = options[:args].shift
61
raise Gem::CommandLineError,
62
"Please specify a gem name or file on the command line"
43
65
dep = Gem::Dependency.new gem, options[:version]
67
field = get_one_optional_argument
72
if options[:format] == :ruby then
73
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive"
76
unless Gem::Specification.attribute_names.include? field then
77
raise Gem::CommandLineError,
78
"no field %p on Gem::Specification" % field.to_s
46
83
if File.exist? gem then
47
84
specs << Gem::Format.from_file_by_path(gem).spec rescue nil
63
100
terminate_interaction 1
66
output = lambda { |s| say s.to_yaml; say "\n" }
103
output = lambda do |s|
104
s = s.send field if field
106
say case options[:format]
107
when :ruby then s.to_ruby
108
when :marshal then Marshal.dump s
68
115
if options[:all] then
69
116
specs.each(&output)