From e487a7f53cffbadf0bf15ff169c9cb5898503250 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 26 Aug 2013 20:24:51 +0000 Subject: * lib/rubygems: Import RubyGems 2.1.0 Release Candidate * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/uninstall_command.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'lib/rubygems/commands/uninstall_command.rb') diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 5db8a1ff22..8e6af2ba65 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -88,6 +88,16 @@ class Gem::Commands::UninstallCommand < Gem::Command "--user-install" end + def description # :nodoc: + <<-EOF +The uninstall command removes a previously installed gem. + +RubyGems will ask for confirmation if you are attempting to uninstall a gem +that is a dependency of an existing gem. You can use the +--ignore-dependencies option to skip this check. + EOF + end + def usage # :nodoc: "#{program_name} GEMNAME [GEMNAME ...]" end @@ -104,15 +114,18 @@ class Gem::Commands::UninstallCommand < Gem::Command end def uninstall_all - install_dir = options[:install_dir] + _, specs = Gem::Specification.partition { |spec| spec.default_gem? } - dirs_to_be_emptied = Dir[File.join(install_dir, '*')] - dirs_to_be_emptied.delete_if { |dir| dir.end_with? 'build_info' } + specs.each do |spec| + options[:version] = spec.version - dirs_to_be_emptied.each do |dir| - FileUtils.rm_rf Dir[File.join(dir, '*')] + begin + Gem::Uninstaller.new(spec.name, options).uninstall + rescue Gem::InstallError + end end - alert("Successfully uninstalled all gems in #{install_dir}") + + alert "Uninstalled all gems in #{options[:install_dir]}" end def uninstall_specific -- cgit v1.2.3