Perform gem uninstallation for prune

This commit is contained in:
Mitchell Hashimoto 2013-02-03 10:30:52 -08:00
parent 472d4182c1
commit 572142df7e
1 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,5 @@
require "rubygems"
require "rubygems/uninstaller"
require "set"
require "log4r"
@ -121,7 +122,29 @@ module VagrantPlugins
prune_specs = all_specs - good_specs
@logger.info("Gems to prune: #{prune_specs.inspect}")
# TODO: Prune
if prune_specs.length > 0
env[:gem_helper].with_environment do
prune_specs.each do |prune_spec|
uninstaller = Gem::Uninstaller.new(prune_spec.name, {
:executables => true,
:force => true,
:version => prune_spec.version.version
})
# This is sad, but there is no way to force this to be true
# so I just monkey-patch here. Vagrant has a pretty strict
# version check on the RubyGems version so this should be okay.
# In the future, let's try to get a pull request into RubyGems
# to fix this.
def uninstaller.ask_if_ok(spec)
true
end
@logger.info("Uninstalling: #{prune_spec.name} (#{prune_spec.version})")
uninstaller.uninstall
end
end
end
@app.call(env)
end