Class: Coco::ConsoleFormatter
- Defined in:
- lib/coco/formatter/console_formatter.rb
Overview
I format coverages information for console output.
Instance Method Summary collapse
-
#format(single_line_report = false) ⇒ Object
single_line_report - Boolean.
-
#initialize(covered, uncovered) ⇒ ConsoleFormatter
constructor
covered - Hash uncovered - Array.
-
#link ⇒ Object
Returns String.
Constructor Details
#initialize(covered, uncovered) ⇒ ConsoleFormatter
covered - Hash uncovered - Array
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/coco/formatter/console_formatter.rb', line 30 def initialize covered, uncovered super(covered, uncovered) @formatted_output = [] compute_percentage add_percentage_to_uncovered @formatted_output.sort! @formatted_output.map! do |percentage, filename| text = ColoredString.new "#{percentage}% #{filename}" if percentage <= 50 text.red else text.yellow end end end |
Instance Method Details
#format(single_line_report = false) ⇒ Object
single_line_report - Boolean
Returns percent covered and associated filenames as a String.
11 12 13 14 15 16 17 |
# File 'lib/coco/formatter/console_formatter.rb', line 11 def format(single_line_report = false) if single_line_report else @formatted_output.join("\n") end end |
#link ⇒ Object
Returns String.
20 21 22 23 24 25 26 |
# File 'lib/coco/formatter/console_formatter.rb', line 20 def link unless @formatted_output.empty? "See file://" + File.(File.join(Coco::HtmlDirectory.new.coverage_dir, 'index.html')) end end |