Class: Fuubar
- Inherits:
-
RSpec::Core::Formatters::BaseTextFormatter
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- Fuubar
- Defined in:
- lib/fuubar.rb,
lib/fuubar/output.rb
Defined Under Namespace
Classes: Output
Constant Summary collapse
- DEFAULT_PROGRESS_BAR_OPTIONS =
{ :format => ' %c/%C |%w>%i| %e ' }.freeze
Instance Attribute Summary collapse
-
#example_tick_lock ⇒ Object
Returns the value of attribute example_tick_lock.
-
#failed_count ⇒ Object
Returns the value of attribute failed_count.
-
#passed_count ⇒ Object
Returns the value of attribute passed_count.
-
#pending_count ⇒ Object
Returns the value of attribute pending_count.
-
#progress ⇒ Object
Returns the value of attribute progress.
Instance Method Summary collapse
- #close(_notification) ⇒ Object
- #dump_failures(_notification) ⇒ Object
- #dump_pending(notification) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_passed(_notification) ⇒ Object
- #example_pending(_notification) ⇒ Object
- #example_tick(_notification) ⇒ Object
- #example_tick_thread ⇒ Object
-
#initialize(*args) ⇒ Fuubar
constructor
A new instance of Fuubar.
- #message(notification) ⇒ Object
- #output ⇒ Object
- #start(notification) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Fuubar
Returns a new instance of Fuubar.
31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Attribute Details
#example_tick_lock ⇒ Object
Returns the value of attribute example_tick_lock.
25 26 27 |
# File 'lib/fuubar.rb', line 25 def example_tick_lock @example_tick_lock end |
#failed_count ⇒ Object
Returns the value of attribute failed_count.
25 26 27 |
# File 'lib/fuubar.rb', line 25 def failed_count @failed_count end |
#passed_count ⇒ Object
Returns the value of attribute passed_count.
25 26 27 |
# File 'lib/fuubar.rb', line 25 def passed_count @passed_count end |
#pending_count ⇒ Object
Returns the value of attribute pending_count.
25 26 27 |
# File 'lib/fuubar.rb', line 25 def pending_count @pending_count end |
#progress ⇒ Object
Returns the value of attribute progress.
25 26 27 |
# File 'lib/fuubar.rb', line 25 def progress @progress end |
Instance Method Details
#close(_notification) ⇒ Object
62 63 64 |
# File 'lib/fuubar.rb', line 62 def close(_notification) example_tick_thread.kill end |
#dump_failures(_notification) ⇒ Object
115 116 117 118 119 120 |
# 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) ⇒ Object
122 123 124 125 126 |
# File 'lib/fuubar.rb', line 122 def dump_pending(notification) return unless configuration. super end |
#example_failed(notification) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# 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) ⇒ Object
66 67 68 69 70 |
# File 'lib/fuubar.rb', line 66 def example_passed(_notification) self.passed_count += 1 increment end |
#example_pending(_notification) ⇒ Object
72 73 74 75 76 |
# File 'lib/fuubar.rb', line 72 def example_pending(_notification) self.pending_count += 1 increment end |
#example_tick(_notification) ⇒ Object
89 90 91 92 93 |
# File 'lib/fuubar.rb', line 89 def example_tick(_notification) example_tick_lock.synchronize do refresh end end |
#example_tick_thread ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fuubar.rb', line 95 def example_tick_thread ::Thread.new do loop do sleep(1) if configuration. example_tick(notification) end end end end |
#message(notification) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/fuubar.rb', line 107 def (notification) if progress.respond_to? :log progress.log(notification.) else super end end |
#output ⇒ Object
128 129 130 |
# File 'lib/fuubar.rb', line 128 def output @fuubar_output ||= ::Fuubar::Output.new(super, configuration.tty?) # rubocop:disable Naming/MemoizedInstanceVariableName end |
#start(notification) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fuubar.rb', line 44 def start(notification) = DEFAULT_PROGRESS_BAR_OPTIONS. merge(:throttle_rate => continuous_integration? ? 1.0 : nil). merge(configuration.). merge(:total => notification.count, :output => output, :autostart => false) self.progress = ::ProgressBar.create() self.passed_count = 0 self.pending_count = 0 self.failed_count = 0 super with_current_color { progress.start } end |