Class: Coverband::Utils::FileList
- Inherits:
-
Array
- Object
- Array
- Coverband::Utils::FileList
- Defined in:
- lib/coverband/utils/file_list.rb
Instance Method Summary collapse
-
#covered_lines ⇒ Object
Returns the count of lines that have coverage.
-
#covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed.
-
#covered_percentages ⇒ Object
Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages.
-
#covered_strength ⇒ Float
Computes the strength (hits / line) based upon lines covered and lines missed.
- #first_seen_at ⇒ Object
-
#formatted_covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed, formatted.
-
#lines_of_code ⇒ Object
Returns the overall amount of relevant lines of code across all files in this list.
-
#missed_lines ⇒ Object
Returns the count of lines that have been missed.
-
#never_lines ⇒ Object
Returns the count of lines that are not relevant for coverage.
-
#skipped_lines ⇒ Object
Returns the count of skipped lines.
Instance Method Details
#covered_lines ⇒ Object
Returns the count of lines that have coverage
14 15 16 17 18 |
# File 'lib/coverband/utils/file_list.rb', line 14 def covered_lines return 0.0 if empty? map { |f| f.covered_lines.count }.inject(:+) end |
#covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed
54 55 56 57 58 |
# File 'lib/coverband/utils/file_list.rb', line 54 def covered_percent return 100.0 if empty? || lines_of_code.zero? Float(covered_lines * 100.0 / lines_of_code) end |
#covered_percentages ⇒ Object
Computes the coverage based upon lines covered and lines missed for each file Returns an array with all coverage percentages
43 44 45 |
# File 'lib/coverband/utils/file_list.rb', line 43 def covered_percentages map(&:covered_percent) end |
#covered_strength ⇒ Float
Computes the strength (hits / line) based upon lines covered and lines missed
68 69 70 71 72 |
# File 'lib/coverband/utils/file_list.rb', line 68 def covered_strength return 0.0 if empty? || lines_of_code.zero? Float(map { |f| f.covered_strength * f.lines_of_code }.inject(:+) / lines_of_code) end |
#first_seen_at ⇒ Object
74 75 76 |
# File 'lib/coverband/utils/file_list.rb', line 74 def first_seen_at map(&:first_updated_at).reject { |el| el.is_a?(String) }.min end |
#formatted_covered_percent ⇒ Float
Computes the coverage based upon lines covered and lines missed, formatted
62 63 64 |
# File 'lib/coverband/utils/file_list.rb', line 62 def formatted_covered_percent covered_percent.round(2) end |
#lines_of_code ⇒ Object
Returns the overall amount of relevant lines of code across all files in this list
48 49 50 |
# File 'lib/coverband/utils/file_list.rb', line 48 def lines_of_code covered_lines + missed_lines end |
#missed_lines ⇒ Object
Returns the count of lines that have been missed
21 22 23 24 25 |
# File 'lib/coverband/utils/file_list.rb', line 21 def missed_lines return 0.0 if empty? map { |f| f.missed_lines.count }.inject(:+) end |
#never_lines ⇒ Object
Returns the count of lines that are not relevant for coverage
28 29 30 31 32 |
# File 'lib/coverband/utils/file_list.rb', line 28 def never_lines return 0.0 if empty? map { |f| f.never_lines.count }.inject(:+) end |
#skipped_lines ⇒ Object
Returns the count of skipped lines
35 36 37 38 39 |
# File 'lib/coverband/utils/file_list.rb', line 35 def skipped_lines return 0.0 if empty? map { |f| f.skipped_lines.count }.inject(:+) end |