Class: SimpleCov::Formatter::MetricFu::FormatLikeRCov

Inherits:
Object
  • Object
show all
Defined in:
lib/metric_fu/metrics/rcov/simplecov_formatter.rb

Overview

report should reference file used to build it

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ FormatLikeRCov

Returns a new instance of FormatLikeRCov.



48
49
50
# File 'lib/metric_fu/metrics/rcov/simplecov_formatter.rb', line 48

def initialize(result)
  @result = result
end

Instance Method Details

#formatObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/metric_fu/metrics/rcov/simplecov_formatter.rb', line 52

def format
  content = "metric_fu shift the first line\n"
  @result.source_files.each do |source_file|
    content << "=" * 80
    content << "\n #{simple_file_name(source_file)}\n"
    content << "=" * 80
    content << "\n"
    source_file.lines.each do |line|
      content << "!!" if line.missed?
      content << "--" if line.never? || line.skipped?
      content << "  " if line.covered?
      content << " #{line.src.chomp}\n"
    end
    content << "\n"
  end
  content
end

#simple_file_name(source_file) ⇒ Object



70
71
72
# File 'lib/metric_fu/metrics/rcov/simplecov_formatter.rb', line 70

def simple_file_name(source_file)
  source_file.filename.gsub(SimpleCov.root, ".")
end