Class: CoverMe::Index
- Inherits:
-
Object
- Object
- CoverMe::Index
- Defined in:
- lib/cover_me/index.rb
Overview
Used to generate an index page for the code coverage.
Instance Attribute Summary collapse
-
#reports ⇒ Object
Returns the value of attribute reports.
Instance Method Summary collapse
-
#initialize(reports = []) ⇒ Index
constructor
:nodoc:.
-
#percent_tested ⇒ Object
Returns an average percent across all files.
-
#total_lines ⇒ Object
Returns the total number of lines across all files.
-
#total_loc ⇒ Object
Returns the total number of lines of code across all files.
-
#total_untested_loc ⇒ Object
Returns the total number of untested lines of code across all files.
Constructor Details
#initialize(reports = []) ⇒ Index
:nodoc:
5 6 7 |
# File 'lib/cover_me/index.rb', line 5 def initialize(reports = []) # :nodoc: self.reports = reports end |
Instance Attribute Details
#reports ⇒ Object
Returns the value of attribute reports.
3 4 5 |
# File 'lib/cover_me/index.rb', line 3 def reports @reports end |
Instance Method Details
#percent_tested ⇒ Object
Returns an average percent across all files.
34 35 36 37 38 39 40 |
# File 'lib/cover_me/index.rb', line 34 def percent_tested unless @percent_tested @percent_tested = (total_loc - total_untested_loc).to_f / (total_loc).to_f * 100 @percent_tested = (@percent_tested.nan? ? 0 : @percent_tested.round(2)) end return @percent_tested end |
#total_lines ⇒ Object
Returns the total number of lines across all files.
10 11 12 13 14 15 |
# File 'lib/cover_me/index.rb', line 10 def total_lines unless @total_lines @total_lines = self.reports.inject(0) {|sum, x| sum += x.lines; sum} end return @total_lines end |
#total_loc ⇒ Object
Returns the total number of lines of code across all files.
18 19 20 21 22 23 |
# File 'lib/cover_me/index.rb', line 18 def total_loc unless @total_loc @total_loc = self.reports.inject(0) {|sum, x| sum += x.lines_of_code; sum} end return @total_loc end |
#total_untested_loc ⇒ Object
Returns the total number of untested lines of code across all files.
26 27 28 29 30 31 |
# File 'lib/cover_me/index.rb', line 26 def total_untested_loc unless @total_untested_loc @total_untested_loc = self.reports.inject(0) {|sum, x| sum += (x.lines_of_code - x.lines_executed); sum} end return @total_untested_loc end |