Class: CommandLineReporter::NestedFormatter
- Inherits:
-
Object
- Object
- CommandLineReporter::NestedFormatter
- Includes:
- OptionsValidator, Singleton
- Defined in:
- lib/command_line_reporter/formatter/nested.rb
Constant Summary collapse
- VALID_OPTIONS =
%i[message type complete indent_size color bold].freeze
Instance Attribute Summary collapse
-
#bold ⇒ Object
Returns the value of attribute bold.
-
#color ⇒ Object
Returns the value of attribute color.
- #complete_string ⇒ Object
- #indent_size ⇒ Object
-
#message_string ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength.
Instance Method Summary collapse
-
#format(options, block) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Methods included from OptionsValidator
Instance Attribute Details
#bold ⇒ Object
Returns the value of attribute bold.
10 11 12 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 10 def bold @bold end |
#color ⇒ Object
Returns the value of attribute color.
10 11 12 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 10 def color @color end |
#complete_string ⇒ Object
43 44 45 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 43 def complete_string @complete_string ||= 'complete' end |
#indent_size ⇒ Object
47 48 49 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 47 def indent_size @indent_size ||= 2 end |
#message_string ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
39 40 41 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 39 def @message_string ||= 'working' end |
Instance Method Details
#format(options, block) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/command_line_reporter/formatter/nested.rb', line 14 def format(, block) (, *VALID_OPTIONS) indent_level :incr padding = ' ' * @indent_level * ([:indent_size] || indent_size) = padding + ([:message] || ) complete_str = [:complete] || complete_string if [:type] == 'inline' colorize("#{}...", true, ) else colorize(, false, ) complete_str = padding + complete_str end block.call colorize(complete_str, false, ) indent_level :decr end |