Class: Evilution::Reporter::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/reporter/cli.rb

Defined Under Namespace

Modules: ItemFormatters, LineFormatters Classes: MetricsBlock, Pct, Section, SectionRenderer, Trailer

Constant Summary collapse

SEPARATOR =
"=" * 44

Instance Method Summary collapse

Constructor Details

#initialize(header: LineFormatters::Header.new, metrics_block: MetricsBlock.new, section_renderer: SectionRenderer.new, sections: DEFAULT_SECTIONS, trailer: Trailer.new) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/evilution/reporter/cli.rb', line 8

def initialize(
  header: LineFormatters::Header.new,
  metrics_block: MetricsBlock.new,
  section_renderer: SectionRenderer.new,
  sections: DEFAULT_SECTIONS,
  trailer: Trailer.new
)
  @header = header
  @metrics_block = metrics_block
  @section_renderer = section_renderer
  @sections = sections
  @trailer = trailer
end

Instance Method Details

#call(summary) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/evilution/reporter/cli.rb', line 22

def call(summary)
  lines = []
  lines << @header.format(summary)
  lines << SEPARATOR
  lines << ""
  lines.concat(@metrics_block.call(summary))
  @sections.each { |section| lines.concat(@section_renderer.call(section, summary)) }
  lines << ""
  lines.concat(@trailer.call(summary))
  lines.join("\n")
end