Class: FactoryTrace::Writers::ReportWriter

Inherits:
Writer
  • Object
show all
Defined in:
lib/factory_trace/writers/report_writer.rb

Constant Summary collapse

COLORS =
{
  blue: "\e[34m",
  yellow: "\e[33m",
  green: "\e[32m",
  red: "\e[31m"
}.freeze
CODES =
{
  used: "used",
  unused: "unused"
}.freeze

Instance Attribute Summary

Attributes inherited from Writer

#configuration, #io

Instance Method Summary collapse

Methods inherited from Writer

#initialize

Constructor Details

This class inherits a constructor from FactoryTrace::Writers::Writer

Instance Method Details

#write(results) ⇒ Object

Parameters:

  • results (Array<Hash>)


19
20
21
22
23
24
25
# File 'lib/factory_trace/writers/report_writer.rb', line 19

def write(results)
  total_color = (results.any? { |result| result[:code] == :unused && !result.key?(:value) }) ? :red : :green

  results.each do |result|
    io.puts(convert(result, total_color: total_color))
  end
end