lib/chef/provider/package/rubygems.rb in chef-0.9.0.a90 vs lib/chef/provider/package/rubygems.rb in chef-0.9.0.a91
- old
+ new
@@ -147,11 +147,13 @@
# === Options
# :sources rubygems servers to use
# Other options are passed to Gem::DependencyInstaller.new
def install(gem_dependency, options={})
with_gem_sources(*options.delete(:sources)) do
- dependency_installer(options).install(gem_dependency)
+ with_correct_verbosity do
+ dependency_installer(options).install(gem_dependency)
+ end
end
end
##
# Uninstall the gem +gem_name+ via the rubygems ruby API. If
@@ -159,10 +161,20 @@
# Otherwise, all versions are uninstalled.
# === Options
# Options are passed to Gem::Uninstaller.new
def uninstall(gem_name, gem_version=nil, opts={})
gem_version ? opts[:version] = gem_version : opts[:all] = true
- uninstaller(gem_name, opts).uninstall
+ with_correct_verbosity do
+ uninstaller(gem_name, opts).uninstall
+ end
+ end
+
+ ##
+ # Set rubygems' user interaction to ConsoleUI or SilentUI depending
+ # on our current debug level
+ def with_correct_verbosity
+ Gem::DefaultUserInteraction.ui = Chef::Log.debug? ? Gem::ConsoleUI.new : Gem::SilentUI.new
+ yield
end
def dependency_installer(opts={})
Gem::DependencyInstaller.new(opts)
end