Class: Reviewer::Report::Formatter

Inherits:
Object
  • Object
show all
Includes:
Output::Formatting
Defined in:
lib/reviewer/report/formatter.rb

Overview

Formats a Report for summary output to the console

Constant Summary

Constants included from Output::Formatting

Output::Formatting::CHECKMARK, Output::Formatting::XMARK

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report, output: Output.new) ⇒ Formatter

Creates a formatter for displaying a report

Parameters:

  • report (Report)

    the report to format

  • output (Output) (defaults to: Output.new)

    the output handler for console display



16
17
18
19
20
# File 'lib/reviewer/report/formatter.rb', line 16

def initialize(report, output: Output.new)
  @report = report
  @output = output
  @name_width = 0
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



9
10
11
# File 'lib/reviewer/report/formatter.rb', line 9

def output
  @output
end

#reportObject (readonly)

Returns the value of attribute report.



9
10
11
# File 'lib/reviewer/report/formatter.rb', line 9

def report
  @report
end

Instance Method Details

This method returns an undefined value.

Prints the formatted report to the console



25
26
27
28
29
30
31
32
33
34
# File 'lib/reviewer/report/formatter.rb', line 25

def print
  if report.results.empty?
    output.printer.puts(:muted, 'No tools to run')
    return
  end

  print_tool_lines
  output.newline
  print_summary
end