Class: CoverUp::Result
- Inherits:
-
Object
- Object
- CoverUp::Result
- Defined in:
- lib/cover-up.rb
Overview
This tracks overall coverage results for a run
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
Instance Method Summary collapse
-
#hit_percentage ⇒ Object
This calculates the overall hit percentage for the run.
-
#initialize(files) ⇒ Result
constructor
This initializes the result with the individual file results.
-
#lines ⇒ Object
This returns the total amount of lines in this coverage report.
-
#lines_without_exclusions ⇒ Object
This returns the total amount of lines without exclusions in this coverage report.
-
#missed_percentage ⇒ Object
This calculates the overall miss percentage for the run.
Constructor Details
#initialize(files) ⇒ Result
This initializes the result with the individual file results
7 8 9 |
# File 'lib/cover-up.rb', line 7 def initialize(files) self.files = files end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
4 5 6 |
# File 'lib/cover-up.rb', line 4 def files @files end |
Instance Method Details
#hit_percentage ⇒ Object
This calculates the overall hit percentage for the run
26 27 28 29 30 |
# File 'lib/cover-up.rb', line 26 def hit_percentage return 0 if self.lines_without_exclusions.to_f == 0.0 hit = self.files.collect { |f| f.hit }.flatten (hit.length.to_f / self.lines_without_exclusions.to_f) * 100.0 end |
#lines ⇒ Object
This returns the total amount of lines in this coverage report
12 13 14 15 16 |
# File 'lib/cover-up.rb', line 12 def lines sum = 0 self.files.collect { |f| f.lines }.each { |i| sum += i } sum end |
#lines_without_exclusions ⇒ Object
This returns the total amount of lines without exclusions in this coverage report
19 20 21 22 23 |
# File 'lib/cover-up.rb', line 19 def lines_without_exclusions sum = 0 self.files.collect { |f| f.lines_without_exclusions }.each { |i| sum += i } sum end |
#missed_percentage ⇒ Object
This calculates the overall miss percentage for the run
33 34 35 36 37 |
# File 'lib/cover-up.rb', line 33 def missed_percentage return 0 if self.lines_without_exclusions.to_f == 0.0 missed = self.files.collect { |f| f.missed }.flatten (missed.length.to_f / self.lines_without_exclusions.to_f) * 100.0 end |