Class: RainbowFormatter
Constant Summary
collapse
- BUNDLED_MODES =
{
tina_bike: Formatter::Custom::TinaBike,
tina_dream: Formatter::Custom::TinaDream,
car: Formatter::Custom::Car,
dog: Formatter::Custom::Dog,
monkey: Formatter::Custom::Monkey
}.freeze
Formatter::Common::ERROR, Formatter::Common::ESC, Formatter::Common::FAIL, Formatter::Common::NND, Formatter::Common::PASS, Formatter::Common::PASS_ARY, Formatter::Common::PENDING, Formatter::Common::VT100_CODES, Formatter::Common::VT100_CODE_VALUES
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#ascii_length, #ascii_to_display, #colors, #console_code_for, #current_width, #dump_progress, #eol, #example_width, #failed_or_pending?, #failure_color, #finished?, #format_duration, #highlight, included, #padding_width, #pending_color, #progress_lines, #rainbow_trail, #rainbowify, #scoreboard, #success_color, #terminal_width, #tick, #trail_progress_line_score, #wrap
Constructor Details
Returns a new instance of RainbowFormatter.
25
26
27
28
29
30
31
32
|
# File 'lib/rainbow_formatter.rb', line 25
def initialize(output)
@output = output
@current = @color_index = @passing_count = @failure_count = @pending_count = @animation_index = 0
@example_results = []
@failed_examples = []
@pending_examples = []
setup_formatter
end
|
Instance Attribute Details
#ascii_array ⇒ Object
Returns the value of attribute ascii_array.
12
13
14
|
# File 'lib/rainbow_formatter.rb', line 12
def ascii_array
@ascii_array
end
|
#example_name ⇒ Object
Returns the value of attribute example_name.
12
13
14
|
# File 'lib/rainbow_formatter.rb', line 12
def example_name
@example_name
end
|
#output ⇒ Object
Returns the value of attribute output.
12
13
14
|
# File 'lib/rainbow_formatter.rb', line 12
def output
@output
end
|
Class Method Details
.configuration ⇒ Object
40
41
42
|
# File 'lib/rainbow_formatter.rb', line 40
def self.configuration
@configuration ||= Formatter::Configuration.new
end
|
44
45
46
|
# File 'lib/rainbow_formatter.rb', line 44
def self.configure
yield configuration if block_given?
end
|
Instance Method Details
#dump_failed_summary ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/rainbow_formatter.rb', line 82
def dump_failed_summary
@failed_examples.each do |n|
output.puts "\n-> #{n.description}\n\n"
output.puts n.colorized_message_lines
output.puts "\n --> Exception backtrace: \n\n"
output.puts n.exception.backtrace.join("\n")
end
end
|
#dump_summary(notification) ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'lib/rainbow_formatter.rb', line 91
def dump_summary(notification)
duration = notification.duration
summary = "\nYou've rainbowified for #{format_duration(duration)}\n".split(//).map { |c| rainbowify(c) }
dump_failed_summary
output.puts notification.colorized_message_lines if notification.respond_to?(:colorized_message_lines)
output.puts summary.join
output.puts notification.fully_formatted
dump_commands_to_rerun_failed_examples if respond_to?(:dump_commands_to_rerun_failed_examples)
end
|
#example_failed(notification) ⇒ Object
76
77
78
79
80
|
# File 'lib/rainbow_formatter.rb', line 76
def example_failed(notification)
@failed_examples << notification
@failure_count += 1
tick(mark: FAIL)
end
|
#example_passed(_notification) ⇒ Object
66
67
68
|
# File 'lib/rainbow_formatter.rb', line 66
def example_passed(_notification)
tick
end
|
#example_pending(notification) ⇒ Object
70
71
72
73
74
|
# File 'lib/rainbow_formatter.rb', line 70
def example_pending(notification)
@pending_examples << notification
@pending_count += 1
tick(mark: PENDING)
end
|
#example_started(notification) ⇒ Object
61
62
63
64
|
# File 'lib/rainbow_formatter.rb', line 61
def example_started(notification)
notification = notification.example if notification.respond_to?(:example)
@example_name = notification.full_description
end
|
34
35
36
37
38
|
# File 'lib/rainbow_formatter.rb', line 34
def setup_formatter
formatter = RainbowFormatter.configuration.formatter
formatter = BUNDLED_MODES.dig(formatter) unless formatter.is_a?(Module)
singleton_class.send(:include, formatter)
end
|
#start(start_notification) ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/rainbow_formatter.rb', line 48
def start(start_notification)
@example_count = if start_notification.is_a?(Integer)
start_notification
else
start_notification.count
end
end
|
#start_dump(_notification) ⇒ Object
57
58
59
|
# File 'lib/rainbow_formatter.rb', line 57
def start_dump(_notification)
@current = @example_count
end
|