Class: DeepCover::Reporter::Text

Inherits:
Base
  • Object
show all
Defined in:
lib/deep_cover/reporter/text.rb

Constant Summary collapse

INDENT =
'  '

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#analysis, #each, #initialize, #populate_stats

Methods included from Memoize

#freeze, included

Constructor Details

This class inherits a constructor from DeepCover::Reporter::Base

Class Method Details

.report(coverage, **options) ⇒ Object



22
23
24
# File 'lib/deep_cover/reporter/text.rb', line 22

def self.report(coverage, **options)
  Text.new(coverage, **options).report
end

Instance Method Details

#reportObject



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

def report
  formatted_headings = headings.map.with_index { |h, i| {value: h, alignment: :center} }
  columns = rows.transpose
  (1...columns.size).step(2) { |i| columns[i] = formatted_stats(columns[i]) }
  table = Terminal::Table.new(
      headings: formatted_headings,
      rows: columns.transpose,
      style: {border_bottom: false, border_top: false, alignment: :right},
  )
  table.align_column 0, :left
  table.render + "\n\nOverall: #{analysis.overall}%"
end