Removed old progress meter module from util
This commit is contained in:
parent
b2c2d2a4cc
commit
a5cb80f396
|
@ -11,6 +11,6 @@ end
|
||||||
require File.expand_path("util/glob_loader", libdir)
|
require File.expand_path("util/glob_loader", libdir)
|
||||||
|
|
||||||
# Load them up
|
# 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
|
actions/base downloaders/base actions/collection actions/runner config
|
||||||
provisioners/base provisioners/chef systems/base commands/base commands/box})
|
provisioners/base provisioners/chef systems/base commands/base commands/box})
|
||||||
|
|
|
@ -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
|
|
|
@ -115,6 +115,10 @@ class ResourceLoggerTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
context "command line reset" do
|
context "command line reset" do
|
||||||
|
setup do
|
||||||
|
Mario::Platform.logger(nil)
|
||||||
|
end
|
||||||
|
|
||||||
context "on windows" do
|
context "on windows" do
|
||||||
setup do
|
setup do
|
||||||
Mario::Platform.forced = Mario::Platform::Windows7
|
Mario::Platform.forced = Mario::Platform::Windows7
|
||||||
|
|
|
@ -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
|
|
|
@ -96,7 +96,6 @@ Gem::Specification.new do |s|
|
||||||
"lib/vagrant/util/output_helper.rb",
|
"lib/vagrant/util/output_helper.rb",
|
||||||
"lib/vagrant/util/plain_logger.rb",
|
"lib/vagrant/util/plain_logger.rb",
|
||||||
"lib/vagrant/util/platform.rb",
|
"lib/vagrant/util/platform.rb",
|
||||||
"lib/vagrant/util/progress_meter.rb",
|
|
||||||
"lib/vagrant/util/stacked_proc_runner.rb",
|
"lib/vagrant/util/stacked_proc_runner.rb",
|
||||||
"lib/vagrant/util/template_renderer.rb",
|
"lib/vagrant/util/template_renderer.rb",
|
||||||
"lib/vagrant/util/translator.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/error_helper_test.rb",
|
||||||
"test/vagrant/util/output_helper_test.rb",
|
"test/vagrant/util/output_helper_test.rb",
|
||||||
"test/vagrant/util/plain_logger_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/stacked_proc_runner_test.rb",
|
||||||
"test/vagrant/util/template_renderer_test.rb",
|
"test/vagrant/util/template_renderer_test.rb",
|
||||||
"test/vagrant/util/translator_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/file_test.rb",
|
||||||
"test/vagrant/downloaders/http_test.rb",
|
"test/vagrant/downloaders/http_test.rb",
|
||||||
"test/vagrant/util/stacked_proc_runner_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/output_helper_test.rb",
|
||||||
"test/vagrant/util/template_renderer_test.rb",
|
"test/vagrant/util/template_renderer_test.rb",
|
||||||
"test/vagrant/util/translator_test.rb",
|
"test/vagrant/util/translator_test.rb",
|
||||||
|
|
Loading…
Reference in New Issue