brew vendor-gems: commit updates.
This commit is contained in:
parent
4d9ea265e5
commit
b9695b2dfe
@ -101,7 +101,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
|||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.1/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-sorbet-1.9.1/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec_junit_formatter-0.6.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-ast-1.27.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-ast-1.27.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.11.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.12.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-2.4.2/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unicode-display_width-2.4.2/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.46.0/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.46.0/lib")
|
||||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-capybara-2.17.1/lib")
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'ruby-progressbar/output'
|
|
||||||
require 'ruby-progressbar/outputs/tty'
|
|
||||||
require 'ruby-progressbar/outputs/non_tty'
|
|
||||||
require 'ruby-progressbar/timer'
|
|
||||||
require 'ruby-progressbar/progress'
|
|
||||||
require 'ruby-progressbar/throttle'
|
|
||||||
require 'ruby-progressbar/calculators/length'
|
|
||||||
require 'ruby-progressbar/calculators/running_average'
|
|
||||||
require 'ruby-progressbar/components'
|
|
||||||
require 'ruby-progressbar/format'
|
|
||||||
require 'ruby-progressbar/base'
|
|
||||||
require 'ruby-progressbar/refinements' if Module.
|
|
||||||
private_instance_methods.
|
|
||||||
include?(:using)
|
|
||||||
|
|
||||||
class ProgressBar
|
|
||||||
def self.create(*args)
|
|
||||||
ProgressBar::Base.new(*args)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
class ProgressBar
|
|
||||||
module Calculators
|
|
||||||
class RunningAverage
|
|
||||||
def self.calculate(current_average, new_value_to_average, smoothing_factor)
|
|
||||||
new_value_to_average * (1.0 - smoothing_factor) + current_average * smoothing_factor
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
require 'ruby-progressbar/components/bar'
|
|
||||||
require 'ruby-progressbar/components/percentage'
|
|
||||||
require 'ruby-progressbar/components/rate'
|
|
||||||
require 'ruby-progressbar/components/time'
|
|
||||||
require 'ruby-progressbar/components/title'
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
require 'ruby-progressbar/format/molecule'
|
|
||||||
require 'ruby-progressbar/format/formatter'
|
|
||||||
require 'ruby-progressbar/format/string'
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
class ProgressBar
|
|
||||||
module Format
|
|
||||||
class Molecule
|
|
||||||
MOLECULES = {
|
|
||||||
:t => [:title_comp, :title],
|
|
||||||
:T => [:title_comp, :title],
|
|
||||||
:c => [:progressable, :progress],
|
|
||||||
:C => [:progressable, :total],
|
|
||||||
:u => [:progressable, :total_with_unknown_indicator],
|
|
||||||
:p => [:percentage, :percentage],
|
|
||||||
:P => [:percentage, :percentage_with_precision],
|
|
||||||
:j => [:percentage, :justified_percentage],
|
|
||||||
:J => [:percentage, :justified_percentage_with_precision],
|
|
||||||
:a => [:time, :elapsed_with_label],
|
|
||||||
:e => [:time, :estimated_with_unknown_oob],
|
|
||||||
:E => [:time, :estimated_with_friendly_oob],
|
|
||||||
:f => [:time, :estimated_with_no_oob],
|
|
||||||
:B => [:bar, :complete_bar],
|
|
||||||
:b => [:bar, :bar],
|
|
||||||
:W => [:bar, :complete_bar_with_percentage],
|
|
||||||
:w => [:bar, :bar_with_percentage],
|
|
||||||
:i => [:bar, :incomplete_space],
|
|
||||||
:r => [:rate, :rate_of_change],
|
|
||||||
:R => [:rate, :rate_of_change_with_precision]
|
|
||||||
}.freeze
|
|
||||||
|
|
||||||
BAR_MOLECULES = %w{W w B b i}.freeze
|
|
||||||
|
|
||||||
attr_accessor :key,
|
|
||||||
:method_name
|
|
||||||
|
|
||||||
def initialize(letter)
|
|
||||||
self.key = letter
|
|
||||||
self.method_name = MOLECULES.fetch(key.to_sym)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bar_molecule?
|
|
||||||
BAR_MOLECULES.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
def non_bar_molecule?
|
|
||||||
!bar_molecule?
|
|
||||||
end
|
|
||||||
|
|
||||||
def full_key
|
|
||||||
"%#{key}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def lookup_value(environment, length = 0)
|
|
||||||
component = environment.__send__(method_name[0])
|
|
||||||
|
|
||||||
if bar_molecule?
|
|
||||||
component.__send__(method_name[1], length).to_s
|
|
||||||
else
|
|
||||||
component.__send__(method_name[1]).to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
class ProgressBar
|
|
||||||
VERSION = '1.11.0'.freeze
|
|
||||||
end
|
|
||||||
12
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.12.0/lib/ruby-progressbar.rb
vendored
Normal file
12
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.12.0/lib/ruby-progressbar.rb
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'ruby-progressbar/base'
|
||||||
|
require 'ruby-progressbar/refinements' if Module.
|
||||||
|
private_instance_methods.
|
||||||
|
include?(:using)
|
||||||
|
|
||||||
|
class ProgressBar
|
||||||
|
def self.create(*args)
|
||||||
|
ProgressBar::Base.new(*args)
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,5 +1,17 @@
|
|||||||
require 'forwardable'
|
require 'forwardable'
|
||||||
|
|
||||||
|
require 'ruby-progressbar/components/bar'
|
||||||
|
require 'ruby-progressbar/components/percentage'
|
||||||
|
require 'ruby-progressbar/components/rate'
|
||||||
|
require 'ruby-progressbar/components/time'
|
||||||
|
require 'ruby-progressbar/components/title'
|
||||||
|
require 'ruby-progressbar/format/formatter'
|
||||||
|
require 'ruby-progressbar/format/string'
|
||||||
|
require 'ruby-progressbar/outputs/non_tty'
|
||||||
|
require 'ruby-progressbar/outputs/tty'
|
||||||
|
require 'ruby-progressbar/progress'
|
||||||
|
require 'ruby-progressbar/timer'
|
||||||
|
|
||||||
class ProgressBar
|
class ProgressBar
|
||||||
class Base
|
class Base
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
@ -21,14 +33,14 @@ class Base
|
|||||||
self.timer = Timer.new(options)
|
self.timer = Timer.new(options)
|
||||||
self.progressable = Progress.new(options)
|
self.progressable = Progress.new(options)
|
||||||
|
|
||||||
options = options.merge(:timer => timer,
|
options = options.merge(:progress => progressable,
|
||||||
:progress => progressable)
|
:timer => timer)
|
||||||
|
|
||||||
self.title_comp = Components::Title.new(options)
|
self.title_component = Components::Title.new(options)
|
||||||
self.bar = Components::Bar.new(options)
|
self.bar_component = Components::Bar.new(options)
|
||||||
self.percentage = Components::Percentage.new(options)
|
self.percentage_component = Components::Percentage.new(options)
|
||||||
self.rate = Components::Rate.new(options)
|
self.rate_component = Components::Rate.new(options)
|
||||||
self.time = Components::Time.new(options)
|
self.time_component = Components::Time.new(options)
|
||||||
|
|
||||||
self.output = Output.detect(options.merge(:bar => self))
|
self.output = Output.detect(options.merge(:bar => self))
|
||||||
@format = Format::String.new(output.resolve_format(options[:format]))
|
@format = Format::String.new(output.resolve_format(options[:format]))
|
||||||
@ -102,19 +114,19 @@ class Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def progress_mark=(mark)
|
def progress_mark=(mark)
|
||||||
output.refresh_with_format_change { bar.progress_mark = mark }
|
output.refresh_with_format_change { bar_component.progress_mark = mark }
|
||||||
end
|
end
|
||||||
|
|
||||||
def remainder_mark=(mark)
|
def remainder_mark=(mark)
|
||||||
output.refresh_with_format_change { bar.remainder_mark = mark }
|
output.refresh_with_format_change { bar_component.remainder_mark = mark }
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
title_comp.title
|
title_component.title
|
||||||
end
|
end
|
||||||
|
|
||||||
def title=(title)
|
def title=(title)
|
||||||
output.refresh_with_format_change { title_comp.title = title }
|
output.refresh_with_format_change { title_component.title = title }
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(new_format = nil)
|
def to_s(new_format = nil)
|
||||||
@ -128,17 +140,17 @@ class Base
|
|||||||
{
|
{
|
||||||
'output_stream' => output.__send__(:stream),
|
'output_stream' => output.__send__(:stream),
|
||||||
'length' => output.length,
|
'length' => output.length,
|
||||||
'title' => title_comp.title,
|
'title' => title_component.title,
|
||||||
'progress_mark' => bar.progress_mark,
|
'progress_mark' => bar_component.progress_mark,
|
||||||
'remainder_mark' => bar.remainder_mark,
|
'remainder_mark' => bar_component.remainder_mark,
|
||||||
'progress' => progressable.progress,
|
'progress' => progressable.progress,
|
||||||
'total' => progressable.total,
|
'total' => progressable.total,
|
||||||
'percentage' => progressable.percentage_completed_with_precision.to_f,
|
'percentage' => progressable.percentage_completed_with_precision.to_f,
|
||||||
'elapsed_time_in_seconds' => time.__send__(:timer).elapsed_seconds,
|
'elapsed_time_in_seconds' => time_component.__send__(:timer).elapsed_seconds,
|
||||||
'estimated_time_remaining_in_seconds' => time.__send__(:estimated_seconds_remaining),
|
'estimated_time_remaining_in_seconds' => time_component.__send__(:estimated_seconds_remaining),
|
||||||
'base_rate_of_change' => rate.__send__(:base_rate),
|
'base_rate_of_change' => rate_component.__send__(:base_rate),
|
||||||
'scaled_rate_of_change' => rate.__send__(:scaled_rate),
|
'scaled_rate_of_change' => rate_component.__send__(:scaled_rate),
|
||||||
'unknown_progress_animation_steps' => bar.upa_steps,
|
'unknown_progress_animation_steps' => bar_component.upa_steps,
|
||||||
'throttle_rate' => output.__send__(:throttle).rate,
|
'throttle_rate' => output.__send__(:throttle).rate,
|
||||||
'started?' => started?,
|
'started?' => started?,
|
||||||
'stopped?' => stopped?,
|
'stopped?' => stopped?,
|
||||||
@ -164,11 +176,11 @@ class Base
|
|||||||
attr_accessor :output,
|
attr_accessor :output,
|
||||||
:timer,
|
:timer,
|
||||||
:progressable,
|
:progressable,
|
||||||
:title_comp,
|
:title_component,
|
||||||
:bar,
|
:bar_component,
|
||||||
:percentage,
|
:percentage_component,
|
||||||
:rate,
|
:rate_component,
|
||||||
:time,
|
:time_component,
|
||||||
:autostart,
|
:autostart,
|
||||||
:autofinish,
|
:autofinish,
|
||||||
:finished
|
:finished
|
||||||
@ -50,7 +50,6 @@ class Length
|
|||||||
end
|
end
|
||||||
# rubocop:enable Style/RescueStandardError
|
# rubocop:enable Style/RescueStandardError
|
||||||
|
|
||||||
# rubocop:disable Lint/DuplicateMethods
|
|
||||||
begin
|
begin
|
||||||
require 'io/console'
|
require 'io/console'
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ class Length
|
|||||||
dynamic_width_via_system_calls
|
dynamic_width_via_system_calls
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Lint/DuplicateMethods
|
|
||||||
|
|
||||||
def dynamic_width_via_output_stream_object
|
def dynamic_width_via_output_stream_object
|
||||||
_rows, columns = output.winsize
|
_rows, columns = output.winsize
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
class ProgressBar
|
||||||
|
module Calculators
|
||||||
|
class SmoothedAverage
|
||||||
|
def self.calculate(current_average, new_value_to_average, rate)
|
||||||
|
(new_value_to_average * (1.0 - rate)) + (current_average * rate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -32,22 +32,6 @@ class Bar
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def integrated_percentage_complete_string
|
|
||||||
return standard_complete_string if completed_length < 5
|
|
||||||
|
|
||||||
" #{progress.percentage_completed} ".to_s.center(completed_length, progress_mark)
|
|
||||||
end
|
|
||||||
|
|
||||||
def standard_complete_string
|
|
||||||
progress_mark * completed_length
|
|
||||||
end
|
|
||||||
|
|
||||||
def incomplete_string
|
|
||||||
remainder_mark * (length - completed_length)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bar(length)
|
def bar(length)
|
||||||
self.length = length
|
self.length = length
|
||||||
|
|
||||||
@ -66,12 +50,6 @@ class Bar
|
|||||||
to_s(:format => :integrated_percentage)
|
to_s(:format => :integrated_percentage)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unknown_string
|
|
||||||
unknown_frame_string = unknown_progress_frame * ((length / upa_steps.size) + 2)
|
|
||||||
|
|
||||||
unknown_frame_string[0, length]
|
|
||||||
end
|
|
||||||
|
|
||||||
def incomplete_space(length)
|
def incomplete_space(length)
|
||||||
self.length = length
|
self.length = length
|
||||||
|
|
||||||
@ -88,6 +66,28 @@ class Bar
|
|||||||
integrated_percentage_complete_string
|
integrated_percentage_complete_string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def integrated_percentage_complete_string
|
||||||
|
return standard_complete_string if completed_length < 5
|
||||||
|
|
||||||
|
" #{progress.percentage_completed} ".to_s.center(completed_length, progress_mark)
|
||||||
|
end
|
||||||
|
|
||||||
|
def standard_complete_string
|
||||||
|
progress_mark * completed_length
|
||||||
|
end
|
||||||
|
|
||||||
|
def incomplete_string
|
||||||
|
remainder_mark * (length - completed_length)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unknown_string
|
||||||
|
unknown_frame_string = unknown_progress_frame * ((length / upa_steps.size) + 2)
|
||||||
|
|
||||||
|
unknown_frame_string[0, length]
|
||||||
|
end
|
||||||
|
|
||||||
def completed_length
|
def completed_length
|
||||||
(length * progress.percentage_completed / 100).floor
|
(length * progress.percentage_completed / 100).floor
|
||||||
end
|
end
|
||||||
@ -7,10 +7,8 @@ class Percentage
|
|||||||
self.progress = options[:progress]
|
self.progress = options[:progress]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def percentage
|
def percentage
|
||||||
progress.percentage_completed
|
progress.percentage_completed.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def justified_percentage
|
def justified_percentage
|
||||||
@ -2,23 +2,17 @@ class ProgressBar
|
|||||||
module Components
|
module Components
|
||||||
class Rate
|
class Rate
|
||||||
attr_accessor :rate_scale,
|
attr_accessor :rate_scale,
|
||||||
:started_at,
|
|
||||||
:stopped_at,
|
|
||||||
:timer,
|
:timer,
|
||||||
:progress
|
:progress
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
self.rate_scale = options[:rate_scale] || lambda { |x| x }
|
self.rate_scale = options[:rate_scale] || lambda { |x| x }
|
||||||
self.started_at = nil
|
|
||||||
self.stopped_at = nil
|
|
||||||
self.timer = options[:timer]
|
self.timer = options[:timer]
|
||||||
self.progress = options[:progress]
|
self.progress = options[:progress]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def rate_of_change(format_string = '%i')
|
def rate_of_change(format_string = '%i')
|
||||||
return 0 unless elapsed_seconds > 0
|
return '0' if elapsed_seconds <= 0
|
||||||
|
|
||||||
format_string % scaled_rate
|
format_string % scaled_rate
|
||||||
end
|
end
|
||||||
@ -27,6 +21,8 @@ class Rate
|
|||||||
rate_of_change('%.2f')
|
rate_of_change('%.2f')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def scaled_rate
|
def scaled_rate
|
||||||
rate_scale.call(base_rate)
|
rate_scale.call(base_rate)
|
||||||
end
|
end
|
||||||
@ -12,60 +12,56 @@ class Time
|
|||||||
NO_TIME_ELAPSED_TEXT = '--:--:--'.freeze
|
NO_TIME_ELAPSED_TEXT = '--:--:--'.freeze
|
||||||
ESTIMATED_LABEL = ' ETA'.freeze
|
ESTIMATED_LABEL = ' ETA'.freeze
|
||||||
ELAPSED_LABEL = 'Time'.freeze
|
ELAPSED_LABEL = 'Time'.freeze
|
||||||
|
WALL_CLOCK_FORMAT = '%H:%M:%S'.freeze
|
||||||
OOB_TEXT_TO_FORMAT = {
|
OOB_TEXT_TO_FORMAT = {
|
||||||
:unknown => OOB_UNKNOWN_TIME_TEXT,
|
:unknown => OOB_UNKNOWN_TIME_TEXT,
|
||||||
:friendly => OOB_FRIENDLY_TIME_TEXT
|
:friendly => OOB_FRIENDLY_TIME_TEXT
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
self.out_of_bounds_time_format = options[:out_of_bounds_time_format]
|
|
||||||
self.timer = options[:timer]
|
self.timer = options[:timer]
|
||||||
self.progress = options[:progress]
|
self.progress = options[:progress]
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimated_with_label
|
def estimated_with_label(out_of_bounds_time_format = nil)
|
||||||
"#{ESTIMATED_LABEL}: #{estimated}"
|
"#{ESTIMATED_LABEL}: #{estimated(out_of_bounds_time_format)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def elapsed_with_label
|
def elapsed_with_label
|
||||||
"#{ELAPSED_LABEL}: #{elapsed}"
|
"#{ELAPSED_LABEL}: #{elapsed}"
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def estimated_with_no_oob
|
def estimated_with_no_oob
|
||||||
self.out_of_bounds_time_format = nil
|
estimated_with_elapsed_fallback(nil)
|
||||||
|
|
||||||
estimated_with_elapsed_fallback
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimated_with_unknown_oob
|
def estimated_with_unknown_oob
|
||||||
self.out_of_bounds_time_format = :unknown
|
estimated_with_elapsed_fallback(:unknown)
|
||||||
|
|
||||||
estimated_with_elapsed_fallback
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimated_with_friendly_oob
|
def estimated_with_friendly_oob
|
||||||
self.out_of_bounds_time_format = :friendly
|
estimated_with_elapsed_fallback(:friendly)
|
||||||
|
|
||||||
estimated_with_elapsed_fallback
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :out_of_bounds_time_format
|
def estimated_wall_clock
|
||||||
|
return timer.stopped_at.strftime(WALL_CLOCK_FORMAT) if progress.finished?
|
||||||
|
return NO_TIME_ELAPSED_TEXT unless timer.started?
|
||||||
|
|
||||||
|
memo_estimated_seconds_remaining = estimated_seconds_remaining
|
||||||
|
return NO_TIME_ELAPSED_TEXT unless memo_estimated_seconds_remaining
|
||||||
|
|
||||||
|
(timer.now + memo_estimated_seconds_remaining).
|
||||||
|
strftime(WALL_CLOCK_FORMAT)
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
attr_accessor :timer,
|
attr_accessor :timer,
|
||||||
:progress
|
:progress
|
||||||
|
|
||||||
def out_of_bounds_time_format=(format)
|
|
||||||
unless OOB_TIME_FORMATS.include? format
|
|
||||||
fail StandardError, "Invalid Out Of Bounds time format. Valid formats are #{OOB_TIME_FORMATS.inspect}"
|
|
||||||
end
|
|
||||||
|
|
||||||
@out_of_bounds_time_format = format
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def estimated
|
def estimated(out_of_bounds_time_format)
|
||||||
memo_estimated_seconds_remaining = estimated_seconds_remaining
|
memo_estimated_seconds_remaining = estimated_seconds_remaining
|
||||||
|
|
||||||
return OOB_UNKNOWN_TIME_TEXT unless memo_estimated_seconds_remaining
|
return OOB_UNKNOWN_TIME_TEXT unless memo_estimated_seconds_remaining
|
||||||
@ -73,7 +69,7 @@ class Time
|
|||||||
hours, minutes, seconds = timer.divide_seconds(memo_estimated_seconds_remaining)
|
hours, minutes, seconds = timer.divide_seconds(memo_estimated_seconds_remaining)
|
||||||
|
|
||||||
if hours > OOB_LIMIT_IN_HOURS && out_of_bounds_time_format
|
if hours > OOB_LIMIT_IN_HOURS && out_of_bounds_time_format
|
||||||
OOB_TEXT_TO_FORMAT[out_of_bounds_time_format]
|
OOB_TEXT_TO_FORMAT.fetch(out_of_bounds_time_format)
|
||||||
else
|
else
|
||||||
TIME_FORMAT % [hours, minutes, seconds]
|
TIME_FORMAT % [hours, minutes, seconds]
|
||||||
end
|
end
|
||||||
@ -87,14 +83,16 @@ class Time
|
|||||||
TIME_FORMAT % [hours, minutes, seconds]
|
TIME_FORMAT % [hours, minutes, seconds]
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimated_with_elapsed_fallback
|
def estimated_with_elapsed_fallback(out_of_bounds_time_format)
|
||||||
progress.finished? ? elapsed_with_label : estimated_with_label
|
return elapsed_with_label if progress.finished?
|
||||||
|
|
||||||
|
estimated_with_label(out_of_bounds_time_format)
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimated_seconds_remaining
|
def estimated_seconds_remaining
|
||||||
return if progress.unknown? || progress.none? || timer.stopped? || timer.reset?
|
return if progress.unknown? || progress.none? || timer.stopped? || timer.reset?
|
||||||
|
|
||||||
(timer.elapsed_seconds * (progress.total / progress.running_average - 1)).round
|
(timer.elapsed_seconds * ((progress.total / progress.running_average) - 1)).round
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -13,7 +13,7 @@ class Formatter
|
|||||||
bar_length = max_length -
|
bar_length = max_length -
|
||||||
processed_string.displayable_length +
|
processed_string.displayable_length +
|
||||||
format_string.bar_molecule_placeholder_length
|
format_string.bar_molecule_placeholder_length
|
||||||
bar_length = (bar_length < 0) ? 0 : bar_length
|
bar_length = 0 if bar_length < 0
|
||||||
|
|
||||||
format_string.bar_molecules.each do |molecule|
|
format_string.bar_molecules.each do |molecule|
|
||||||
processed_string.gsub!(molecule.full_key,
|
processed_string.gsub!(molecule.full_key,
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
class ProgressBar
|
||||||
|
module Format
|
||||||
|
class Molecule
|
||||||
|
MOLECULES = {
|
||||||
|
:t => [:title_component, :title],
|
||||||
|
:T => [:title_component, :title],
|
||||||
|
:c => [:progressable, :progress],
|
||||||
|
:C => [:progressable, :total],
|
||||||
|
:u => [:progressable, :total_with_unknown_indicator],
|
||||||
|
:p => [:percentage_component, :percentage],
|
||||||
|
:P => [:percentage_component, :percentage_with_precision],
|
||||||
|
:j => [:percentage_component, :justified_percentage],
|
||||||
|
:J => [:percentage_component, :justified_percentage_with_precision],
|
||||||
|
:a => [:time_component, :elapsed_with_label],
|
||||||
|
:e => [:time_component, :estimated_with_unknown_oob],
|
||||||
|
:E => [:time_component, :estimated_with_friendly_oob],
|
||||||
|
:f => [:time_component, :estimated_with_no_oob],
|
||||||
|
:l => [:time_component, :estimated_wall_clock],
|
||||||
|
:B => [:bar_component, :complete_bar],
|
||||||
|
:b => [:bar_component, :bar],
|
||||||
|
:W => [:bar_component, :complete_bar_with_percentage],
|
||||||
|
:w => [:bar_component, :bar_with_percentage],
|
||||||
|
:i => [:bar_component, :incomplete_space],
|
||||||
|
:r => [:rate_component, :rate_of_change],
|
||||||
|
:R => [:rate_component, :rate_of_change_with_precision]
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
BAR_MOLECULES = %w{W w B b i}.freeze
|
||||||
|
|
||||||
|
attr_accessor :key,
|
||||||
|
:method_name
|
||||||
|
|
||||||
|
def initialize(letter)
|
||||||
|
self.key = letter
|
||||||
|
self.method_name = MOLECULES.fetch(key.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
def bar_molecule?
|
||||||
|
BAR_MOLECULES.include? key
|
||||||
|
end
|
||||||
|
|
||||||
|
def non_bar_molecule?
|
||||||
|
!bar_molecule?
|
||||||
|
end
|
||||||
|
|
||||||
|
def full_key
|
||||||
|
"%#{key}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def lookup_value(environment, length = 0)
|
||||||
|
component = environment.__send__(method_name[0])
|
||||||
|
|
||||||
|
if bar_molecule?
|
||||||
|
component.__send__(method_name[1], length).to_s
|
||||||
|
else
|
||||||
|
component.__send__(method_name[1]).to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
require 'ruby-progressbar/format/molecule'
|
||||||
|
|
||||||
class ProgressBar
|
class ProgressBar
|
||||||
module Format
|
module Format
|
||||||
class String < ::String
|
class String < ::String
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
require 'ruby-progressbar/calculators/length'
|
||||||
|
require 'ruby-progressbar/throttle'
|
||||||
|
|
||||||
class ProgressBar
|
class ProgressBar
|
||||||
class Output
|
class Output
|
||||||
DEFAULT_OUTPUT_STREAM = $stdout
|
DEFAULT_OUTPUT_STREAM = $stdout
|
||||||
@ -1,21 +1,33 @@
|
|||||||
require 'ruby-progressbar/errors/invalid_progress_error'
|
require 'ruby-progressbar/errors/invalid_progress_error'
|
||||||
|
require 'ruby-progressbar/calculators/smoothed_average'
|
||||||
|
|
||||||
class ProgressBar
|
class ProgressBar
|
||||||
class Progress
|
class Progress
|
||||||
DEFAULT_TOTAL = 100
|
DEFAULT_TOTAL = 100
|
||||||
DEFAULT_BEGINNING_POSITION = 0
|
DEFAULT_BEGINNING_POSITION = 0
|
||||||
DEFAULT_SMOOTHING = 0.1
|
DEFAULT_RUNNING_AVERAGE_RATE = 0.1
|
||||||
|
DEFAULT_RUNNING_AVERAGE_CALCULATOR = ProgressBar::Calculators::SmoothedAverage
|
||||||
|
|
||||||
|
RUNNING_AVERAGE_CALCULATOR_MAP = {
|
||||||
|
'smoothing' => ProgressBar::Calculators::SmoothedAverage
|
||||||
|
}.freeze
|
||||||
|
|
||||||
attr_reader :total,
|
attr_reader :total,
|
||||||
:progress
|
:progress
|
||||||
|
|
||||||
attr_accessor :starting_position,
|
attr_accessor :starting_position,
|
||||||
:running_average,
|
:running_average,
|
||||||
:smoothing
|
:running_average_calculator,
|
||||||
|
:running_average_rate
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
self.total = options.fetch(:total, DEFAULT_TOTAL)
|
self.total = options.fetch(:total, DEFAULT_TOTAL)
|
||||||
self.smoothing = options[:smoothing] || DEFAULT_SMOOTHING
|
self.running_average_rate = options[:smoothing] ||
|
||||||
|
options[:running_average_rate] ||
|
||||||
|
DEFAULT_RUNNING_AVERAGE_RATE
|
||||||
|
self.running_average_calculator = RUNNING_AVERAGE_CALCULATOR_MAP.
|
||||||
|
fetch(options[:running_average_calculator],
|
||||||
|
DEFAULT_RUNNING_AVERAGE_CALCULATOR)
|
||||||
|
|
||||||
start :at => DEFAULT_BEGINNING_POSITION
|
start :at => DEFAULT_BEGINNING_POSITION
|
||||||
end
|
end
|
||||||
@ -66,9 +78,9 @@ class Progress
|
|||||||
|
|
||||||
@progress = new_progress
|
@progress = new_progress
|
||||||
|
|
||||||
self.running_average = Calculators::RunningAverage.calculate(running_average,
|
self.running_average = running_average_calculator.calculate(running_average,
|
||||||
absolute,
|
absolute,
|
||||||
smoothing)
|
running_average_rate)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total=(new_total)
|
def total=(new_total)
|
||||||
@ -17,12 +17,10 @@ class Time
|
|||||||
end
|
end
|
||||||
|
|
||||||
def unmocked_time_method
|
def unmocked_time_method
|
||||||
@unmocked_time_method ||= begin
|
@unmocked_time_method ||= TIME_MOCKING_LIBRARY_METHODS.find do |method|
|
||||||
TIME_MOCKING_LIBRARY_METHODS.find do |method|
|
|
||||||
time.respond_to? method
|
time.respond_to? method
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
@ -28,6 +28,10 @@ class Timer
|
|||||||
start
|
start
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def now
|
||||||
|
time.now
|
||||||
|
end
|
||||||
|
|
||||||
def started?
|
def started?
|
||||||
started_at
|
started_at
|
||||||
end
|
end
|
||||||
@ -51,6 +55,8 @@ class Timer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def elapsed_seconds
|
def elapsed_seconds
|
||||||
|
return 0 unless started?
|
||||||
|
|
||||||
((stopped_at || time.now) - started_at)
|
((stopped_at || time.now) - started_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class ProgressBar
|
||||||
|
VERSION = '1.12.0'.freeze
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user