brew vendor-gems: commit updates.

This commit is contained in:
BrewTestBot 2023-03-06 21:47:33 +00:00
parent d475072d19
commit a120f4dd80
No known key found for this signature in database
GPG Key ID: 82D7D104050B0F0F
30 changed files with 174 additions and 74 deletions

View File

@ -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.12.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-progressbar-1.13.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.47.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-1.47.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")

View File

@ -1,9 +0,0 @@
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

View File

@ -1 +0,0 @@
require 'ruby-progressbar/refinements/enumerator'

View File

@ -1,23 +0,0 @@
class ProgressBar
module Refinements
module Enumerator
refine ::Enumerator do
def with_progressbar(options = {}, &block)
chain = ::Enumerator.new do |yielder|
progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))
each do |*args|
yielder.yield(*args).tap do
progress_bar.increment
end
end
end
return chain unless block
chain.each(&block)
end
end
end
end
end

View File

@ -1,3 +0,0 @@
class ProgressBar
VERSION = '1.12.0'.freeze
end

View File

@ -10,12 +10,29 @@ require 'ruby-progressbar/format/string'
require 'ruby-progressbar/outputs/non_tty' require 'ruby-progressbar/outputs/non_tty'
require 'ruby-progressbar/outputs/tty' require 'ruby-progressbar/outputs/tty'
require 'ruby-progressbar/progress' require 'ruby-progressbar/progress'
require 'ruby-progressbar/projector'
require 'ruby-progressbar/timer' require 'ruby-progressbar/timer'
class ProgressBar class ProgressBar
class Base class Base
extend Forwardable extend Forwardable
# rubocop:disable Layout/HeredocIndentation
SMOOTHING_DEPRECATION_WARNING = <<-HEREDOC.tr("\n", ' ')
WARNING: Passing the 'smoothing' option is deprecated and will be removed
in version 2.0. Please pass { projector: { type: 'smoothing', strength: 0.x }}.
For more information on why this change is happening, visit
https://github.com/jfelchner/ruby-progressbar/wiki/Upgrading
HEREDOC
RUNNING_AVERAGE_RATE_DEPRECATION_WARNING = <<-HEREDOC.tr("\n", ' ')
WARNING: Passing the 'running_average_rate' option is deprecated and will be removed
in version 2.0. Please pass { projector: { type: 'smoothing', strength: 0.x }}.
For more information on why this change is happening, visit
https://github.com/jfelchner/ruby-progressbar/wiki/Upgrading
HEREDOC
# rubocop:enable Layout/HeredocIndentation
def_delegators :output, def_delegators :output,
:clear, :clear,
:log, :log,
@ -26,14 +43,33 @@ class Base
:total :total
def initialize(options = {}) # rubocop:disable Metrics/AbcSize def initialize(options = {}) # rubocop:disable Metrics/AbcSize
options[:projector] ||= {}
self.autostart = options.fetch(:autostart, true) self.autostart = options.fetch(:autostart, true)
self.autofinish = options.fetch(:autofinish, true) self.autofinish = options.fetch(:autofinish, true)
self.finished = false self.finished = false
self.timer = Timer.new(options) self.timer = Timer.new(options)
projector_opts = if options[:projector].any?
options[:projector]
elsif options[:smoothing]
warn SMOOTHING_DEPRECATION_WARNING
{ :strength => options[:smoothing] }
elsif options[:running_average_rate]
warn RUNNING_AVERAGE_RATE_DEPRECATION_WARNING
{ :strength => options[:smoothing] }
else
{}
end
self.projector = Projector.
from_type(options[:projector][:type]).
new(projector_opts)
self.progressable = Progress.new(options) self.progressable = Progress.new(options)
options = options.merge(:progress => progressable, options = options.merge(:progress => progressable,
:projector => projector,
:timer => timer) :timer => timer)
self.title_component = Components::Title.new(options) self.title_component = Components::Title.new(options)
@ -79,6 +115,7 @@ class Base
output.with_refresh do output.with_refresh do
self.finished = false self.finished = false
progressable.reset progressable.reset
projector.reset
timer.reset timer.reset
end end
end end
@ -174,6 +211,7 @@ class Base
protected protected
attr_accessor :output, attr_accessor :output,
:projector,
:timer, :timer,
:progressable, :progressable,
:title_component, :title_component,
@ -188,6 +226,7 @@ class Base
def update_progress(*args) def update_progress(*args)
output.with_refresh do output.with_refresh do
progressable.__send__(*args) progressable.__send__(*args)
projector.__send__(*args)
timer.stop if finished? timer.stop if finished?
end end
end end

