Class: RSpec::Conductor::Formatters::Fancy
- Inherits:
-
Base
- Object
- Base
- RSpec::Conductor::Formatters::Fancy
show all
- Defined in:
- lib/rspec/conductor/formatters/fancy.rb
Constant Summary
Constants included
from Util::ANSI
Util::ANSI::ANSI_SEQUENCE_REGEX, Util::ANSI::COLOR_CODES, Util::ANSI::VISIBLE_CHAR_GROUP_REGEX
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#colorize, #print_debug, #print_retry_message, #print_slowest, #print_startup_banner, #print_summary
Methods included from Util::ANSI
clear_line, clear_line_forward, color_code, colorize, cursor_back, cursor_column, cursor_down, cursor_end_of_line, cursor_forward, cursor_up, split_visible_char_groups, tty_height, tty_width, visible_chars
Constructor Details
#initialize(worker_count:, **kwargs) ⇒ Fancy
Returns a new instance of Fancy.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 13
def initialize(worker_count:, **kwargs)
@terminal = Util::Terminal.new
@dots_string = +""
@last_error = nil
@progress_bar_line = @terminal.line
@terminal.puts
@workers_box = @terminal.box
@worker_lines = worker_count.times.to_h { |i| [i + 1, @workers_box.line] }
@terminal.puts
@dots_line = @terminal.line(truncate: false)
@terminal.puts
@last_error_line = @terminal.line(truncate: false)
@stdout_line = @terminal.puts nil
@stderr_line = @terminal.puts nil
@shutdown_line = @terminal.puts nil
super(**kwargs)
end
|
Class Method Details
.recommended? ⇒ Boolean
9
10
11
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 9
def self.recommended?
$stdout.tty? && $stdout.winsize[0] >= 30 && $stdout.winsize[1] >= 80
end
|
Instance Method Details
#example_failed(_worker_process, message) ⇒ Object
42
43
44
45
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 42
def example_failed(_worker_process, message)
dot "F", :red
@last_error = message.slice(:description, :location, :exception_class, :message, :backtrace)
end
|
#example_passed(_worker_process, _message) ⇒ Object
38
39
40
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 38
def example_passed(_worker_process, _message)
dot ".", :green
end
|
#example_pending(_worker_process, _message) ⇒ Object
51
52
53
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 51
def example_pending(_worker_process, _message)
dot "*", :yellow
end
|
#example_retried(_worker_process, _message) ⇒ Object
47
48
49
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 47
def example_retried(_worker_process, _message)
dot "R", :magenta
end
|
#handle_worker_message(worker_process, message, suite_run) ⇒ Object
33
34
35
36
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 33
def handle_worker_message(worker_process, message, suite_run)
public_send(message[:type], worker_process, message) if respond_to?(message[:type])
redraw(worker_process, suite_run)
end
|
#handle_worker_stderr(worker_number, string) ⇒ Object
59
60
61
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 59
def handle_worker_stderr(worker_number, string)
@stderr_line.update("STDERR: [worker #{worker_number}]: #{string}")
end
|
#handle_worker_stdout(worker_number, string) ⇒ Object
55
56
57
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 55
def handle_worker_stdout(worker_number, string)
@stdout_line.update("STDOUT: [worker #{worker_number}]: #{string}")
end
|
#print_shutdown_banner ⇒ Object
63
64
65
|
# File 'lib/rspec/conductor/formatters/fancy.rb', line 63
def print_shutdown_banner
@shutdown_line.update("Shutting down... (press ctrl-c again to force quit)")
end
|