Class: Undercover::Formatter
- Inherits:
-
Object
- Object
- Undercover::Formatter
- Defined in:
- lib/undercover/formatter.rb
Constant Summary collapse
- WARNINGS_TO_S =
{ stale_coverage: Rainbow('🚨 WARNING: Coverage data is older than your ' \ 'latest changes and results might be incomplete. ' \ 'Re-run tests to update').yellow, no_changes: Rainbow('✅ No reportable changes').green }.freeze
Instance Method Summary collapse
- #exit_code ⇒ Object
-
#initialize(results, validation_error = nil) ⇒ Formatter
constructor
A new instance of Formatter.
- #to_s ⇒ Object
Constructor Details
#initialize(results, validation_error = nil) ⇒ Formatter
Returns a new instance of Formatter.
12 13 14 15 |
# File 'lib/undercover/formatter.rb', line 12 def initialize(results, validation_error = nil) @results = results @validation_error = validation_error end |
Instance Method Details
#exit_code ⇒ Object
25 26 27 28 29 30 |
# File 'lib/undercover/formatter.rb', line 25 def exit_code return 0 if @validation_error return 0 unless @results.any? 1 end |
#to_s ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/undercover/formatter.rb', line 17 def to_s return WARNINGS_TO_S[@validation_error] if @validation_error return success unless @results.any? ([warnings_header] + formatted_warnings).join("\n") end |