Class: Rcov::TextReport

Inherits:
TextSummary show all
Defined in:
lib/rcov/formatters/text_report.rb

Overview

:nodoc:

Constant Summary

Constant Summary

Constants inherited from BaseFormatter

BaseFormatter::DEFAULT_OPTS, BaseFormatter::RCOV_IGNORE_REGEXPS

Instance Method Summary (collapse)

Methods inherited from TextSummary

#summary

Methods inherited from BaseFormatter

#add_file, #code_coverage, #each_file_pair_sorted, #initialize, #mangle_filename, #normalize_filename, #num_code_lines, #num_lines, #sorted_file_pairs, #total_coverage

Constructor Details

This class inherits a constructor from Rcov::BaseFormatter

Instance Method Details

- (Object) execute



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rcov/formatters/text_report.rb', line 3

def execute
  print_lines
  print_header
  print_lines

  each_file_pair_sorted do |fname, finfo|
    name = fname.size < 52 ? fname : "..." + fname[-48..-1]
    print_info(name, finfo.num_lines, finfo.num_code_lines,
    finfo.code_coverage)
  end

  print_lines
  print_info("Total", num_lines, num_code_lines, code_coverage)
  print_lines
  puts summary
end


28
29
30
# File 'lib/rcov/formatters/text_report.rb', line 28

def print_header
  puts "|                  File                              | Lines |  LOC  |  COV   |"
end


20
21
22
# File 'lib/rcov/formatters/text_report.rb', line 20

def print_info(name, lines, loc, coverage)
  puts "|%-51s | %5d | %5d | %5.1f%% |" % [name, lines, loc, 100 * coverage]
end


24
25
26
# File 'lib/rcov/formatters/text_report.rb', line 24

def print_lines
  puts "+----------------------------------------------------+-------+-------+--------+"
end