simplecov-csv 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ Manifest
2
+ README.rdoc
3
+ Rakefile
4
+ lib/simplecov-csv.rb
5
+ test/fixtures/app/controllers/sample_controller.rb
6
+ test/fixtures/app/models/user.rb
7
+ test/fixtures/results.csv
8
+ test/fixtures/sample.rb
9
+ test/helper.rb
10
+ test/simplecov-csv_test.rb
@@ -0,0 +1,18 @@
1
+ = SimpleCov CSV Formatter gem
2
+
3
+ == Install
4
+
5
+ $ [sudo] gem install simplecov_csv
6
+
7
+ == Usage
8
+ require 'simplecov_csv'
9
+ SimpleCov.formatter = SimpleCov::Formatter::CSVFormatter
10
+
11
+ == TODO
12
+ The actual version generates only one simple CSV file.
13
+
14
+ == Credits
15
+
16
+ Author:: Fernando Guillen: http://fernandoguillen.info
17
+ Copyright:: Copyright (c) 2010 Fernando Guillen
18
+ License:: Released under the MIT license.
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('simplecov-csv', '0.1.3') do |p|
6
+ p.description = "CSV formatter for SimpleCov"
7
+ p.url = "http://github.com/fguillen/simplecov-csv"
8
+ p.author = "Fernando Guillen http://fernandoguillen.info"
9
+ p.email = "fguillen.mail@gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ p.runtime_dependencies = ['simplecov']
13
+ end
@@ -0,0 +1,34 @@
1
+ class SimpleCov::Formatter::CSVFormatter
2
+ RESULT_FILE_NAME = "results.csv"
3
+
4
+ def format( result )
5
+ csv = "File,% covered,Lines,Relevant Lines,Lines covered,Lines missed\n"
6
+
7
+ result.files.each do |file|
8
+ csv << "\"#{shortened_filename file}\","
9
+ csv << "#{file.covered_percent.round.to_s},"
10
+ csv << "#{file.lines.count},"
11
+ csv << "#{file.covered_lines.count + file.missed_lines.count},"
12
+ csv << "#{file.covered_lines.count},"
13
+ csv << "#{file.missed_lines.count}\n"
14
+ end
15
+
16
+ result_file_path = File.join( SimpleCov.coverage_path, SimpleCov::Formatter::CSVFormatter.result_file_name )
17
+ File.open( result_file_path, "w" ) do |file_result|
18
+ file_result.write csv
19
+ end
20
+ puts "Coverage report generated for #{result.command_name} to #{result_file_path}"
21
+
22
+ return csv
23
+ end
24
+
25
+ private
26
+
27
+ def shortened_filename(source_file)
28
+ source_file.filename.gsub(SimpleCov.root, '.')
29
+ end
30
+
31
+ def self.result_file_name
32
+ SimpleCov::Formatter::CSVFormatter::RESULT_FILE_NAME
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{simplecov-csv}
5
+ s.version = "0.1.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Fernando Guillen http://fernandoguillen.info"]
9
+ s.date = %q{2010-10-11}
10
+ s.description = %q{CSV formatter for SimpleCov}
11
+ s.email = %q{fguillen.mail@gmail.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/simplecov-csv.rb"]
13
+ s.files = ["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", "simplecov-csv.gemspec"]
14
+ s.homepage = %q{http://github.com/fguillen/simplecov-csv}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Simplecov-csv", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{simplecov-csv}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{CSV formatter for SimpleCov}
20
+ s.test_files = ["test/simplecov-csv_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<simplecov>, [">= 0"])
28
+ else
29
+ s.add_dependency(%q<simplecov>, [">= 0"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<simplecov>, [">= 0"])
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ File,% covered,Lines,Relevant Lines,Lines covered,Lines missed
2
+ "./fixtures/app/controllers/sample_controller.rb",60,10,5,3,2
3
+ "./fixtures/app/models/user.rb",80,10,5,4,1
4
+ "./fixtures/sample.rb",100,10,5,5,0
@@ -0,0 +1,10 @@
1
+ # Foo class
2
+ class Foo
3
+ def initialize
4
+ @foo = 'baz'
5
+ end
6
+
7
+ def bar
8
+ @foo
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'mocha'
4
+ require 'simplecov'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+ require 'simplecov-csv'
9
+
10
+ class Test::Unit::TestCase
11
+ end
@@ -0,0 +1,30 @@
1
+ require "#{File.dirname(__FILE__)}/helper"
2
+
3
+ class SimplecovCsvFormatterTest < Test::Unit::TestCase
4
+ def test_format
5
+ SimpleCov.stubs( :coverage_path ).returns( "/tmp" )
6
+ SimpleCov::Formatter::CSVFormatter.stubs( :result_file_name ).returns( 'coverage_test_results.csv' )
7
+ if File.exists?( "/#{SimpleCov.coverage_path}/#{SimpleCov::Formatter::CSVFormatter.result_file_name}" )
8
+ File.delete( "/#{SimpleCov.coverage_path}/#{SimpleCov::Formatter::CSVFormatter.result_file_name}" )
9
+ end
10
+
11
+ @original_result = {
12
+ source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
13
+ source_fixture( 'app/models/user.rb' ) => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
14
+ source_fixture( 'app/controllers/sample_controller.rb' ) => [nil, 1, 1, 1, nil, nil, 0, 0, nil, nil]
15
+ }
16
+
17
+ @result = SimpleCov::Result.new(@original_result)
18
+ csv_result = SimpleCov::Formatter::CSVFormatter.new().format( @result )
19
+
20
+ File.readlines( source_fixture( 'results.csv' ) ).each do |line|
21
+ assert_match( line.gsub( /^"\./, '' ), csv_result )
22
+ end
23
+
24
+ assert( File.exists?( "/#{SimpleCov.coverage_path}/#{SimpleCov::Formatter::CSVFormatter::RESULT_FILE_NAME}" ) )
25
+ end
26
+
27
+ def source_fixture( filename )
28
+ File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) )
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-csv
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - Fernando Guillen http://fernandoguillen.info
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-11 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: simplecov
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: CSV formatter for SimpleCov
36
+ email: fguillen.mail@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.rdoc
43
+ - lib/simplecov-csv.rb
44
+ files:
45
+ - Manifest
46
+ - README.rdoc
47
+ - Rakefile
48
+ - lib/simplecov-csv.rb
49
+ - test/fixtures/app/controllers/sample_controller.rb
50
+ - test/fixtures/app/models/user.rb
51
+ - test/fixtures/results.csv
52
+ - test/fixtures/sample.rb
53
+ - test/helper.rb
54
+ - test/simplecov-csv_test.rb
55
+ - simplecov-csv.gemspec
56
+ has_rdoc: true
57
+ homepage: http://github.com/fguillen/simplecov-csv
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options:
62
+ - --line-numbers
63
+ - --inline-source
64
+ - --title
65
+ - Simplecov-csv
66
+ - --main
67
+ - README.rdoc
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 11
85
+ segments:
86
+ - 1
87
+ - 2
88
+ version: "1.2"
89
+ requirements: []
90
+
91
+ rubyforge_project: simplecov-csv
92
+ rubygems_version: 1.3.7
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: CSV formatter for SimpleCov
96
+ test_files:
97
+ - test/simplecov-csv_test.rb