From 1cbdbdc6bf039114d2d40449a0cb1185633b8091 Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Fri, 24 Jan 2014 11:31:55 -0500 Subject: [PATCH] Use our own Vagrant::UI for logging --- lib/vagrant-cachier/action/clean.rb | 4 ++-- lib/vagrant-cachier/action/ensure_single_cache_root.rb | 2 +- lib/vagrant-cachier/bucket/apt.rb | 2 +- lib/vagrant-cachier/bucket/apt_cacher.rb | 4 ++-- lib/vagrant-cachier/bucket/chef.rb | 2 +- lib/vagrant-cachier/bucket/composer.rb | 2 +- lib/vagrant-cachier/bucket/gem.rb | 2 +- lib/vagrant-cachier/bucket/npm.rb | 2 +- lib/vagrant-cachier/bucket/pacman.rb | 2 +- lib/vagrant-cachier/bucket/rvm.rb | 2 +- lib/vagrant-cachier/bucket/yum.rb | 2 +- lib/vagrant-cachier/bucket/zypper.rb | 2 +- lib/vagrant-cachier/plugin.rb | 4 ++++ lib/vagrant-cachier/provision_ext.rb | 2 +- 14 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/vagrant-cachier/action/clean.rb b/lib/vagrant-cachier/action/clean.rb index a2015bf..bbc1143 100644 --- a/lib/vagrant-cachier/action/clean.rb +++ b/lib/vagrant-cachier/action/clean.rb @@ -14,7 +14,7 @@ module VagrantPlugins @machine = env[:machine] if symlinks.any? - env[:ui].info I18n.t('vagrant_cachier.cleanup') + Cachier.ui.info I18n.t('vagrant_cachier.cleanup') if sshable? symlinks.each do |symlink| remove_symlink symlink @@ -43,7 +43,7 @@ module VagrantPlugins end end rescue Timeout::Error - @env[:ui].warn(I18n.t('vagrant_cachier.unable_to_ssh')) + Cachier.ui.warn(I18n.t('vagrant_cachier.unable_to_ssh')) end return false diff --git a/lib/vagrant-cachier/action/ensure_single_cache_root.rb b/lib/vagrant-cachier/action/ensure_single_cache_root.rb index def6375..7366af8 100644 --- a/lib/vagrant-cachier/action/ensure_single_cache_root.rb +++ b/lib/vagrant-cachier/action/ensure_single_cache_root.rb @@ -43,7 +43,7 @@ module VagrantPlugins new_path = new_path.to_s.gsub(/^#{@env[:root_path]}\//, '') # If we got here there is a single provider specific cacher dir, so # let's be nice with users and just fix it ;) - @env[:ui].warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir', + Cachier.ui.warn I18n.t('vagrant_cachier.will_fix_machine_cache_dir', current_path: current_path, new_path: new_path) FileUtils.mv current_path, new_path diff --git a/lib/vagrant-cachier/bucket/apt.rb b/lib/vagrant-cachier/bucket/apt.rb index 3b326df..210f269 100644 --- a/lib/vagrant-cachier/bucket/apt.rb +++ b/lib/vagrant-cachier/bucket/apt.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'APT') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'APT') end end end diff --git a/lib/vagrant-cachier/bucket/apt_cacher.rb b/lib/vagrant-cachier/bucket/apt_cacher.rb index 57c6f8d..5ec4060 100644 --- a/lib/vagrant-cachier/bucket/apt_cacher.rb +++ b/lib/vagrant-cachier/bucket/apt_cacher.rb @@ -26,11 +26,11 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher') + Cachier.ui.info I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher') end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-cacher') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-cacher') end end end diff --git a/lib/vagrant-cachier/bucket/chef.rb b/lib/vagrant-cachier/bucket/chef.rb index b78bbe4..d36e30b 100644 --- a/lib/vagrant-cachier/bucket/chef.rb +++ b/lib/vagrant-cachier/bucket/chef.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef') end end end diff --git a/lib/vagrant-cachier/bucket/composer.rb b/lib/vagrant-cachier/bucket/composer.rb index cb939ad..2171774 100644 --- a/lib/vagrant-cachier/bucket/composer.rb +++ b/lib/vagrant-cachier/bucket/composer.rb @@ -25,7 +25,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer') end end end diff --git a/lib/vagrant-cachier/bucket/gem.rb b/lib/vagrant-cachier/bucket/gem.rb index e166520..1087f35 100644 --- a/lib/vagrant-cachier/bucket/gem.rb +++ b/lib/vagrant-cachier/bucket/gem.rb @@ -29,7 +29,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems') end end end diff --git a/lib/vagrant-cachier/bucket/npm.rb b/lib/vagrant-cachier/bucket/npm.rb index f10a2ce..d6ebd13 100644 --- a/lib/vagrant-cachier/bucket/npm.rb +++ b/lib/vagrant-cachier/bucket/npm.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'npm') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'npm') end end end diff --git a/lib/vagrant-cachier/bucket/pacman.rb b/lib/vagrant-cachier/bucket/pacman.rb index c9d9cdc..6d804af 100644 --- a/lib/vagrant-cachier/bucket/pacman.rb +++ b/lib/vagrant-cachier/bucket/pacman.rb @@ -24,7 +24,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman') end end end diff --git a/lib/vagrant-cachier/bucket/rvm.rb b/lib/vagrant-cachier/bucket/rvm.rb index ce57ff8..528cba0 100644 --- a/lib/vagrant-cachier/bucket/rvm.rb +++ b/lib/vagrant-cachier/bucket/rvm.rb @@ -29,7 +29,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM') end end end diff --git a/lib/vagrant-cachier/bucket/yum.rb b/lib/vagrant-cachier/bucket/yum.rb index d43af7c..654a838 100644 --- a/lib/vagrant-cachier/bucket/yum.rb +++ b/lib/vagrant-cachier/bucket/yum.rb @@ -27,7 +27,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum') end end end diff --git a/lib/vagrant-cachier/bucket/zypper.rb b/lib/vagrant-cachier/bucket/zypper.rb index f556b21..6949e3a 100644 --- a/lib/vagrant-cachier/bucket/zypper.rb +++ b/lib/vagrant-cachier/bucket/zypper.rb @@ -27,7 +27,7 @@ module VagrantPlugins end end else - @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Zypper') + Cachier.ui.info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Zypper') end end end diff --git a/lib/vagrant-cachier/plugin.rb b/lib/vagrant-cachier/plugin.rb index c6c638f..b8a57b6 100644 --- a/lib/vagrant-cachier/plugin.rb +++ b/lib/vagrant-cachier/plugin.rb @@ -8,6 +8,10 @@ I18n.load_path << File.expand_path("../../../locales/en.yml", __FILE__) module VagrantPlugins module Cachier + def self.ui + @ui ||= ::Vagrant::UI::Colored.new.scope('Cachier') + end + class Plugin < Vagrant.plugin('2') name 'vagrant-cachier' diff --git a/lib/vagrant-cachier/provision_ext.rb b/lib/vagrant-cachier/provision_ext.rb index a04b266..3ef9f34 100644 --- a/lib/vagrant-cachier/provision_ext.rb +++ b/lib/vagrant-cachier/provision_ext.rb @@ -46,7 +46,7 @@ module VagrantPlugins return unless @env[:machine].config.cache.buckets.any? - @env[:ui].info 'Configuring cache buckets...' + Cachier.ui.info 'Configuring cache buckets...' cache_config = @env[:machine].config.cache cache_config.buckets.each do |bucket_name, configs| cachier_debug "Installing #{bucket_name} with configs #{configs.inspect}"