Class: Coco::ConsoleFormatter
- Inherits:
-
Object
- Object
- Coco::ConsoleFormatter
- Defined in:
- lib/coco/formatter/console_formatter.rb
Overview
I format coverages data for console output.
Instance Method Summary collapse
-
#format ⇒ Object
Public: Get a colored report, formatted for console output.
-
#initialize(uncovered, threshold, result, config) ⇒ ConsoleFormatter
constructor
Public: Creates a new ConsoleFormatter.
-
#link ⇒ Object
Get the link for the report’s index file.
Constructor Details
#initialize(uncovered, threshold, result, config) ⇒ ConsoleFormatter
Public: Creates a new ConsoleFormatter.
uncovered - An Array list of uncovered files. threshold - The Fixnum percentage threshold. result - A CoverageResult. config - A Configuration.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/coco/formatter/console_formatter.rb', line 35 def initialize(uncovered, threshold, result, config) @uncovered = uncovered @result = result @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 elsif percentage >= threshold text.green else text.yellow end end @summary = Summary.new(result, uncovered) @config = config end |
Instance Method Details
#format ⇒ Object
Public: Get a colored report, formatted for console output.
Returns percent covered and associated filenames as a multilines or a single line String.
12 13 14 |
# File 'lib/coco/formatter/console_formatter.rb', line 12 def format @config[:single_line_report] ? : end |
#link ⇒ Object
Get the link for the report’s index file.
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 |