Skip to content

Commit

Permalink
Added a count of the untested lines, to see which file would give you…
Browse files Browse the repository at this point in the history
… the most bang-for-buck.
  • Loading branch information
mattalbright committed May 25, 2011
1 parent ae3b6bd commit 414ac9b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/cover_me/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ def total_loc
end
return @total_loc
end


# Returns the total number of untested lines of code across all files.
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

# Returns an average percent across all files.
def percent_tested
unless @percent_tested
Expand Down
5 changes: 5 additions & 0 deletions lib/cover_me/templates/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<th>File</th>
<th>Lines</th>
<th>Lines Of Code</th>
<th>Untested Lines of Code</th>
<th>Tested %</th>
</tr>
</thead>
Expand All @@ -118,6 +119,9 @@
<td>
<%= report.lines_of_code %>
</td>
<td>
<%= report.lines_of_code - report.lines_executed %>
</td>
<td>
<%= report.executed_percent %>%
</td>
Expand All @@ -129,6 +133,7 @@
<th>Total</th>
<th><%= index.total_lines %></th>
<th><%= index.total_loc %></th>
<th><%= index.total_untested_loc %></th>
<th><%= index.percent_tested %>%</th>
</tr>
</table>
Expand Down
2 changes: 2 additions & 0 deletions lib/cover_me/templates/report.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<th>File</th>
<th>Lines</th>
<th>Lines Of Code</th>
<th>Untested Lines of Code</th>
<th>Tested %</th>
</tr>
<tr valign='top'>
Expand All @@ -64,6 +65,7 @@
</td>
<td><%= report.lines %></td>
<td><%= report.lines_of_code %></td>
<td><%= report.lines_of_code - report.lines_executed %></td>
<td><%= report.executed_percent %>%</td>
</tr>
</table>
Expand Down

0 comments on commit 414ac9b

Please sign in to comment.