Class: Coco::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/coco/cover/summary.rb

Overview

A very brief summary of the coverage result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, uncovered) ⇒ Summary

Returns a new instance of Summary.



8
9
10
11
12
# 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

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/coco/cover/summary.rb', line 6

def count
  @count
end

#uncovered_countObject (readonly)

Returns the value of attribute uncovered_count.



6
7
8
# File 'lib/coco/cover/summary.rb', line 6

def uncovered_count
  @uncovered_count
end

Instance Method Details

#averageObject

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.



30
31
32
# File 'lib/coco/cover/summary.rb', line 30

def average
  files_present? ? sum / count : 0
end

#to_sObject



14
15
16
# File 'lib/coco/cover/summary.rb', line 14

def to_s
  "Cover #{'%.2f' % average}% | #{uncovered_count} uncovered | #{count} files"
end