Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set #spec during Gem::Uninstaller#uninstall_gem

git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1829 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information...
commit bba98e83179f3f1c490d4840a3caa94d9176c85f 1 parent 6e5b317
drbrain authored
View
13 lib/rubygems/uninstaller.rb
@@ -18,6 +18,11 @@ class Gem::Uninstaller
include Gem::UserInteraction
##
+ # Spec currently being uninstalled. Only set during #uninstall_gem
+
+ attr_reader :spec
+
+ ##
# Constructs an Uninstaller instance
#
# gem:: [String] The Gem name to uninstall
@@ -68,16 +73,20 @@ def uninstall
# Uninstalls gem +spec+
def uninstall_gem(spec, specs)
+ @spec = spec
+
Gem.pre_uninstall_hooks.each do |hook|
- hook.call self, spec
+ hook.call self
end
remove spec, specs
specs.each do |s| remove_executables s end
Gem.post_uninstall_hooks.each do |hook|
- hook.call self, spec
+ hook.call self
end
+
+ @spec = nil
end
##
View
8 test/gemutilities.rb
@@ -99,16 +99,16 @@ def setup
@post_install_hook_arg = installer
end
- Gem.post_uninstall do |uninstaller, spec|
- @post_uninstall_hook_arg = [uninstaller, spec]
+ Gem.post_uninstall do |uninstaller|
+ @post_uninstall_hook_arg = uninstaller
end
Gem.pre_install do |installer|
@pre_install_hook_arg = installer
end
- Gem.pre_uninstall do |uninstaller, spec|
- @pre_uninstall_hook_arg = [uninstaller, spec]
+ Gem.pre_uninstall do |uninstaller|
+ @pre_uninstall_hook_arg = uninstaller
end
end
View
9 test/test_gem_uninstaller.rb
@@ -77,13 +77,8 @@ def test_uninstall
assert !File.exist?(gem_dir)
- pre_uninstaller, spec = @pre_uninstall_hook_arg
- assert_same uninstaller, pre_uninstaller
- assert_equal @spec, spec
-
- post_uninstaller, spec = @post_uninstall_hook_arg
- assert_same uninstaller, post_uninstaller
- assert_equal @spec, spec
+ assert_same uninstaller, @pre_uninstall_hook_arg
+ assert_same uninstaller, @post_uninstall_hook_arg
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.