Class: Rcov::TextReport

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

Overview

:nodoc:

Constant Summary

Constants inherited from BaseFormatter

BaseFormatter::DEFAULT_OPTS

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

#executeObject



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

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


30
31
32
# File 'lib/rcov/formatters/text_report.rb', line 30

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


22
23
24
# File 'lib/rcov/formatters/text_report.rb', line 22

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


26
27
28
# File 'lib/rcov/formatters/text_report.rb', line 26

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