Permalink
Browse files

first commit

  • Loading branch information...
fguillen committed Oct 18, 2010
0 parents commit 7ee1ec31e129ea7acb0e36a21748ce3a15d64a27
@@ -0,0 +1,24 @@
+.rvmrc
+.bundle
+
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -0,0 +1,10 @@
+# Foo class
+class Foo
+ def initialize
+ @foo = 'baz'
+ end
+
+ def bar
+ @foo
+ end
+end
@@ -0,0 +1,10 @@
+# Foo class
+class Foo
+ def initialize
+ @foo = 'baz'
+ end
+
+ def bar
+ @foo
+ end
+end
Oops, something went wrong.

0 comments on commit 7ee1ec3

Please sign in to comment.