View File

@ -21,6 +21,7 @@ class Time
def initialize(options = {}) def initialize(options = {})
self.timer = options[:timer] self.timer = options[:timer]
self.progress = options[:progress] self.progress = options[:progress]
self.projector = options[:projector]
end end
def estimated_with_label(out_of_bounds_time_format = nil) def estimated_with_label(out_of_bounds_time_format = nil)
@ -57,7 +58,8 @@ class Time
protected protected
attr_accessor :timer, attr_accessor :timer,
:progress :progress,
:projector
private private
@ -90,9 +92,9 @@ class Time
end end
def estimated_seconds_remaining def estimated_seconds_remaining
return if progress.unknown? || progress.none? || timer.stopped? || timer.reset? return if progress.unknown? || projector.none? || progress.none? || timer.stopped? || timer.reset?
(timer.elapsed_seconds * ((progress.total / progress.running_average) - 1)).round (timer.elapsed_seconds * ((progress.total / projector.projection) - 1)).round
end end
end end
end end

View File

@ -1,39 +1,21 @@
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_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_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.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
def start(options = {}) def start(options = {})
self.running_average = 0
self.progress = \ self.progress = \
self.starting_position = options[:at] || progress self.starting_position = options[:at] || progress
end end
@ -67,7 +49,7 @@ class Progress
end end
def reset def reset
start :at => starting_position start(:at => starting_position)
end end
def progress=(new_progress) def progress=(new_progress)
@ -77,10 +59,6 @@ class Progress
end end
@progress = new_progress @progress = new_progress
self.running_average = running_average_calculator.calculate(running_average,
absolute,
running_average_rate)
end end
def total=(new_total) def total=(new_total)
@ -105,7 +83,7 @@ class Progress
end end
def none? def none?
running_average.zero? || progress.zero? progress.zero?
end end
def unknown? def unknown?

View File

@ -0,0 +1,14 @@
require 'ruby-progressbar/projectors/smoothed_average'
class ProgressBar
class Projector
DEFAULT_PROJECTOR = ProgressBar::Projectors::SmoothedAverage
NAME_TO_PROJECTOR_MAP = {
'smoothed' => ProgressBar::Projectors::SmoothedAverage
}.freeze
def self.from_type(name)
NAME_TO_PROJECTOR_MAP.fetch(name, DEFAULT_PROJECTOR)
end
end
end

View File

@ -0,0 +1,71 @@
class ProgressBar
module Projectors
class SmoothedAverage
DEFAULT_STRENGTH = 0.1
DEFAULT_BEGINNING_POSITION = 0
attr_accessor :samples,
:strength
attr_reader :projection
def initialize(options = {})
self.samples = []
self.projection = 0.0
self.strength = options[:strength] || DEFAULT_STRENGTH
start(:at => DEFAULT_BEGINNING_POSITION)
end
def start(options = {})
self.projection = 0.0
self.progress = samples[0] = (options[:at] || progress)
end
def decrement
self.progress -= 1
end
def increment
self.progress += 1
end
def progress
samples[1]
end
def total=(_new_total); end
def reset
start(:at => samples[0])
end
def progress=(new_progress)
samples[1] = new_progress
self.projection = \
self.class.calculate(
@projection,
absolute,
strength
)
end
def none?
projection.zero?
end
def self.calculate(current_projection, new_value, rate)
(new_value * (1.0 - rate)) + (current_projection * rate)
end
protected
attr_writer :projection
private
def absolute
samples[1] - samples[0]
end
end
end
end

View File

@ -0,0 +1 @@
require 'ruby-progressbar/refinements/progress_enumerator'

View File

@ -0,0 +1,28 @@
class ProgressBar
module Refinements
module Enumerator
ARITY_ERROR_MESSAGE = 'Only two arguments allowed to be passed to ' \
'with_progressbar (item, progress_bar)'.freeze
refine ::Enumerator do
def with_progressbar(options = {}, &block)
progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size))
each do |item|
progress_bar.increment
next unless block
yielded_args = []
yielded_args << item if block.arity > 0
yielded_args << progress_bar if block.arity > 1
fail ::ArgumentError, ARITY_ERROR_MESSAGE if block.arity > 2
yield(*yielded_args)
end
end
end
end
end
end

View File

@ -0,0 +1,3 @@
class ProgressBar
VERSION = '1.13.0'.freeze
end