Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixing total coverage amount

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

0 notes on commit 26f3c64

Please sign in to comment.
Something went wrong with that request. Please try again.