class Coco::Summary

A very brief summary of the coverage result.

Attributes

count[R]
coverable_files[R]
uncovered_count[R]

Public Class Methods

new(result, uncovered) click to toggle source
# File lib/coco/cover/summary.rb, line 8
def initialize(result, uncovered)
  @uncovered_count = uncovered.size
  @coverable_files = result.coverable_files
  @count = @coverable_files.size + @uncovered_count
end

Public Instance Methods

average() click to toggle source

Public: Computes the average coverage rate. The formula is simple:

N = number of files f = a file average = sum(f_i%) / N

In words: Take the sum of the coverage's percentage of all files and divide this sum by the number of files.

Returns the Float average rate of coverage.

# File lib/coco/cover/summary.rb, line 30
def average
  files_present? ? sum / count : 0
end
to_s() click to toggle source
# File lib/coco/cover/summary.rb, line 14
def to_s
  "Cover #{'%.2f' % average}% | #{uncovered_count} uncovered | #{count} files"
end

Private Instance Methods

files_present?() click to toggle source
# File lib/coco/cover/summary.rb, line 46
def files_present?
  count > 0
end
sum() click to toggle source

Returns the Float sum of all files' percentage.

# File lib/coco/cover/summary.rb, line 40
def sum
  coverable_files.values.map do |hits|
    CoverageStat.real_percent(hits)
  end.reduce(&:+)
end