summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/query_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-18 21:29:41 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-18 21:29:41 +0000
commit95683e5cb2d1ab8351402b09ef853dcdf875bf8d (patch)
tree44500dba22e9aa94ecc5d4fd348512d0fb236501 /lib/rubygems/commands/query_command.rb
parent81629f05312cc4df2193a17f13c581eda174d9af (diff)
* lib/rubygems: Update to RubyGems 2.2.0.preview.1
This brings several new features to RubyGems summarized here: https://github.com/rubygems/rubygems/blob/v2.2.0.preview.1/History.txt * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/query_command.rb')
-rw-r--r--lib/rubygems/commands/query_command.rb46
1 files changed, 31 insertions, 15 deletions
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index c9c30149754..55b950c1b7c 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -72,16 +72,26 @@ is too hard to use.
def execute
exit_code = 0
+ if options[:args].to_a.empty? and options[:name].source.empty?
+ name = options[:name]
+ no_name = true
+ elsif !options[:name].source.empty?
+ name = Array(options[:name])
+ else
+ name = options[:args].to_a.map{|arg| /#{arg}/i }
+ end
- name = options[:name]
prerelease = options[:prerelease]
unless options[:installed].nil? then
- if name.source.empty? then
+ if no_name then
alert_error "You must specify a gem name"
exit_code |= 4
+ elsif name.count > 1
+ alert_error "You must specify only ONE gem!"
+ exit_code |= 4
else
- installed = installed? name, options[:version]
+ installed = installed? name.first, options[:version]
installed = !installed unless options[:installed]
if installed then
@@ -95,6 +105,22 @@ is too hard to use.
terminate_interaction exit_code
end
+ names = Array(name)
+ names.each { |n| show_gems n, prerelease }
+ end
+
+ private
+
+ def display_header type
+ if (ui.outs.tty? and Gem.configuration.verbose) or both? then
+ say
+ say "*** #{type} GEMS ***"
+ say
+ end
+ end
+
+ #Guts of original execute
+ def show_gems name, prerelease
req = Gem::Requirement.default
# TODO: deprecate for real
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
@@ -105,11 +131,7 @@ is too hard to use.
alert_warning "prereleases are always shown locally"
end
- if ui.outs.tty? or both? then
- say
- say "*** LOCAL GEMS ***"
- say
- end
+ display_header 'LOCAL'
specs = Gem::Specification.find_all { |s|
s.name =~ name and req =~ s.version
@@ -123,11 +145,7 @@ is too hard to use.
end
if remote? then
- if ui.outs.tty? or both? then
- say
- say "*** REMOTE GEMS ***"
- say
- end
+ display_header 'REMOTE'
fetcher = Gem::SpecFetcher.fetcher
@@ -155,8 +173,6 @@ is too hard to use.
end
end
- private
-
##
# Check if gem +name+ version +version+ is installed.