From a5cb80f396a81960fabe048c876ca4168ecc4c4c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 20 May 2010 22:54:48 -0700 Subject: [PATCH] Removed old progress meter module from util --- lib/vagrant.rb | 2 +- lib/vagrant/util/progress_meter.rb | 33 ------------------------ test/vagrant/resource_logger_test.rb | 4 +++ test/vagrant/util/progress_meter_test.rb | 33 ------------------------ vagrant.gemspec | 3 --- 5 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 lib/vagrant/util/progress_meter.rb delete mode 100644 test/vagrant/util/progress_meter_test.rb diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 4e1bb23c1..95316e7b7 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -11,6 +11,6 @@ end require File.expand_path("util/glob_loader", libdir) # Load them up -Vagrant::GlobLoader.glob_require(libdir, %w{util/stacked_proc_runner util/progress_meter +Vagrant::GlobLoader.glob_require(libdir, %w{util/stacked_proc_runner actions/base downloaders/base actions/collection actions/runner config provisioners/base provisioners/chef systems/base commands/base commands/box}) diff --git a/lib/vagrant/util/progress_meter.rb b/lib/vagrant/util/progress_meter.rb deleted file mode 100644 index afbfa13e8..000000000 --- a/lib/vagrant/util/progress_meter.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Vagrant - module Util - # A mixin which allows any class to be able to show a "progress meter" - # to standard out. The progress meter shows the progress of an operation - # with console-animated text in stdout. - module ProgressMeter - # Updates the progress meter with the given progress amount and total. - # This method will do the math to figure out a percentage and show it - # within stdout. - # - # @param [Float] progress Progress - # @param [Float] total Total - def update_progress(progress, total, show_parts=true) - percent = (progress.to_f / total.to_f) * 100 - print "#{cl_reset}Progress: #{percent.to_i}%" - print " (#{progress} / #{total})" if show_parts - $stdout.flush - end - - # Completes the progress meter by resetting it off of the screen. - def complete_progress - # Just clear the line back out - print "#{cl_reset}" - end - - def cl_reset - reset = "\r" - reset += "\e[0K" unless Mario::Platform.windows? - reset - end - end - end -end diff --git a/test/vagrant/resource_logger_test.rb b/test/vagrant/resource_logger_test.rb index 92e958bc9..ccd788912 100644 --- a/test/vagrant/resource_logger_test.rb +++ b/test/vagrant/resource_logger_test.rb @@ -115,6 +115,10 @@ class ResourceLoggerTest < Test::Unit::TestCase end context "command line reset" do + setup do + Mario::Platform.logger(nil) + end + context "on windows" do setup do Mario::Platform.forced = Mario::Platform::Windows7 diff --git a/test/vagrant/util/progress_meter_test.rb b/test/vagrant/util/progress_meter_test.rb deleted file mode 100644 index b74b69a58..000000000 --- a/test/vagrant/util/progress_meter_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') - -class ProgressMeterUtilTest < Test::Unit::TestCase - class TestProgressMeter - include Vagrant::Util::ProgressMeter - end - - setup do - @instance = TestProgressMeter.new - - Mario::Platform.logger(nil) - end - - context "on windows" do - setup do - Mario::Platform.forced = Mario::Platform::Windows7 - end - - should "just return \\r for the clear screen" do - assert_equal "\r", @instance.cl_reset - end - end - - context "on other platforms" do - setup do - Mario::Platform.forced = Mario::Platform::Linux - end - - should "return the full clear screen" do - assert_equal "\r\e[0K", @instance.cl_reset - end - end -end diff --git a/vagrant.gemspec b/vagrant.gemspec index 50e16b408..77a1729e4 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -96,7 +96,6 @@ Gem::Specification.new do |s| "lib/vagrant/util/output_helper.rb", "lib/vagrant/util/plain_logger.rb", "lib/vagrant/util/platform.rb", - "lib/vagrant/util/progress_meter.rb", "lib/vagrant/util/stacked_proc_runner.rb", "lib/vagrant/util/template_renderer.rb", "lib/vagrant/util/translator.rb", @@ -169,7 +168,6 @@ Gem::Specification.new do |s| "test/vagrant/util/error_helper_test.rb", "test/vagrant/util/output_helper_test.rb", "test/vagrant/util/plain_logger_test.rb", - "test/vagrant/util/progress_meter_test.rb", "test/vagrant/util/stacked_proc_runner_test.rb", "test/vagrant/util/template_renderer_test.rb", "test/vagrant/util/translator_test.rb", @@ -240,7 +238,6 @@ Gem::Specification.new do |s| "test/vagrant/downloaders/file_test.rb", "test/vagrant/downloaders/http_test.rb", "test/vagrant/util/stacked_proc_runner_test.rb", - "test/vagrant/util/progress_meter_test.rb", "test/vagrant/util/output_helper_test.rb", "test/vagrant/util/template_renderer_test.rb", "test/vagrant/util/translator_test.rb",