Class: XCPerfect::Simple

Inherits:
Formatter show all
Defined in:
lib/xcperfect/formatters/simple.rb

Overview

Simple just prints the following information

  • Target Name

  • Number of lines hit

  • Total number of lines

  • Coverage percentage

Constant Summary

Constants included from ANSI

ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER

Instance Attribute Summary

Attributes inherited from Formatter

#parser

Attributes included from ANSI

#colorize

Instance Method Summary collapse

Methods inherited from Formatter

#align, #align_formats, #color_percentage, #initialize, #pretty_coverage_info, #spaces

Methods included from ANSI

#ansi_parse, #applied_effects, #color_for, #colorize?, #cyan, #green, #red, #strip, #white, #yellow

Constructor Details

This class inherits a constructor from XCPerfect::Formatter

Instance Method Details

#pretty_format(desirables) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/xcperfect/formatters/simple.rb', line 8

def pretty_format(desirables)
  output = [['Target', 'Covered', 'Out of', 'Percentage']]

  @parser.extract_targets(desirables).each do |target|
    output << pretty_coverage_info(target)
  end
  output << pretty_coverage_info(@parser.json)

  rows = align(output)
  sentences = rows.map { |row| row.join(' ') }

  divider = '-' * sentences[0].length
  sentences[0] = white(sentences[0])

  sentences.insert(1, divider)
  sentences.insert(sentences.length - 1, divider).join("\n")
end