aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands/cleanup_command.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 03:45:05 +0000
commitd22130922e7842226d38d59680e4bbb48a28a5f0 (patch)
tree39594d3a14641dd5488a99a5e633239296fa5742 /lib/rubygems/commands/cleanup_command.rb
parent4752539e3f3e563d559732c52424206bd6f12dbd (diff)
downloadruby-d22130922e7842226d38d59680e4bbb48a28a5f0.tar.gz
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/cleanup_command.rb')
-rw-r--r--lib/rubygems/commands/cleanup_command.rb29
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index 0cdf50433e..2d8d8ff4fc 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -5,7 +5,6 @@
######################################################################
require 'rubygems/command'
-require 'rubygems/source_index'
require 'rubygems/dependency_list'
require 'rubygems/uninstaller'
@@ -44,28 +43,20 @@ installed elsewhere in GEM_PATH the cleanup command won't touch it.
say "Cleaning up installed gems..."
primary_gems = {}
- Gem.source_index.each do |name, spec|
+ Gem::Specification.each do |spec|
if primary_gems[spec.name].nil? or
primary_gems[spec.name].version < spec.version then
primary_gems[spec.name] = spec
end
end
- gems_to_cleanup = []
-
- unless options[:args].empty? then
- options[:args].each do |gem_name|
- dep = Gem::Dependency.new gem_name, Gem::Requirement.default
- specs = Gem.source_index.search dep
- specs.each do |spec|
- gems_to_cleanup << spec
- end
- end
- else
- Gem.source_index.each do |name, spec|
- gems_to_cleanup << spec
- end
- end
+ gems_to_cleanup = unless options[:args].empty? then
+ options[:args].map do |gem_name|
+ Gem::Specification.find_all_by_name gem_name
+ end.flatten
+ else
+ Gem::Specification.to_a
+ end
gems_to_cleanup = gems_to_cleanup.select { |spec|
primary_gems[spec.name].version != spec.version
@@ -89,8 +80,8 @@ installed elsewhere in GEM_PATH the cleanup command won't touch it.
:version => "= #{spec.version}",
}
- if Gem.user_dir == spec.installation_path then
- uninstall_options[:install_dir] = spec.installation_path
+ if Gem.user_dir == spec.base_dir then
+ uninstall_options[:install_dir] = spec.base_dir
end
uninstaller = Gem::Uninstaller.new spec.name, uninstall_options