Class: Spec::Runner::Formatter::ItermColorProgressFormatter
- Inherits:
-
ProgressBarFormatter
- Object
- ProgressBarFormatter
- Spec::Runner::Formatter::ItermColorProgressFormatter
- Defined in:
- lib/iterm_color_progress_formatter.rb
Constant Summary collapse
- PASS_COLOR =
[0, 16385, 0]
- FAIL_COLOR =
[16385, 0, 0]
- PEND_COLOR =
[32768, 32768, 0]
- @@anything_failed_ever =
false- @@anything_pended_ever =
false
Instance Method Summary collapse
- #example_failed(example, counter, failure) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example, message, pending_caller) ⇒ Object
-
#initialize(a, b) ⇒ ItermColorProgressFormatter
constructor
A new instance of ItermColorProgressFormatter.
- #set_iterm_bg(color) ⇒ Object
- #start_dump ⇒ Object
Constructor Details
#initialize(a, b) ⇒ ItermColorProgressFormatter
Returns a new instance of ItermColorProgressFormatter.
18 19 20 21 22 23 |
# File 'lib/iterm_color_progress_formatter.rb', line 18 def initialize(a,b) super iterm = Appscript::app('iTerm') @@term = iterm.current_terminal.sessions.get.find {|sess| sess.get == iterm.current_terminal.current_session.get } @@original_color = @@term.background_color.get end |
Instance Method Details
#example_failed(example, counter, failure) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/iterm_color_progress_formatter.rb', line 42 def example_failed(example, counter, failure) unless @@anything_failed_ever @@anything_failed_ever = true set_iterm_bg(FAIL_COLOR) end super end |
#example_passed(example) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/iterm_color_progress_formatter.rb', line 35 def example_passed(example) unless @@anything_pended_ever || @@anything_failed_ever set_iterm_bg(PASS_COLOR) end super end |
#example_pending(example, message, pending_caller) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/iterm_color_progress_formatter.rb', line 50 def example_pending(example, , pending_caller) unless @@anything_pended_ever || @@anything_failed_ever @@anything_pended_ever = true set_iterm_bg(PEND_COLOR) end super end |
#set_iterm_bg(color) ⇒ Object
25 26 27 |
# File 'lib/iterm_color_progress_formatter.rb', line 25 def set_iterm_bg(color) @@term.background_color.set color end |
#start_dump ⇒ Object
29 30 31 32 33 |
# File 'lib/iterm_color_progress_formatter.rb', line 29 def start_dump # uncomment this if you don't want the final color left on the screen # @@current_terminal.background_color.set @@original_color super end |