class Fuubar
Constants
- DEFAULT_PROGRESS_BAR_OPTIONS
Attributes
example_tick_lock[RW]
failed_count[RW]
passed_count[RW]
pending_count[RW]
progress[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/fuubar.rb, line 31 def initialize(*args) super self.example_tick_lock = ::Mutex.new self.progress = ::ProgressBar.create( DEFAULT_PROGRESS_BAR_OPTIONS. merge(:throttle_rate => continuous_integration? ? 1.0 : nil). merge(:total => 0, :output => output, :autostart => false) ) end
Public Instance Methods
close(_notification)
click to toggle source
# File lib/fuubar.rb, line 62 def close(_notification) example_tick_thread.kill end
dump_failures(_notification)
click to toggle source
# File lib/fuubar.rb, line 115 def dump_failures(_notification) # # We output each failure as it happens so we don't need to output them en # masse at the end of the run. # end
dump_pending(notification)
click to toggle source
Calls superclass method
# File lib/fuubar.rb, line 122 def dump_pending(notification) return unless configuration.fuubar_output_pending_results super end
example_failed(notification)
click to toggle source
# File lib/fuubar.rb, line 78 def example_failed(notification) self.failed_count += 1 progress.clear output.puts notification.fully_formatted(failed_count) output.puts increment end
example_passed(_notification)
click to toggle source
# File lib/fuubar.rb, line 66 def example_passed(_notification) self.passed_count += 1 increment end
example_pending(_notification)
click to toggle source
# File lib/fuubar.rb, line 72 def example_pending(_notification) self.pending_count += 1 increment end
example_tick(_notification)
click to toggle source
# File lib/fuubar.rb, line 89 def example_tick(_notification) example_tick_lock.synchronize do refresh end end
example_tick_thread()
click to toggle source
# File lib/fuubar.rb, line 95 def example_tick_thread ::Thread.new do loop do sleep(1) if configuration.fuubar_auto_refresh example_tick(notification) end end end end
message(notification)
click to toggle source
Calls superclass method
# File lib/fuubar.rb, line 107 def message(notification) if progress.respond_to? :log progress.log(notification.message) else super end end
output()
click to toggle source
Calls superclass method
# File lib/fuubar.rb, line 128 def output @fuubar_output ||= ::Fuubar::Output.new(super, configuration.tty?) # rubocop:disable Naming/MemoizedInstanceVariableName end
start(notification)
click to toggle source
Calls superclass method
# File lib/fuubar.rb, line 44 def start(notification) progress_bar_options = DEFAULT_PROGRESS_BAR_OPTIONS. merge(:throttle_rate => continuous_integration? ? 1.0 : nil). merge(configuration.fuubar_progress_bar_options). merge(:total => notification.count, :output => output, :autostart => false) self.progress = ::ProgressBar.create(progress_bar_options) self.passed_count = 0 self.pending_count = 0 self.failed_count = 0 super with_current_color { progress.start } end
Private Instance Methods
color_code_for(*args)
click to toggle source
# File lib/fuubar.rb, line 162 def color_code_for(*args) ::RSpec::Core::Formatters::ConsoleCodes.console_code_for(*args) end
color_enabled?()
click to toggle source
# File lib/fuubar.rb, line 148 def color_enabled? configuration.color_enabled? && !continuous_integration? end
configuration()
click to toggle source
# File lib/fuubar.rb, line 166 def configuration ::RSpec.configuration end
continuous_integration?()
click to toggle source
# File lib/fuubar.rb, line 170 def continuous_integration? @continuous_integration ||= \ ![nil, '', 'false'].include?(ENV['CONTINUOUS_INTEGRATION']) end
current_color()
click to toggle source
# File lib/fuubar.rb, line 152 def current_color if failed_count > 0 configuration.failure_color elsif pending_count > 0 configuration.pending_color else configuration.success_color end end
increment()
click to toggle source
# File lib/fuubar.rb, line 134 def increment with_current_color { progress.increment } end
refresh()
click to toggle source
# File lib/fuubar.rb, line 138 def refresh with_current_color { progress.refresh } end
with_current_color() { || ... }
click to toggle source
# File lib/fuubar.rb, line 142 def with_current_color output.print "\e[#{color_code_for(current_color)}m" if color_enabled? yield output.print "\e[0m" if color_enabled? end