Permalink
Browse files

fixing total coverage amount

  • Loading branch information...
1 parent 183dd79 commit 26f3c64af448a503c9586f1c45d512f7a2c80e34 @fguillen fguillen committed Feb 3, 2011
Showing with 14 additions and 4 deletions.
  1. +1 −1 Manifest
  2. +1 −1 Rakefile
  3. +10 −1 lib/simplecov-rcov.rb
  4. +2 −1 test/fixtures/file_tr.html
View
2 Manifest
@@ -1,5 +1,5 @@
Manifest
-README.rdoc
+README.md
Rakefile
lib/simplecov-rcov.rb
test/fixtures/app/controllers/sample_controller.rb
View
2 Rakefile
@@ -2,7 +2,7 @@ require 'rubygems'
require 'rake'
require 'echoe'
-Echoe.new('simplecov-rcov', '0.1.1') do |p|
+Echoe.new('simplecov-rcov', '0.1.2') do |p|
p.description = "Rcov style formatter for SimpleCov"
p.url = "http://github.com/fguillen/simplecov-rcov"
p.author = "Fernando Guillen http://fernandoguillen.info"
View
11 lib/simplecov-rcov.rb
@@ -6,7 +6,7 @@ def format( result )
@total_lines = result.files.map { |e| e.lines.count }.inject(:+)
@total_lines_code = result.files.map { |e| e.covered_lines.count + e.missed_lines.count }.inject(:+)
- @total_coverage = result.covered_percent
+ @total_coverage = SimpleCov::Formatter::RcovFormatter.total_coverage(@files)
template = ERB.new( File.read( "#{File.dirname(__FILE__)}/../views/index.erb.html" ) )
rcov_result = template.result( binding )
@@ -23,6 +23,15 @@ def format( result )
end
private
+
+ # Computes the coverage based upon lines covered and lines missed
+ def self.total_coverage(file_list)
+ return 100.0 if file_list.length == 0
+ porcents_sum = file_list.map(&:covered_percent).reduce(&:+)
+ result = porcents_sum / file_list.length
+
+ return result
+ end
def self.path_result
File.join( SimpleCov.coverage_path, SimpleCov::Formatter::RcovFormatter::PATH_RESULT )
View
3 test/fixtures/file_tr.html
@@ -1,4 +1,5 @@
-fixtures/app/controllers/sample_controller.rb</td>
+ <tr class="all_files">
+ <td class="left_align"><a href="#./test/fixtures/app/controllers/sample_controller.rb">./test/fixtures/app/controllers/sample_controller.rb</a></td>
<td class='right_align'><tt>10</tt></td>
<td class='right_align'><tt>5</tt></td>
<td class="left_align"><tt class=''>60.00%</tt></td>

0 comments on commit 26f3c64

Please sign in to comment.