simplecov-lcov 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e362d445284dfde3e79ee49d52d1c9528bee4539
4
- data.tar.gz: bb9288acb35d223bfd8d14fd19a00506a2792963
3
+ metadata.gz: 34cd28b3146b636fe1e78b3c19b73f575b223a93
4
+ data.tar.gz: db1b370802df784c9d861930195785b140d64ffa
5
5
  SHA512:
6
- metadata.gz: 2a6d42ca2c75f684be4f54a7e3300b70df0ffeaf78e5c2249933818a73f6d2cdda6e3e2d41ae4c11679687b8760159d2289eb75204b47ab32d4ab042ce87d762
7
- data.tar.gz: 36c3081fc6a3c4a608e49c4a1f6f895f63d4403e09c20d6c15d069ba152ebffd00206fd36fcfab050709b1da5c2f68e890277f3d5033a9b3e648c45e33882463
6
+ metadata.gz: c949498594b903c6f8be29e0c52579764cca1e88da563c55f4c9534c3b6ae33590fbc38dd6fdba76ed31c646a910f8a4a4c6bc2ced874fae83c560ecec6e2fb2
7
+ data.tar.gz: b1b8c0f889eb52df9453544bb992f56d3e859d8d4e16bb452b43924162f8b89ea82e45039a521e8a0427f33fa56cb8c9367fb71ac2188ef3f4da0abcc0e2c2d2
@@ -1,12 +1,12 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (4.0.4)
4
+ activesupport (4.1.1)
5
5
  i18n (~> 0.6, >= 0.6.9)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
8
  thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
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 (4.7.5)
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 (2.14.1)
68
- rspec-core (~> 2.14.0)
69
- rspec-expectations (~> 2.14.0)
70
- rspec-mocks (~> 2.14.0)
71
- rspec-core (2.14.8)
72
- rspec-expectations (2.14.5)
73
- diff-lcs (>= 1.1.3, < 2.0)
74
- rspec-mocks (2.14.6)
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 (0.3.39)
89
+ tzinfo (1.2.1)
90
+ thread_safe (~> 0.1)
86
91
 
87
92
  PLATFORMS
88
93
  ruby
@@ -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.4
1
+ 0.2.0
@@ -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
- result.files.each { |file| write_lcov!(file) }
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
- # Output directory for generated files.
20
- # ==== Return
21
- # Path for output directory.
22
- def self.output_directory
23
- File.join(SimpleCov.coverage_path, 'lcov')
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' }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "simplecov-lcov"
8
- s.version = "0.1.4"
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-05-30"
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 = [
@@ -3,11 +3,11 @@ DA:4,2
3
3
  DA:5,2
4
4
  DA:6,2
5
5
  DA:7,2
6
- DA:9:0
6
+ DA:9,0
7
7
  DA:10,0
8
8
  DA:11,0
9
9
  DA:13,1
10
10
  DA:14,0
11
11
  DA:15,0
12
- DA:16:1
12
+ DA:16,1
13
13
  end_of_record
@@ -20,30 +20,76 @@ describe SimpleCov::Formatter::LcovFormatter do
20
20
  SimpleCov::Result.new(simplecov_result_hash)
21
21
  }
22
22
 
23
- before {
24
- @output = capture(:stdout) do
25
- SimpleCov::Formatter::LcovFormatter.new.format(simplecov_result)
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
- describe File do
30
- it { expect(File).to exist(File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-hoge.rb.lcov')) }
31
- it { expect(File).to exist(File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-app-models-user.rb.lcov')) }
57
+ describe STDOUT do
58
+ it { expect(@output).to include('Lcov style coverage report') }
59
+ end
32
60
  end
33
61
 
34
- describe 'spec-fixtures-hoge.rb.lcov' do
35
- let(:output_path) {
36
- File.join(SimpleCov::Formatter::LcovFormatter.output_directory, 'spec-fixtures-hoge.rb.lcov')
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
- describe STDOUT do
46
- it { expect(@output).to include('Lcov style coverage report') }
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
 
@@ -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.1.4
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-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec