Class: RakeCommandFilter::LineFilterResult
- Inherits:
-
Object
- Object
- RakeCommandFilter::LineFilterResult
- Defined in:
- lib/line_filter_result.rb
Overview
sumarizes the result of filtering a single line of command output
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(name, result, output) ⇒ LineFilterResult
constructor
Do not create this directly, use the result_…
-
#output(elapsed) ⇒ Object
Called to output the result to the console.
-
#severity ⇒ Object
serious failures.
Constructor Details
#initialize(name, result, output) ⇒ LineFilterResult
Do not create this directly, use the result_… variants in CommandDefinition
28 29 30 31 32 |
# File 'lib/line_filter_result.rb', line 28 def initialize(name, result, output) @name = name @result = result @message = output end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
24 25 26 |
# File 'lib/line_filter_result.rb', line 24 def @message end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/line_filter_result.rb', line 24 def name @name end |
#result ⇒ Object
Returns the value of attribute result.
24 25 26 |
# File 'lib/line_filter_result.rb', line 24 def result @result end |
Instance Method Details
#output(elapsed) ⇒ Object
Called to output the result to the console. rubocop:disable MethodLength
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/line_filter_result.rb', line 52 def output(elapsed) case @result when MATCH_SUCCESS color = :green header = 'OK' when MATCH_FAILURE color = :red header = 'FAIL' when MATCH_WARNING color = :light_red header = 'WARN' end header = header.ljust(12).colorize(color) str_elapsed = "#{elapsed.round(2)}s" name = @name.to_s[0..17] puts "#{header} #{name.ljust(20)} #{str_elapsed.ljust(9)} #{@message}" end |
#severity ⇒ Object
serious failures.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/line_filter_result.rb', line 36 def severity case @result when MATCH_SUCCESS return 0 when MATCH_WARNING return 1 when MATCH_FAILURE return 2 else raise ArgumentError, 'Unknown result' end end |