Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 7ee1ec31e129ea7acb0e36a21748ce3a15d64a27 0 parents
@fguillen fguillen authored
24 .gitignore
@@ -0,0 +1,24 @@
+.rvmrc
+.bundle
+
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
10 Manifest
@@ -0,0 +1,10 @@
+Manifest
+README.rdoc
+Rakefile
+lib/simplecov-csv.rb
+test/fixtures/app/controllers/sample_controller.rb
+test/fixtures/app/models/user.rb
+test/fixtures/results.csv
+test/fixtures/sample.rb
+test/helper.rb
+test/simplecov-csv_test.rb
22 README.rdoc
@@ -0,0 +1,22 @@
+= SimpleCov CSV Formatter gem
+
+Is a CSV formatter for the ruby 1.9+ coverage gem: {SimpleCov}[http://github.com/colszowka/simplecov]
+
+== Install
+
+ $ [sudo] gem install simplecov_csv
+
+== Usage
+
+ require 'simplecov_csv'
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
+
+== TODO
+
+The actual version generates only one simple CSV file.
+
+== Credits
+
+Author:: Fernando Guillen: http://fernandoguillen.info
+Copyright:: Copyright (c) 2010 Fernando Guillen
+License:: Released under the MIT license.
13 Rakefile
@@ -0,0 +1,13 @@
+require 'rubygems'
+require 'rake'
+require 'echoe'
+
+Echoe.new('simplecov-csv', '0.1.3') do |p|
+ p.description = "CSV formatter for SimpleCov"
+ p.url = "http://github.com/fguillen/simplecov-csv"
+ p.author = "Fernando Guillen http://fernandoguillen.info"
+ p.email = "fguillen.mail@gmail.com"
+ p.ignore_pattern = ["tmp/*", "script/*"]
+ p.development_dependencies = []
+ p.runtime_dependencies = ['simplecov']
+end
29 lib/simplecov-rcov.rb
@@ -0,0 +1,29 @@
+class SimpleCov::Formatter::RcovFormatter
+ PATH_RESULT = "/rcov/index.html"
+
+ def format( result )
+ @files = result.files
+
+ @covered_percent = result.covered_percent
+ @total_lines = result.files.map(&:covered_percent).inject(:+) / files.count.to_f
+
+ template = ERB.new( File.read( "#{File.dirname(__FILE__)}/../views/index.erb.html" ) )
+ rcov_result = template.result( binding )
+
+ FileUtils.mkdir_p( File.dirname( SimpleCov::Formatter::RcovFormatter.path_result ) )
+
+ File.open( SimpleCov::Formatter::RcovFormatter.path_result, "w" ) do |file_result|
+ file_result.write rcov_result
+ end
+
+ puts "Coverage report generated for #{result.command_name} to #{SimpleCov::Formatter::RcovFormatter.path_result}"
+
+ return rcov_result
+ end
+
+ private
+
+ def self.path_result
+ File.join( SimpleCov.coverage_path, SimpleCov::Formatter::CSVFormatter::PATH_RESULT )
+ end
+end
10 test/fixtures/app/controllers/sample_controller.rb
@@ -0,0 +1,10 @@
+# Foo class
+class Foo
+ def initialize
+ @foo = 'baz'
+ end
+
+ def bar
+ @foo
+ end
+end
10 test/fixtures/app/models/user.rb
@@ -0,0 +1,10 @@
+# Foo class
+class Foo
+ def initialize
+ @foo = 'baz'
+ end
+
+ def bar
+ @foo
+ end
+end
509 test/fixtures/index.html
@@ -0,0 +1,509 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
+ <head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
+ <title>SimpleCov - RCov style</title>
+ </head>
+ <body>
+ <h1>SimpleCov - RCov style</h1>
+
+ <div class="report_table_wrapper">
+ <table class='report' id='report_table'>
+ <thead>
+ <tr>
+ <th class="left_align">Name</th>
+ <th class="right_align">Total Lines</th>
+ <th class="right_align">Lines of Code</th>
+ <th class="left_align">Total Coverage</th>
+ <th class="left_align">Code Coverage</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td class="left_align">TOTAL</td>
+ <td class='right_align'><tt>1019</tt></td>
+ <td class='right_align'><tt>757</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>89.21%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:89px"></div>
+ <div class="uncovered" style="width:11px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>86.13%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:86px"></div>
+ <div class="uncovered" style="width:14px"></div>
+ </div></td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">app/controllers/application_controller.rb</a></td>
+ <td class='right_align'><tt>115</tt></td>
+ <td class='right_align'><tt>82</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>71.30%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:71px"></div>
+ <div class="uncovered" style="width:29px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>63.41%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:63px"></div>
+ <div class="uncovered" style="width:37px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app controllers odd">
+ <td class="left_align"><a href="app-controllers-authors_controller_rb.html">app/controllers/authors_controller.rb</a></td>
+ <td class='right_align'><tt>62</tt></td>
+ <td class='right_align'><tt>51</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app controllers even">
+ <td class="left_align"><a href="app-controllers-galleries_controller_rb.html">app/controllers/galleries_controller.rb</a></td>
+ <td class='right_align'><tt>18</tt></td>
+ <td class='right_align'><tt>15</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app controllers odd">
+ <td class="left_align"><a href="app-controllers-pages_controller_rb.html">app/controllers/pages_controller.rb</a></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-paintings_controller_rb.html">app/controllers/paintings_controller.rb</a></td>
+ <td class='right_align'><tt>199</tt></td>
+ <td class='right_align'><tt>164</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>92.46%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:92px"></div>
+ <div class="uncovered" style="width:8px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>90.85%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:91px"></div>
+ <div class="uncovered" style="width:9px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 50 60 70 80 90 100 app controllers odd">
+ <td class="left_align"><a href="app-controllers-user_sessions_controller_rb.html">app/controllers/user_sessions_controller.rb</a></td>
+ <td class='right_align'><tt>33</tt></td>
+ <td class='right_align'><tt>25</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>54.55%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:55px"></div>
+ <div class="uncovered" style="width:45px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>44.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:44px"></div>
+ <div class="uncovered" style="width:56px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app controllers even">
+ <td class="left_align"><a href="app-controllers-users_controller_rb.html">app/controllers/users_controller.rb</a></td>
+ <td class='right_align'><tt>47</tt></td>
+ <td class='right_align'><tt>37</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app controllers odd">
+ <td class="left_align"><a href="app-controllers-utils_controller_rb.html">app/controllers/utils_controller.rb</a></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app helpers even">
+ <td class="left_align"><a href="app-helpers-application_helper_rb.html">app/helpers/application_helper.rb</a></td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>8</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app helpers odd">
+ <td class="left_align"><a href="app-helpers-authors_helper_rb.html">app/helpers/authors_helper.rb</a></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 60 70 80 90 100 app helpers even">
+ <td class="left_align"><a href="app-helpers-layout_helper_rb.html">app/helpers/layout_helper.rb</a></td>
+ <td class='right_align'><tt>22</tt></td>
+ <td class='right_align'><tt>15</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>68.18%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:68px"></div>
+ <div class="uncovered" style="width:32px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>53.33%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:53px"></div>
+ <div class="uncovered" style="width:47px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app models odd">
+ <td class="left_align"><a href="app-models-author_rb.html">app/models/author.rb</a></td>
+ <td class='right_align'><tt>23</tt></td>
+ <td class='right_align'><tt>17</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app models even">
+ <td class="left_align"><a href="app-models-invitation_rb.html">app/models/invitation.rb</a></td>
+ <td class='right_align'><tt>17</tt></td>
+ <td class='right_align'><tt>14</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 90 100 app models odd">
+ <td class="left_align"><a href="app-models-painting_rb.html">app/models/painting.rb</a></td>
+ <td class='right_align'><tt>100</tt></td>
+ <td class='right_align'><tt>75</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>92.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:92px"></div>
+ <div class="uncovered" style="width:8px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>89.33%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:89px"></div>
+ <div class="uncovered" style="width:11px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app models even">
+ <td class="left_align"><a href="app-models-user_rb.html">app/models/user.rb</a></td>
+ <td class='right_align'><tt>46</tt></td>
+ <td class='right_align'><tt>34</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 app models odd">
+ <td class="left_align"><a href="app-models-user_session_rb.html">app/models/user_session.rb</a></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 70 80 90 100 config even">
+ <td class="left_align"><a href="config-boot_rb.html">config/boot.rb</a></td>
+ <td class='right_align'><tt>110</tt></td>
+ <td class='right_align'><tt>89</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>72.73%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:73px"></div>
+ <div class="uncovered" style="width:27px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>67.42%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:67px"></div>
+ <div class="uncovered" style="width:33px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config odd">
+ <td class="left_align"><a href="config-environment_rb.html">config/environment.rb</a></td>
+ <td class='right_align'><tt>47</tt></td>
+ <td class='right_align'><tt>11</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers even">
+ <td class="left_align"><a href="config-initializers-00_load_app_config_rb.html">config/initializers/00_load_app_config.rb</a></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers odd">
+ <td class="left_align"><a href="config-initializers-05_exception_notification_rb.html">config/initializers/05_exception_notification.rb</a></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class='right_align'><tt>3</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers even">
+ <td class="left_align"><a href="config-initializers-locale_rb.html">config/initializers/locale.rb</a></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers odd">
+ <td class="left_align"><a href="config-initializers-new_rails_defaults_rb.html">config/initializers/new_rails_defaults.rb</a></td>
+ <td class='right_align'><tt>21</tt></td>
+ <td class='right_align'><tt>7</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers even">
+ <td class="left_align"><a href="config-initializers-paperclip_rb.html">config/initializers/paperclip.rb</a></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class='right_align'><tt>2</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config initializers odd">
+ <td class="left_align"><a href="config-initializers-session_store_rb.html">config/initializers/session_store.rb</a></td>
+ <td class='right_align'><tt>15</tt></td>
+ <td class='right_align'><tt>4</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 config even">
+ <td class="left_align"><a href="config-routes_rb.html">config/routes.rb</a></td>
+ <td class='right_align'><tt>25</tt></td>
+ <td class='right_align'><tt>18</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 lib kids_art odd">
+ <td class="left_align"><a href="lib-kids_art-batch_processor_rb.html">lib/kids_art/batch_processor.rb</a></td>
+ <td class='right_align'><tt>27</tt></td>
+ <td class='right_align'><tt>20</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 lib paperclip even">
+ <td class="left_align"><a href="lib-paperclip-write_dimensions_rb.html">lib/paperclip/write_dimensions.rb</a></td>
+ <td class='right_align'><tt>11</tt></td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 110 lib utils odd">
+ <td class="left_align"><a href="lib-utils-core_rb.html">lib/utils/core.rb</a></td>
+ <td class='right_align'><tt>7</tt></td>
+ <td class='right_align'><tt>7</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>100.00%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:100px"></div>
+ <div class="uncovered" style="width:0px"></div>
+ </div></td>
+ </tr>
+
+ <tr class="all_files all_coverage 100 lib utils even">
+ <td class="left_align"><a href="lib-utils-zip_rb.html">lib/utils/zip.rb</a></td>
+ <td class='right_align'><tt>39</tt></td>
+ <td class='right_align'><tt>31</tt></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>94.87%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:95px"></div>
+ <div class="uncovered" style="width:5px"></div>
+ </div></td>
+ <td class="left_align"><div class="percent_graph_legend"><tt class=''>93.55%</tt></div>
+ <div class="percent_graph">
+ <div class="covered" style="width:94px"></div>
+ <div class="uncovered" style="width:6px"></div>
+ </div></td>
+ </tr>
+
+ </tbody>
+ </table>
+ </div>
+
+ </body>
+</html>
61 test/fixtures/index_1.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
+ <head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
+ <title>SimpleCov - RCov style</title>
+ </head>
+ <body>
+ <h1>SimpleCov - RCov style</h1>
+
+ <div class="report_table_wrapper">
+ <table class='report' id='report_table'>
+ <thead>
+ <tr>
+ <th class="left_align">Name</th>
+ <th class="right_align">Total Lines</th>
+ <th class="right_align">Lines of Code</th>
+ <th class="left_align">Total Coverage</th>
+ <th class="left_align">Code Coverage</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td class="left_align">TOTAL</td>
+ <td class='right_align'><tt>1019</tt></td>
+ <td class='right_align'><tt>757</tt></td>
+ <td class="left_align"><tt class=''>89.21%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/controllers/sample_controller.rb</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>
+ <td class="left_align"><tt class=''>60.00%</tt></td>
+ </tr>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/models/user.rb</td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ </tr>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/sample.rb</td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><tt class=''>100.00%</tt></td>
+ <td class="left_align"><tt class=''>100.00%</tt></td>
+ </tr>
+
+ </tbody>
+ </table>
+ </div>
+
+ </body>
+</html>
4 test/fixtures/results.csv
@@ -0,0 +1,4 @@
+File,% covered,Lines,Relevant Lines,Lines covered,Lines missed
+"./fixtures/app/controllers/sample_controller.rb",60,10,5,3,2
+"./fixtures/app/models/user.rb",80,10,5,4,1
+"./fixtures/sample.rb",100,10,5,5,0
10 test/fixtures/sample.rb
@@ -0,0 +1,10 @@
+# Foo class
+class Foo
+ def initialize
+ @foo = 'baz'
+ end
+
+ def bar
+ @foo
+ end
+end
11 test/helper.rb
@@ -0,0 +1,11 @@
+require 'rubygems'
+require 'test/unit'
+require 'mocha'
+require 'simplecov'
+
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+require 'simplecov-rcov'
+
+class Test::Unit::TestCase
+end
61 test/rcov/coverage_test_index.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
+ <head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
+ <title>SimpleCov - RCov style</title>
+ </head>
+ <body>
+ <h1>SimpleCov - RCov style</h1>
+
+ <div class="report_table_wrapper">
+ <table class='report' id='report_table'>
+ <thead>
+ <tr>
+ <th class="left_align">Name</th>
+ <th class="right_align">Total Lines</th>
+ <th class="right_align">Lines of Code</th>
+ <th class="left_align">Total Coverage</th>
+ <th class="left_align">Code Coverage</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td class="left_align">TOTAL</td>
+ <td class='right_align'><tt>1019</tt></td>
+ <td class='right_align'><tt>757</tt></td>
+ <td class="left_align"><tt class=''>89.21%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
+ </tr>
+ </tfoot>
+ <tbody>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/controllers/sample_controller.rb</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>
+ <td class="left_align"><tt class=''>60.00%</tt></td>
+ </tr>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/app/models/user.rb</td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ <td class="left_align"><tt class=''>80.00%</tt></td>
+ </tr>
+
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html">./fixtures/sample.rb</td>
+ <td class='right_align'><tt>10</tt></td>
+ <td class='right_align'><tt>5</tt></td>
+ <td class="left_align"><tt class=''>100.00%</tt></td>
+ <td class="left_align"><tt class=''>100.00%</tt></td>
+ </tr>
+
+ </tbody>
+ </table>
+ </div>
+
+ </body>
+</html>
33 test/simplecov-rcov_test.rb
@@ -0,0 +1,33 @@
+require "#{File.dirname(__FILE__)}/helper"
+
+class SimplecovRcovFormatterTest < Test::Unit::TestCase
+ def test_format
+ SimpleCov.stubs( :coverage_path ).returns( "/tmp" )
+ SimpleCov::Formatter::RcovFormatter.stubs( :path_result ).returns( 'rcov/coverage_test_index.html' )
+ if File.exists?( SimpleCov::Formatter::RcovFormatter.path_result )
+ File.delete( SimpleCov::Formatter::RcovFormatter.path_result )
+ end
+
+ @original_result = {
+ source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
+ source_fixture( 'app/models/user.rb' ) => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
+ source_fixture( 'app/controllers/sample_controller.rb' ) => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil]
+ }
+
+ @result = SimpleCov::Result.new( @original_result )
+ puts "XXX: @result: #{@result}"
+ rcov_result = SimpleCov::Formatter::RcovFormatter.new().format( @result )
+
+ # File.open( "#{File.dirname(__FILE__)}/fixtures/index_1.html", 'w' ) { |f| f.write rcov_result }
+
+ # File.readlines( source_fixture( 'results.csv' ) ).each do |line|
+ # assert_match( line.gsub( /^"\./, '' ), csv_result )
+ # end
+
+ assert( File.exists?( SimpleCov::Formatter::RcovFormatter.path_result ) )
+ end
+
+ def source_fixture( filename )
+ File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) )
+ end
+end
45 views/index.erb.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
+ <head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
+ <title>SimpleCov - RCov style</title>
+ </head>
+ <body>
+ <h1>SimpleCov - RCov style</h1>
+
+ <div class="report_table_wrapper">
+ <table class='report' id='report_table'>
+ <thead>
+ <tr>
+ <th class="left_align">Name</th>
+ <th class="right_align">Total Lines</th>
+ <th class="right_align">Lines of Code</th>
+ <th class="left_align">Total Coverage</th>
+ <th class="left_align">Code Coverage</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td class="left_align">TOTAL</td>
+ <td class='right_align'><tt>1019</tt></td>
+ <td class='right_align'><tt>757</tt></td>
+ <td class="left_align"><tt class=''>89.21%</tt></td>
+ <td class="left_align"><tt class='coverage_total'>86.13%</tt></td>
+ </tr>
+ </tfoot>
+ <tbody>
+ <% @files.each do |file| %>
+ <tr class="all_files all_coverage 70 80 90 100 app controllers even">
+ <td class="left_align"><a href="app-controllers-application_controller_rb.html"><%= file.filename.gsub(SimpleCov.root, '.') %></td>
+ <td class='right_align'><tt><%= file.lines.count %></tt></td>
+ <td class='right_align'><tt><%= file.covered_lines.count + file.missed_lines.count %></tt></td>
+ <td class="left_align"><tt class=''><%= '%.2f' % file.covered_percent %>%</tt></td>
+ <td class="left_align"><tt class=''><%= '%.2f' % file.covered_percent %>%</tt></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.