Class: MutationTester::ProgressDisplay
- Inherits:
-
Object
- Object
- MutationTester::ProgressDisplay
- Defined in:
- lib/mutation_tester/progress_display.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#current_mutation ⇒ Object
readonly
Returns the value of attribute current_mutation.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(total, config, output_stream: $stdout.clone) ⇒ ProgressDisplay
constructor
A new instance of ProgressDisplay.
- #update(mutation, index) ⇒ Object
Constructor Details
#initialize(total, config, output_stream: $stdout.clone) ⇒ ProgressDisplay
Returns a new instance of ProgressDisplay.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mutation_tester/progress_display.rb', line 5 def initialize(total, config, output_stream: $stdout.clone) @output_stream = output_stream @total = total @current = 0 @current_mutation = nil @config = config @start_time = Time.now @spinner_frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] @spinner_index = 0 @lock = Mutex.new @spinner_thread = nil @stop_spinner = false start_spinner if @config.show_progress end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
3 4 5 |
# File 'lib/mutation_tester/progress_display.rb', line 3 def current @current end |
#current_mutation ⇒ Object (readonly)
Returns the value of attribute current_mutation.
3 4 5 |
# File 'lib/mutation_tester/progress_display.rb', line 3 def current_mutation @current_mutation end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/mutation_tester/progress_display.rb', line 3 def total @total end |
Instance Method Details
#finish ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mutation_tester/progress_display.rb', line 28 def finish @lock.synchronize do @stop_spinner = true if @config.show_progress clear_line elapsed = Time.now - @start_time @output_stream.puts " #{Rainbow("Completed in #{format_duration(elapsed)}").green}" end end stop_spinner end |
#update(mutation, index) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mutation_tester/progress_display.rb', line 21 def update(mutation, index) @lock.synchronize do @current = index @current_mutation = mutation end end |