From 9694bb8cac12969300692dac5a1cf7aa4e3a46cd Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 29 Nov 2012 06:52:18 +0000 Subject: * lib/rubygems*: Updated to RubyGems 2.0 * test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/uninstall_command.rb | 31 +++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 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 aaadb762b5..736574ddff 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -13,7 +13,8 @@ class Gem::Commands::UninstallCommand < Gem::Command def initialize super 'uninstall', 'Uninstall gems from the local repository', - :version => Gem::Requirement.default, :user_install => true + :version => Gem::Requirement.default, :user_install => true, + :check_dev => false add_option('-a', '--[no-]all', 'Uninstall all matching versions' @@ -27,6 +28,12 @@ class Gem::Commands::UninstallCommand < Gem::Command options[:ignore] = value end + add_option('-D', '--[no-]-check-development', + 'Check development dependencies while uninstalling', + '(default: false)') do |value, options| + options[:check_dev] = value + end + add_option('-x', '--[no-]executables', 'Uninstall applicable executables without', 'confirmation') do |value, options| @@ -54,6 +61,12 @@ class Gem::Commands::UninstallCommand < Gem::Command options[:format_executable] = value end + add_option('--[no-]force', + 'Uninstall all versions of the named gems', + 'ignoring dependencies') do |value, options| + options[:force] = value + end + add_version_option add_platform_option end @@ -73,19 +86,23 @@ class Gem::Commands::UninstallCommand < Gem::Command end def execute - original_path = Gem.path + # REFACTOR: stolen from cleanup_command + deplist = Gem::DependencyList.new + get_all_gem_names.uniq.each do |name| + Gem::Specification.find_all_by_name(name).each do |spec| + deplist.add spec + end + end + + deps = deplist.strongly_connected_components.flatten.reverse - get_all_gem_names.each do |gem_name| + deps.map(&:name).uniq.each do |gem_name| begin Gem::Uninstaller.new(gem_name, options).uninstall - rescue Gem::InstallError => e - alert e.message rescue Gem::GemNotInHomeException => e spec = e.spec alert("In order to remove #{spec.name}, please execute:\n" \ "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}") - ensure - Gem.use_paths(*original_path) end end end -- cgit v1.2.3