aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/uninstaller.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-19 07:19:10 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-19 07:19:10 +0000
commiteddc0685f224a6de2f5a6bdaab7f87562192ba7f (patch)
tree54f3427a70f2cc21e9dbbb6c3ad9ed500ea96865 /lib/rubygems/uninstaller.rb
parent1b2be1f8ca5286a75d9401f96eaec89317353e3e (diff)
downloadruby-eddc0685f224a6de2f5a6bdaab7f87562192ba7f.tar.gz
* lib/rubygems/commands/query_command.rb: Refactored to improve
maintainability. * test/rubygems/test_gem_commands_query_command.rb: Note default gems in gem list details. * lib/rubygems/uninstaller.rb: Detect all gems for uninstallation. This allows duplicate installs of default gems to be removed. * lib/rubygems/specification.rb: Allow use of ::each_spec. * lib/rubygems/test_case.rb: Added install_default_gems. * test/rubygems/test_gem_commands_uninstall_command.rb: Moved test down to the uninstaller tests. * test/rubygems/test_gem_uninstaller.rb: Test for uninstallation of default gems and duplicate default gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/uninstaller.rb')
-rw-r--r--lib/rubygems/uninstaller.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index 475211dfe3..d672b9dec1 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -72,7 +72,19 @@ class Gem::Uninstaller
# directory, and the cached .gem file.
def uninstall
- list = Gem::Specification.find_all_by_name(@gem, @version)
+ dependency = Gem::Dependency.new @gem, @version
+
+ list = []
+
+ dirs =
+ Gem::Specification.dirs +
+ [Gem::Specification.default_specifications_dir]
+
+ Gem::Specification.each_spec dirs do |spec|
+ next unless dependency.matches_spec? spec
+
+ list << spec
+ end
default_specs, list = list.partition do |spec|
spec.default_gem?
@@ -80,7 +92,7 @@ class Gem::Uninstaller
list, other_repo_specs = list.partition do |spec|
@gem_home == spec.base_dir or
- (@user_install and spec.base_dir == Gem.user_dir)
+ (@user_install and spec.base_dir == Gem.user_dir)
end
if list.empty? then