Class: SimpleCov::SingleFile::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/single_file/formatter.rb

Constant Summary collapse

RSPEC_REGEX =
%r{r?spec}.freeze
RB_EXTENSION =
'.rb'
DEFAULT_GREEN_THRESHOLD =
100
BLOCK_STYLE =
:block
NO_COLOR =
'%<message>s'

Instance Method Summary collapse

Instance Method Details

#format(result) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/simplecov/single_file/formatter.rb', line 12

def format(result)
  return unless single_file?

  include_output

  @result = result
  lines = []

  if (file = tested_file(result))
    lines << file_message(file)
    lines << coverage_message(file.coverage_statistics[:line])
    lines << branch_coverage_message(file.coverage_statistics[:branch]) if SimpleCov.branch_coverage?
  else
    lines << file_not_found_message
  end

  output(lines)
end