summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
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
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')
-rw-r--r--lib/rubygems/commands/list_command.rb8
-rw-r--r--lib/rubygems/commands/pristine_command.rb15
-rw-r--r--lib/rubygems/commands/push_command.rb13
-rw-r--r--lib/rubygems/commands/query_command.rb46
-rw-r--r--lib/rubygems/commands/search_command.rb6
-rw-r--r--lib/rubygems/commands/uninstall_command.rb6
-rw-r--r--lib/rubygems/commands/update_command.rb3
-rw-r--r--lib/rubygems/commands/which_command.rb8
8 files changed, 62 insertions, 43 deletions
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index 0d15950475e..4edeabef020 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -33,13 +33,7 @@ To search for remote gems use the search command.
end
def usage # :nodoc:
- "#{program_name} [STRING]"
- end
-
- def execute
- string = get_one_optional_argument || ''
- options[:name] = /^#{string}/i
- super
+ "#{program_name} [STRING ...]"
end
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 3f3bca45be2..b54e7eac938 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -12,6 +12,7 @@ class Gem::Commands::PristineCommand < Gem::Command
'Restores installed gems to pristine condition from files located in the gem cache',
:version => Gem::Requirement.default,
:extensions => true,
+ :extensions_set => false,
:all => false
add_option('--all',
@@ -23,7 +24,8 @@ class Gem::Commands::PristineCommand < Gem::Command
add_option('--[no-]extensions',
'Restore gems with extensions',
'in addition to regular gems') do |value, options|
- options[:extensions] = value
+ options[:extensions_set] = true
+ options[:extensions] = value
end
add_option('--only-executables',
@@ -62,6 +64,9 @@ If the cached gem cannot be found it will be downloaded.
If --no-extensions is provided pristine will not attempt to restore a gem
with an extension.
+
+If --extensions is given (but not --all or gem names) only gems with
+extensions will be restored.
EOF
end
@@ -72,6 +77,14 @@ with an extension.
def execute
specs = if options[:all] then
Gem::Specification.map
+
+ # `--extensions` must be explicitly given to pristine only gems
+ # with extensions.
+ elsif options[:extensions_set] and
+ options[:extensions] and options[:args].empty? then
+ Gem::Specification.select do |spec|
+ spec.extensions and not spec.extensions.empty?
+ end
else
get_all_gem_names.map do |gem_name|
Gem::Specification.find_all_by_name gem_name, options[:version]
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index b90be7bd10d..6899b489ad7 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -69,13 +69,18 @@ You can upgrade or downgrade to the latest release version with:
terminate_interaction 1
end
+ gem_data = Gem::Package.new(name)
+
unless @host then
- if gem_data = Gem::Package.new(name) then
- @host = gem_data.spec.metadata['default_gem_server']
- end
+ @host = gem_data.spec.metadata['default_gem_server']
end
- args << @host if @host
+ # Always include this, even if it's nil
+ args << @host
+
+ if gem_data.spec.metadata.has_key?('allowed_push_host')
+ args << gem_data.spec.metadata['allowed_push_host']
+ end
say "Pushing gem to #{@host || Gem.host}..."
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.
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 5bc9650672b..5809690735f 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -36,11 +36,5 @@ To list local gems use the list command.
"#{program_name} [STRING]"
end
- def execute
- string = get_one_optional_argument
- options[:name] = /#{string}/i
- super
- end
-
end
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 8e6af2ba653..e62095a3365 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -15,7 +15,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
def initialize
super 'uninstall', 'Uninstall gems from the local repository',
:version => Gem::Requirement.default, :user_install => true,
- :install_dir => Gem.dir, :check_dev => false
+ :check_dev => false
add_option('-a', '--[no-]all',
'Uninstall all matching versions'
@@ -84,7 +84,6 @@ class Gem::Commands::UninstallCommand < Gem::Command
def defaults_str # :nodoc:
"--version '#{Gem::Requirement.default}' --no-force " +
- "--install-dir #{Gem.dir}\n" +
"--user-install"
end
@@ -104,8 +103,7 @@ that is a dependency of an existing gem. You can use the
def execute
if options[:all] and not options[:args].empty? then
- alert_error 'Gem names and --all may not be used together'
- terminate_interaction 1
+ uninstall_specific
elsif options[:all] then
uninstall_all
else
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 77bf5edb452..e53798db86d 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -244,6 +244,9 @@ command to remove old versions.
args << '--no-rdoc' unless options[:document].include? 'rdoc'
args << '--no-ri' unless options[:document].include? 'ri'
args << '--no-format-executable' if options[:no_format_executable]
+ args << '--previous-version' << Gem::VERSION if
+ options[:system] == true or
+ Gem::Version.new(options[:system]) >= Gem::Version.new(2)
args
end
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index 99b9085b2bf..18706afdf5f 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -45,9 +45,9 @@ requiring to see why it does not behave as you expect.
if spec then
if options[:search_gems_first] then
- dirs = gem_paths(spec) + $LOAD_PATH
+ dirs = spec.full_require_paths + $LOAD_PATH
else
- dirs = $LOAD_PATH + gem_paths(spec)
+ dirs = $LOAD_PATH + spec.full_require_paths
end
end
@@ -81,10 +81,6 @@ requiring to see why it does not behave as you expect.
result
end
- def gem_paths(spec)
- spec.require_paths.collect { |d| File.join spec.full_gem_path, d }
- end
-
def usage # :nodoc:
"#{program_name} FILE [FILE ...]"
end