Class: Mnogootex::Job::Logger
- Defined in:
- lib/mnogootex/job/logger.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(spinner:, processor:, runners:, porters:) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(spinner:, processor:, runners:, porters:) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mnogootex/job/logger.rb', line 8 def initialize(spinner:, processor:, runners:, porters:) super do while runners.any?(&:alive?) self.class.print_status(runners: runners, spinner: spinner) sleep 0.02 # 50 fps end self.class.print_status(runners: runners, spinner: spinner) puts self.class.print_outcome(runners: runners, porters: porters, processor: processor) end end |
Class Method Details
.print_outcome(runners:, porters:, processor:) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/mnogootex/job/logger.rb', line 30 def print_outcome(runners:, porters:, processor:) puts 'Outcome:' porters.zip(runners).each do |porter, runner| outcome_icon = runner.successful? ? '✔'.green : '✘'.red puts " #{outcome_icon} #{porter.hid}" puts processor.call(runner.log_lines) unless runner.successful? end end |
.print_status(runners:, spinner:) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/mnogootex/job/logger.rb', line 21 def print_status(runners:, spinner:) spinners_frames = [] runners.each do |runner| spinner_frame = spinner[runner.count_lines % spinner.size] spinners_frames << colour_by_state(spinner_frame, runner) end print "Runners: #{spinners_frames.join}\r" end |