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/projector'require'ruby-progressbar/timer'classProgressBarclassBaseextendForwardable# rubocop:disable Layout/HeredocIndentationSMOOTHING_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
HEREDOCRUNNING_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/HeredocIndentationdef_delegators:output,:clear,:log,:refreshdef_delegators:progressable,:progress,:totaldefinitialize(options={})# rubocop:disable Metrics/AbcSizeoptions[:projector]||={}self.autostart=options.fetch(:autostart,true)self.autofinish=options.fetch(:autofinish,true)self.finished=falseself.timer=Timer.new(options)projector_opts=ifoptions[:projector].any?options[:projector]elsifoptions[:smoothing]warnSMOOTHING_DEPRECATION_WARNING{:strength=>options[:smoothing]}elsifoptions[:running_average_rate]warnRUNNING_AVERAGE_RATE_DEPRECATION_WARNING{:strength=>options[:smoothing]}else{}endself.projector=Projector.from_type(options[:projector][:type]).new(projector_opts)self.progressable=Progress.new(options)options=options.merge(:progress=>progressable,:projector=>projector,:timer=>timer)self.title_component=Components::Title.new(options)self.bar_component=Components::Bar.new(options)self.percentage_component=Components::Percentage.new(options)self.rate_component=Components::Rate.new(options)self.time_component=Components::Time.new(options)self.output=Output.detect(options.merge(:bar=>self))@format=Format::String.new(output.resolve_format(options[:format]))start:at=>options[:starting_at]ifautostartenddefstart(options={})timer.startupdate_progress(:start,options)enddeffinishreturniffinished?output.with_refreshdoself.finished=trueprogressable.finishtimer.stopendenddefpauseoutput.with_refresh{timer.pause}unlesspaused?enddefstopoutput.with_refresh{timer.stop}unlessstopped?enddefresumeoutput.with_refresh{timer.resume}ifstopped?enddefresetoutput.with_refreshdoself.finished=falseprogressable.resetprojector.resettimer.resetendenddefstopped?timer.stopped?||finished?endaliaspaused?stopped?deffinished?finished||(autofinish&&progressable.finished?)enddefstarted?timer.started?enddefdecrementupdate_progress(:decrement)enddefincrementupdate_progress(:increment)enddefprogress=(new_progress)update_progress(:progress=,new_progress)enddeftotal=(new_total)update_progress(:total=,new_total)enddefprogress_mark=(mark)output.refresh_with_format_change{bar_component.progress_mark=mark}enddefremainder_mark=(mark)output.refresh_with_format_change{bar_component.remainder_mark=mark}enddeftitletitle_component.titleenddeftitle=(title)output.refresh_with_format_change{title_component.title=title}enddefto_s(new_format=nil)self.format=new_formatifnew_formatFormat::Formatter.process(@format,output.length,self)end# rubocop:disable Metrics/AbcSize, Layout/LineLengthdefto_h{'output_stream'=>output.__send__(:stream),'length'=>output.length,'title'=>title_component.title,'progress_mark'=>bar_component.progress_mark,'remainder_mark'=>bar_component.remainder_mark,'progress'=>progressable.progress,'total'=>progressable.total,'percentage'=>progressable.percentage_completed_with_precision.to_f,'elapsed_time_in_seconds'=>time_component.__send__(:timer).elapsed_seconds,'estimated_time_remaining_in_seconds'=>time_component.__send__(:estimated_seconds_remaining),'base_rate_of_change'=>rate_component.__send__(:base_rate),'scaled_rate_of_change'=>rate_component.__send__(:scaled_rate),'unknown_progress_animation_steps'=>bar_component.upa_steps,'throttle_rate'=>output.__send__(:throttle).rate,'started?'=>started?,'stopped?'=>stopped?,'finished?'=>finished?}end# rubocop:enable Metrics/AbcSize, Layout/LineLengthdefinspect"#<ProgressBar:#{progress}/#{total||'unknown'}>"enddefformat=(other)output.refresh_with_format_changedo@format=Format::String.new(other||output.default_format)endendaliasformatformat=protectedattr_accessor:output,:projector,:timer,:progressable,:title_component,:bar_component,:percentage_component,:rate_component,:time_component,:autostart,:autofinish,:finisheddefupdate_progress(*args)output.with_refreshdoprogressable.__send__(*args)projector.__send__(*args)timer.stopiffinished?endendendend