summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-28 03:08:14 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-28 03:08:14 +0000
commit5dbc6583c93621a7e992163bd27991bd3d3d9378 (patch)
tree93d60f32d81d9ee58b538586f44acccbbc27c230 /lib/rubygems
parentb52761e4f71326099374515e494b1667b2bbf84b (diff)
Merge rubygems upstream from https://github.com/rubygems/rubygems/commit/2c499655f29070c809dfea9f5fda6fac6850e62e
https://github.com/rubygems/rubygems/pull/2493 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/install_command.rb2
-rw-r--r--lib/rubygems/commands/pristine_command.rb5
-rw-r--r--lib/rubygems/commands/uninstall_command.rb21
-rw-r--r--lib/rubygems/installer.rb10
-rw-r--r--lib/rubygems/specification.rb10
5 files changed, 23 insertions, 25 deletions
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index fca14681ee..776b58651f 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -142,7 +142,7 @@ You can use `i` command instead of `install`.
if options[:version] != Gem::Requirement.default and
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
- " version requirments using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ " version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
end
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index b686d8341d..41decde856 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -129,11 +129,6 @@ extensions will be restored.
end
end
- if spec.bundled_gem_in_old_ruby?
- say "Skipped #{spec.full_name}, it is bundled with old Ruby"
- next
- end
-
unless spec.extensions.empty? or options[:extensions] or options[:only_executables]
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 3f975ce3bc..9de0ea722b 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -114,7 +114,18 @@ that is a dependency of an existing gem. You can use the
"#{program_name} GEMNAME [GEMNAME ...]"
end
+ def check_version # :nodoc:
+ if options[:version] != Gem::Requirement.default and
+ get_all_gem_names.size > 1
+ alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
+ " version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
+ terminate_interaction 1
+ end
+ end
+
def execute
+ check_version
+
if options[:all] and not options[:args].empty?
uninstall_specific
elsif options[:all]
@@ -138,8 +149,9 @@ that is a dependency of an existing gem. You can use the
def uninstall_specific
deplist = Gem::DependencyList.new
- get_all_gem_names.uniq.each do |name|
- gem_specs = Gem::Specification.find_all_by_name(name)
+ get_all_gem_names_and_versions.each do |name, version|
+ requirement = Array(version || options[:version])
+ gem_specs = Gem::Specification.find_all_by_name(name, *requirement)
say("Gem '#{name}' is not installed") if gem_specs.empty?
gem_specs.each do |spec|
deplist.add spec
@@ -148,8 +160,9 @@ that is a dependency of an existing gem. You can use the
deps = deplist.strongly_connected_components.flatten.reverse
- deps.map(&:name).uniq.each do |gem_name|
- uninstall_gem(gem_name)
+ deps.each do |dep|
+ options[:version] = dep.version
+ uninstall_gem(dep.name)
end
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 3c2a2ac3c2..b1f83174bd 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -749,11 +749,11 @@ require 'rubygems'
version = "#{Gem::Requirement.default}.a"
-if ARGV.first
- str = ARGV.first
- str = str.dup.force_encoding("BINARY")
- if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1)
- version = $1
+str = ARGV.first
+if str
+ str = str.b[/\\A_(.*)_\\z/, 1]
+ if str and Gem::Version.correct?(str)
+ version = str
ARGV.shift
end
end
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 4721bfc415..7eaa509d2b 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1661,16 +1661,6 @@ class Gem::Specification < Gem::BasicSpecification
end
##
- # Used to detect if the gem is bundled in older version of Ruby, but not
- # detectable as default gem (see BasicSpecification#default_gem?).
-
- def bundled_gem_in_old_ruby?
- !default_gem? &&
- RUBY_VERSION < "2.0.0" &&
- summary == "This #{name} is bundled with Ruby"
- end
-
- ##
# Returns the full path to the cache directory containing this
# spec's cached gem.