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.
-
#example_tick_thread ⇒ Object
Returns the value of attribute example_tick_thread.
-
#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
- #example_failed(notification) ⇒ Object
- #example_passed(_notification) ⇒ Object
- #example_pending(_notification) ⇒ Object
- #example_tick(_notification) ⇒ 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.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fuubar.rb', line 29 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.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def example_tick_lock @example_tick_lock end |
#example_tick_thread ⇒ Object
Returns the value of attribute example_tick_thread.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def example_tick_thread @example_tick_thread end |
#failed_count ⇒ Object
Returns the value of attribute failed_count.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def failed_count @failed_count end |
#passed_count ⇒ Object
Returns the value of attribute passed_count.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def passed_count @passed_count end |
#pending_count ⇒ Object
Returns the value of attribute pending_count.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def pending_count @pending_count end |
#progress ⇒ Object
Returns the value of attribute progress.
22 23 24 |
# File 'lib/fuubar.rb', line 22 def progress @progress end |
Instance Method Details
#close(_notification) ⇒ Object
70 71 72 |
# File 'lib/fuubar.rb', line 70 def close(_notification) example_tick_thread.kill end |
#dump_failures(_notification) ⇒ Object
111 112 113 114 115 116 |
# File 'lib/fuubar.rb', line 111 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 |
#example_failed(notification) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fuubar.rb', line 86 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
74 75 76 77 78 |
# File 'lib/fuubar.rb', line 74 def example_passed(_notification) self.passed_count += 1 increment end |
#example_pending(_notification) ⇒ Object
80 81 82 83 84 |
# File 'lib/fuubar.rb', line 80 def example_pending(_notification) self.pending_count += 1 increment end |
#example_tick(_notification) ⇒ Object
97 98 99 100 101 |
# File 'lib/fuubar.rb', line 97 def example_tick(_notification) example_tick_lock.synchronize do refresh end end |
#message(notification) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/fuubar.rb', line 103 def (notification) if progress.respond_to? :log progress.log(notification.) else super end end |
#output ⇒ Object
118 119 120 |
# File 'lib/fuubar.rb', line 118 def output @fuubar_output ||= Fuubar::Output.new(super, configuration.tty?) end |
#start(notification) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fuubar.rb', line 42 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 self.example_tick_thread = start_tick_thread(notification) if Object.const_defined?('Pry') Pry .config .hooks .add_hook(:when_started, :fuubar_kill_refresh) do |_target, _opt, _| example_tick_thread.kill end end super with_current_color { progress.start } end |