simplecov-lcov 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -14
- data/README.markdown +13 -0
- data/VERSION +1 -1
- data/lib/simplecov-lcov.rb +32 -6
- data/simplecov-lcov.gemspec +2 -2
- data/spec/fixtures/lcov/spec-fixtures-app-models-user.rb.lcov +2 -2
- data/spec/simplecov-lcov_spec.rb +64 -18
- data/spec/spec_helper.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34cd28b3146b636fe1e78b3c19b73f575b223a93
|
4
|
+
data.tar.gz: db1b370802df784c9d861930195785b140d64ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c949498594b903c6f8be29e0c52579764cca1e88da563c55f4c9534c3b6ae33590fbc38dd6fdba76ed31c646a910f8a4a4c6bc2ced874fae83c560ecec6e2fb2
|
7
|
+
data.tar.gz: b1b8c0f889eb52df9453544bb992f56d3e859d8d4e16bb452b43924162f8b89ea82e45039a521e8a0427f33fa56cb8c9367fb71ac2188ef3f4da0abcc0e2c2d2
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.
|
4
|
+
activesupport (4.1.1)
|
5
5
|
i18n (~> 0.6, >= 0.6.9)
|
6
|
-
|
7
|
-
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
8
|
thread_safe (~> 0.1)
|
9
|
-
tzinfo (~>
|
9
|
+
tzinfo (~> 1.1)
|
10
10
|
addressable (2.3.6)
|
11
11
|
builder (3.2.2)
|
12
12
|
coveralls (0.7.0)
|
@@ -46,7 +46,7 @@ GEM
|
|
46
46
|
jwt (1.0.0)
|
47
47
|
mime-types (2.3)
|
48
48
|
mini_portile (0.6.0)
|
49
|
-
minitest (
|
49
|
+
minitest (5.3.4)
|
50
50
|
multi_json (1.10.1)
|
51
51
|
multi_xml (0.5.5)
|
52
52
|
multipart-post (2.0.0)
|
@@ -64,14 +64,18 @@ GEM
|
|
64
64
|
json (~> 1.4)
|
65
65
|
rest-client (1.6.7)
|
66
66
|
mime-types (>= 1.16)
|
67
|
-
rspec (
|
68
|
-
rspec-core (~>
|
69
|
-
rspec-expectations (~>
|
70
|
-
rspec-mocks (~>
|
71
|
-
rspec-core (
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
rspec (3.0.0)
|
68
|
+
rspec-core (~> 3.0.0)
|
69
|
+
rspec-expectations (~> 3.0.0)
|
70
|
+
rspec-mocks (~> 3.0.0)
|
71
|
+
rspec-core (3.0.0)
|
72
|
+
rspec-support (~> 3.0.0)
|
73
|
+
rspec-expectations (3.0.0)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.0.0)
|
76
|
+
rspec-mocks (3.0.0)
|
77
|
+
rspec-support (~> 3.0.0)
|
78
|
+
rspec-support (3.0.0)
|
75
79
|
simplecov (0.8.2)
|
76
80
|
docile (~> 1.1.0)
|
77
81
|
multi_json
|
@@ -82,7 +86,8 @@ GEM
|
|
82
86
|
thor (0.19.1)
|
83
87
|
thread_safe (0.3.4)
|
84
88
|
tins (1.3.0)
|
85
|
-
tzinfo (
|
89
|
+
tzinfo (1.2.1)
|
90
|
+
thread_safe (~> 0.1)
|
86
91
|
|
87
92
|
PLATFORMS
|
88
93
|
ruby
|
data/README.markdown
CHANGED
@@ -4,12 +4,25 @@ Custom SimpleCov formatter to generate a lcov style coverage.
|
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/fortissimo1997/simplecov-lcov.svg?branch=master)](https://travis-ci.org/fortissimo1997/simplecov-lcov)
|
6
6
|
[![Coverage Status](https://img.shields.io/coveralls/fortissimo1997/simplecov-lcov.svg)](https://coveralls.io/r/fortissimo1997/simplecov-lcov)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/simplecov-lcov.svg)](http://badge.fury.io/rb/simplecov-lcov)
|
7
8
|
|
8
9
|
## Usage
|
9
10
|
|
11
|
+
#### Output report per file.
|
12
|
+
|
13
|
+
```Ruby
|
14
|
+
require 'simplecov'
|
15
|
+
require 'simplecov-lcov'
|
16
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
17
|
+
SimpleCov.start
|
18
|
+
```
|
19
|
+
|
20
|
+
#### Output report as single file.
|
21
|
+
|
10
22
|
```Ruby
|
11
23
|
require 'simplecov'
|
12
24
|
require 'simplecov-lcov'
|
25
|
+
SimpleCov::Formatter::LcovFormatter.report_with_single_file = true
|
13
26
|
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
14
27
|
SimpleCov.start
|
15
28
|
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/simplecov-lcov.rb
CHANGED
@@ -11,16 +11,36 @@ module SimpleCov
|
|
11
11
|
# _result_ :: [SimpleCov::Result] abcoverage result instance.
|
12
12
|
def format(result)
|
13
13
|
create_output_directory!
|
14
|
-
|
14
|
+
if self.class.report_with_single_file?
|
15
|
+
write_lcov_to_single_file!(result.files)
|
16
|
+
else
|
17
|
+
result.files.each { |file| write_lcov!(file) }
|
18
|
+
end
|
15
19
|
|
16
20
|
puts "Lcov style coverage report generated for #{result.command_name} to #{SimpleCov::Formatter::LcovFormatter.output_directory}."
|
17
21
|
end
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
class << self
|
24
|
+
attr_writer :report_with_single_file
|
25
|
+
|
26
|
+
def report_with_single_file?
|
27
|
+
!!@report_with_single_file
|
28
|
+
end
|
29
|
+
|
30
|
+
# Output directory for generated files.
|
31
|
+
# ==== Return
|
32
|
+
# Path for output directory.
|
33
|
+
def output_directory
|
34
|
+
File.join(SimpleCov.coverage_path, 'lcov')
|
35
|
+
end
|
36
|
+
|
37
|
+
# Output path for single file report.
|
38
|
+
# ==== Return
|
39
|
+
# Path for output path of single file report.
|
40
|
+
def single_report_path
|
41
|
+
basename = Pathname.new(SimpleCov.root).basename.to_s
|
42
|
+
File.join(output_directory, "#{basename}.lcov")
|
43
|
+
end
|
24
44
|
end
|
25
45
|
|
26
46
|
private
|
@@ -36,6 +56,12 @@ module SimpleCov
|
|
36
56
|
end
|
37
57
|
end
|
38
58
|
|
59
|
+
def write_lcov_to_single_file!(files)
|
60
|
+
File.open(self.class.single_report_path, 'w') do |f|
|
61
|
+
files.each { |file| f.write format_file(file) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
39
65
|
def output_filename(filename)
|
40
66
|
filename.gsub("#{SimpleCov.root}/", '').gsub('/', '-')
|
41
67
|
.tap { |name| name << '.lcov' }
|
data/simplecov-lcov.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "simplecov-lcov"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["fortissimo1997"]
|
12
|
-
s.date = "2014-
|
12
|
+
s.date = "2014-06-02"
|
13
13
|
s.description = "Custom SimpleCov formatter to generate a lcov style coverage."
|
14
14
|
s.email = "fortissimo1997@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/simplecov-lcov_spec.rb
CHANGED
@@ -20,30 +20,76 @@ describe SimpleCov::Formatter::LcovFormatter do
|
|
20
20
|
SimpleCov::Result.new(simplecov_result_hash)
|
21
21
|
}
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
context 'generating report per file' do
|
24
|
+
before {
|
25
|
+
@output = capture(:stdout) do
|
26
|
+
SimpleCov::Formatter::LcovFormatter.new.format(simplecov_result)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
|
30
|
+
describe File do
|
31
|
+
it { expect(File).to exist(File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-hoge.rb.lcov')) }
|
32
|
+
it { expect(File).to exist(File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-app-models-user.rb.lcov')) }
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'spec-fixtures-hoge.rb.lcov' do
|
36
|
+
let(:output_path) {
|
37
|
+
File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-hoge.rb.lcov')
|
38
|
+
}
|
39
|
+
let(:fixture) {
|
40
|
+
File.read("#{File.dirname(__FILE__)}/fixtures/lcov/spec-fixtures-hoge.rb.lcov")
|
41
|
+
.gsub('/path/to/repository/spec', File.dirname(__FILE__))
|
42
|
+
}
|
43
|
+
it { expect(File.read(output_path)).to eq(fixture) }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'spec-fixtures-app-models-user.rb.lcov' do
|
47
|
+
let(:output_path) {
|
48
|
+
File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-app-models-user.rb.lcov')
|
49
|
+
}
|
50
|
+
let(:fixture) {
|
51
|
+
File.read("#{File.dirname(__FILE__)}/fixtures/lcov/spec-fixtures-app-models-user.rb.lcov")
|
52
|
+
.gsub('/path/to/repository/spec', File.dirname(__FILE__))
|
53
|
+
}
|
54
|
+
it { expect(File.read(output_path)).to eq(fixture) }
|
26
55
|
end
|
27
|
-
}
|
28
56
|
|
29
|
-
|
30
|
-
|
31
|
-
|
57
|
+
describe STDOUT do
|
58
|
+
it { expect(@output).to include('Lcov style coverage report') }
|
59
|
+
end
|
32
60
|
end
|
33
61
|
|
34
|
-
|
35
|
-
|
36
|
-
|
62
|
+
context 'generating single file report' do
|
63
|
+
before {
|
64
|
+
SimpleCov::Formatter::LcovFormatter.report_with_single_file = true
|
65
|
+
@output = capture(:stdout) do
|
66
|
+
SimpleCov::Formatter::LcovFormatter.new.format(simplecov_result)
|
67
|
+
end
|
37
68
|
}
|
38
|
-
let(:fixture) {
|
39
|
-
File.read("#{File.dirname(__FILE__)}/fixtures/lcov/spec-fixtures-hoge.rb.lcov")
|
40
|
-
.gsub('/path/to/repository/spec', File.dirname(__FILE__))
|
41
|
-
}
|
42
|
-
it { expect(File.read(output_path)).to eq(fixture) }
|
43
|
-
end
|
44
69
|
|
45
|
-
|
46
|
-
|
70
|
+
describe File do
|
71
|
+
it { expect(File).to exist(SimpleCov::Formatter::LcovFormatter.single_report_path) }
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'single_report_path' do
|
75
|
+
let(:output_path) {
|
76
|
+
SimpleCov::Formatter::LcovFormatter.single_report_path
|
77
|
+
}
|
78
|
+
let(:fixture_of_hoge) {
|
79
|
+
File.read("#{File.dirname(__FILE__)}/fixtures/lcov/spec-fixtures-hoge.rb.lcov")
|
80
|
+
.gsub('/path/to/repository/spec', File.dirname(__FILE__))
|
81
|
+
}
|
82
|
+
let(:fixture_of_user) {
|
83
|
+
File.read("#{File.dirname(__FILE__)}/fixtures/lcov/spec-fixtures-app-models-user.rb.lcov")
|
84
|
+
.gsub('/path/to/repository/spec', File.dirname(__FILE__))
|
85
|
+
}
|
86
|
+
it { expect(File.read(output_path)).to match(fixture_of_hoge) }
|
87
|
+
it { expect(File.read(output_path)).to match(fixture_of_user) }
|
88
|
+
end
|
89
|
+
|
90
|
+
describe STDOUT do
|
91
|
+
it { expect(@output).to include('Lcov style coverage report') }
|
92
|
+
end
|
47
93
|
end
|
48
94
|
end
|
49
95
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
require 'coveralls'
|
3
|
+
require 'pathname'
|
4
|
+
require 'fileutils'
|
3
5
|
|
4
6
|
module SimpleCov::Configuration
|
5
7
|
def clean_filters
|
@@ -31,5 +33,13 @@ require 'simplecov-lcov'
|
|
31
33
|
# Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
32
34
|
|
33
35
|
RSpec.configure do |config|
|
34
|
-
|
36
|
+
config.before(:each) do
|
37
|
+
if Dir.exist?(SimpleCov::Formatter::LcovFormatter.output_directory)
|
38
|
+
FileUtils
|
39
|
+
.remove_dir(
|
40
|
+
SimpleCov::Formatter::LcovFormatter.output_directory,
|
41
|
+
true
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
35
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-lcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fortissimo1997
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|