summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/specification_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/specification_command.rb')
-rw-r--r--lib/rubygems/commands/specification_command.rb31
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 987e401042..e4036aea78 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -72,18 +72,8 @@ FIELD name of gemspec field to show
field = get_one_optional_argument
- if field then
- field = field.intern
-
- if options[:format] == :ruby then
- raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive"
- end
-
- unless Gem::Specification.attribute_names.include? field then
- raise Gem::CommandLineError,
- "no field %p on Gem::Specification" % field.to_s
- end
- end
+ raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
+ field and options[:format] == :ruby
if local? then
if File.exist? gem then
@@ -91,7 +81,7 @@ FIELD name of gemspec field to show
end
if specs.empty? then
- specs.push(*Gem.source_index.search(dep))
+ specs.push(*dep.matching_specs)
end
end
@@ -106,7 +96,11 @@ FIELD name of gemspec field to show
terminate_interaction 1
end
- output = lambda do |s|
+ unless options[:all] then
+ specs = [specs.sort_by { |s| s.version }.last]
+ end
+
+ specs.each do |s|
s = s.send field if field
say case options[:format]
@@ -117,14 +111,5 @@ FIELD name of gemspec field to show
say "\n"
end
-
- if options[:all] then
- specs.each(&output)
- else
- spec = specs.sort_by { |s| s.version }.last
- output[spec]
- end
end
-
end
-