simplecov-cobertura 1.2.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTEzZGFiNGNhYjhkYjAyNDBiNWZhNTc2NGNhMTIyZWRjNGRhZmE2Mg==
5
- data.tar.gz: !binary |-
6
- YmU3ZWJkMTQ3YmQ3ZjI4MzIzYWIzYTNmYmI5YjJmZjM5NjU1ZjFkNg==
2
+ SHA256:
3
+ metadata.gz: 17f485d57f75e4ffb86132662c75714f039b493fb03cab4fa1875fe1dd01fd32
4
+ data.tar.gz: 5d6b51cfcc1bbe0dec7f8ac0a9a051c9e67064b185b280725bc101667f42ebd7
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDVmNjdkZGYxMDNjMTRkNzk1MWEyNmJjMDY5YjY5ZTdjZTliYzBiOGEyODZm
10
- ZjlkNDQwNmUzOTY5NmE4NWIwMDU4YjA0MDg5M2ZmZjUxNDQ2NWVhZjUxMjVh
11
- Mjc2MDhjMDkxZjMzNDA4YjZmNTZjN2M5NWQzMjdkYjkyM2ZhOWQ=
12
- data.tar.gz: !binary |-
13
- NjU4ODZjMjlhMTI0MGVjOTZlZTc0M2Q4NjUwZDVlYTE0MzA4ZmNiNWI4OTFl
14
- ZmVlOWJlYTViMjg3ODk3MWZlODg3ZjllZjI0ZTY2NDIxOWUzMDRmNTllOTcz
15
- MzY1MWIwZjNhMmUxNjQ5YzE3MmQzNTljZjllNmEzODRhZTAwODU=
6
+ metadata.gz: 996338e8d5fb7ea79e3f912e8734e0ae0795ff3ffe41bf1e00ef722f4ff50b423d8a2e95d3bf7e7cfd18179785d5dcd5bdb4318ed5f91bb912b10341c5b91d78
7
+ data.tar.gz: 98adbf973e7c454ac7645556cbf1e83b3c50b9071523e5c536fbdad86f53eb48afbdbcde6212f9e699a692bce226a19b094a0e8823348f2fc0a49f4032150c24
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.7
6
+ - 2.6
7
+ - 2.5
8
+ - 2.4
9
+ - 2.3
10
+ - 2.2
11
+ - 2.1
12
+ - 2.0
13
+ - 1.9
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # simplecov-cobertura
2
- [![Build Status](https://api.shippable.com/projects/549b1fbbd46935d5fbc0f9f3/badge?branchName=master)](https://app.shippable.com/projects/549b1fbbd46935d5fbc0f9f3/builds/latest) [![Gem Version](https://badge.fury.io/rb/simplecov-cobertura.svg)](http://badge.fury.io/rb/simplecov-cobertura) [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/simplecov-cobertura?type=total)](https://rubygems.org/gems/simplecov-cobertura)
2
+ [![Build Status](https://travis-ci.com/dashingrocket/simplecov-cobertura.svg?branch=master)](https://travis-ci.com/dashingrocket/simplecov-cobertura) [![Gem Version](https://badge.fury.io/rb/simplecov-cobertura.svg)](http://badge.fury.io/rb/simplecov-cobertura) [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/simplecov-cobertura?type=total)](https://rubygems.org/gems/simplecov-cobertura)
3
3
 
4
4
  Produces [Cobertura](http://cobertura.sourceforge.net/) formatted XML from [SimpleCov](https://github.com/colszowka/simplecov).
5
5
 
@@ -32,11 +32,15 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
32
32
 
33
33
  ## Continuous Integration
34
34
  Tested in a CI environment against the following Ruby versions:
35
- * 2.3.1
36
- * 2.2.5
37
- * 2.1.10
38
- * 1.9.3
39
- * JRuby (1.9 mode)
35
+ * 2.7
36
+ * 2.6
37
+ * 2.5
38
+ * 2.4
39
+ * 2.3
40
+ * 2.2
41
+ * 2.1
42
+ * 2.0
43
+ * 1.9
40
44
 
41
45
  ## Known Limitations
42
46
  * No support for branch coverage
@@ -46,6 +50,11 @@ Tested in a CI environment against the following Ruby versions:
46
50
  * Sean Clemmer
47
51
  * Ivailo Petrov
48
52
  * Rob Lester
53
+ * Denis <Zaratan> Pasin
54
+ * Jesper Rønn-Jensen
55
+ * Pramod Shinde
56
+ * Magnus Bergmark
57
+ * Peter Leitzen
49
58
 
50
59
  ## Contributing
51
60
 
@@ -56,7 +65,7 @@ Tested in a CI environment against the following Ruby versions:
56
65
  5. Create a new Pull Request
57
66
 
58
67
  ## License
59
- Copyright 2016 Dashing Rocket, Ltd.
68
+ Copyright 2020 Dashing Rocket, Ltd.
60
69
 
61
70
  Licensed under the Apache License, Version 2.0 (the "License");
62
71
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'ci/reporter/rake/test_unit'
4
3
 
5
4
  Rake::TestTask.new do |t|
6
5
  t.libs << 'test'
@@ -8,4 +7,4 @@ Rake::TestTask.new do |t|
8
7
  end
9
8
 
10
9
  desc 'Run tests'
11
- task :default => ['ci:setup:testunit', :test]
10
+ task :default => [:test]
@@ -1,11 +1,14 @@
1
+ require 'simplecov'
2
+
1
3
  require 'rexml/document'
2
4
  require 'rexml/element'
5
+ require 'pathname'
6
+
7
+ require_relative 'simplecov-cobertura/version'
3
8
 
4
9
  module SimpleCov
5
10
  module Formatter
6
11
  class CoberturaFormatter
7
- VERSION = '1.2.0'
8
-
9
12
  RESULT_FILE_NAME = 'coverage.xml'
10
13
  DTD_URL = 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'
11
14
 
@@ -20,7 +23,7 @@ module SimpleCov
20
23
 
21
24
  xml_str = string_io.string
22
25
  File.write(result_path, xml_str)
23
- puts "Coverage report generated for #{result.command_name} to #{result_path}"
26
+ puts "Coverage report generated for #{result.command_name} to #{result_path}. #{coverage_output(result)}"
24
27
  xml_str
25
28
  end
26
29
 
@@ -92,9 +95,8 @@ module SimpleCov
92
95
 
93
96
  def set_class_attributes(class_, file)
94
97
  filename = file.filename
95
- path = filename[SimpleCov.root.length+1..-1]
96
98
  class_.attributes['name'] = File.basename(filename, '.*')
97
- class_.attributes['filename'] = path
99
+ class_.attributes['filename'] = resolve_filename(filename)
98
100
  class_.attributes['line-rate'] = (file.covered_percent/100).round(2).to_s
99
101
  class_.attributes['branch-rate'] = '0'
100
102
  class_.attributes['complexity'] = '0'
@@ -112,6 +114,18 @@ module SimpleCov
112
114
  lines << "<!-- Generated by simplecov-cobertura version #{VERSION} (https://github.com/dashingrocket/simplecov-cobertura) -->"
113
115
  lines.join("\n")
114
116
  end
117
+
118
+ def coverage_output(result)
119
+ "#{result.covered_lines} / #{result.covered_lines + result.missed_lines} LOC (#{result.covered_percent.round(2)}%) covered."
120
+ end
121
+
122
+ def resolve_filename(filename)
123
+ Pathname.new(filename).relative_path_from(project_root).to_s
124
+ end
125
+
126
+ def project_root
127
+ @project_root ||= Pathname.new(SimpleCov.root)
128
+ end
115
129
  end
116
130
  end
117
131
  end
@@ -0,0 +1,7 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class CoberturaFormatter
4
+ VERSION = '1.4.2'
5
+ end
6
+ end
7
+ end
@@ -2,7 +2,7 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
- require 'simplecov-cobertura'
5
+ require 'simplecov-cobertura/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'simplecov-cobertura'
@@ -20,11 +20,17 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.7'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'ci_reporter_test_unit', '~> 1.0'
26
- spec.add_development_dependency 'nokogiri', '~> 1.6'
23
+ spec.add_development_dependency 'test-unit', '~> 3.2'
24
+ spec.add_development_dependency 'nokogiri', '~> 1.0'
27
25
 
28
26
  spec.add_dependency 'simplecov', '~> 0.8'
29
- spec.add_dependency 'json', '~> 1.8'
27
+
28
+ if RUBY_VERSION < '2.0'
29
+ spec.add_dependency 'json', '< 2.3.0'
30
+ spec.add_development_dependency 'rake', '~> 12.0', '< 12.3'
31
+ elsif RUBY_VERSION < '2.2'
32
+ spec.add_development_dependency 'rake', '~> 12.0'
33
+ else
34
+ spec.add_development_dependency 'rake', '~> 13.0'
35
+ end
30
36
  end
@@ -7,9 +7,8 @@ require 'simplecov'
7
7
  require 'simplecov-cobertura'
8
8
 
9
9
  class CoberturaFormatterTest < Test::Unit::TestCase
10
-
11
10
  def setup
12
- @result = SimpleCov::Result.new("#{__FILE__}" => [1,2])
11
+ @result = SimpleCov::Result.new({ "#{__FILE__}" => [1,2] })
13
12
  @formatter = SimpleCov::Formatter::CoberturaFormatter.new
14
13
  end
15
14
 
@@ -24,6 +23,13 @@ class CoberturaFormatterTest < Test::Unit::TestCase
24
23
  assert_equal(xml, IO.read(result_path))
25
24
  end
26
25
 
26
+ def test_terminal_output
27
+ output, _ = capture_output { @formatter.format(@result) }
28
+ result_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::CoberturaFormatter::RESULT_FILE_NAME)
29
+ output_regex = /Coverage report generated for #{@result.command_name} to #{result_path}. (.*) covered./
30
+ assert_match(output_regex, output)
31
+ end
32
+
27
33
  def test_format_dtd_validates
28
34
  xml = @formatter.format(@result)
29
35
  options = Nokogiri::XML::ParseOptions::DTDLOAD
@@ -128,4 +134,21 @@ class CoberturaFormatterTest < Test::Unit::TestCase
128
134
  assert_equal 'false', last_line.attribute('branch').value
129
135
  assert_equal '2', last_line.attribute('hits').value
130
136
  end
131
- end
137
+
138
+ def test_supports_root_project_path
139
+ old_root = SimpleCov.root
140
+ SimpleCov.root('/')
141
+ expected_base = old_root[1..-1] # Remove leading "/"
142
+
143
+ xml = @formatter.format(@result)
144
+ doc = Nokogiri::XML::Document.parse(xml)
145
+
146
+ classes = doc.xpath '/coverage/packages/package/classes/class'
147
+ assert_equal 1, classes.length
148
+ clazz = classes.first
149
+ assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
150
+ assert_equal "#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
151
+ ensure
152
+ SimpleCov.root(old_root)
153
+ end
154
+ end
metadata CHANGED
@@ -1,99 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-cobertura
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Bowes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '3.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: ci_reporter_test_unit
28
+ name: nokogiri
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ~>
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
33
  version: '1.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ~>
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '1.0'
55
- - !ruby/object:Gem::Dependency
56
- name: nokogiri
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.6'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '1.6'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: simplecov
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
- - - ~>
45
+ - - "~>"
74
46
  - !ruby/object:Gem::Version
75
47
  version: '0.8'
76
48
  type: :runtime
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
- - - ~>
52
+ - - "~>"
81
53
  - !ruby/object:Gem::Version
82
54
  version: '0.8'
83
55
  - !ruby/object:Gem::Dependency
84
- name: json
56
+ name: rake
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
- - - ~>
59
+ - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '1.8'
90
- type: :runtime
61
+ version: '13.0'
62
+ type: :development
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
- - - ~>
66
+ - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '1.8'
68
+ version: '13.0'
97
69
  description: Produces Cobertura XML formatted output from SimpleCov
98
70
  email:
99
71
  - jbowes@dashingrocket.com
@@ -101,37 +73,37 @@ executables: []
101
73
  extensions: []
102
74
  extra_rdoc_files: []
103
75
  files:
104
- - .gitignore
76
+ - ".gitignore"
77
+ - ".travis.yml"
105
78
  - Gemfile
106
79
  - LICENSE
107
80
  - README.md
108
81
  - Rakefile
109
82
  - lib/simplecov-cobertura.rb
110
- - shippable.yml
83
+ - lib/simplecov-cobertura/version.rb
111
84
  - simplecov-cobertura.gemspec
112
85
  - test/simplecov-cobertura_test.rb
113
86
  homepage: https://github.com/dashingrocket/simplecov-cobertura
114
87
  licenses:
115
88
  - Apache-2.0
116
89
  metadata: {}
117
- post_install_message:
90
+ post_install_message:
118
91
  rdoc_options: []
119
92
  require_paths:
120
93
  - lib
121
94
  required_ruby_version: !ruby/object:Gem::Requirement
122
95
  requirements:
123
- - - ! '>='
96
+ - - ">="
124
97
  - !ruby/object:Gem::Version
125
98
  version: 1.9.3
126
99
  required_rubygems_version: !ruby/object:Gem::Requirement
127
100
  requirements:
128
- - - ! '>='
101
+ - - ">="
129
102
  - !ruby/object:Gem::Version
130
103
  version: '0'
131
104
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.4.6
134
- signing_key:
105
+ rubygems_version: 3.1.2
106
+ signing_key:
135
107
  specification_version: 4
136
108
  summary: SimpleCov Cobertura Formatter
137
109
  test_files:
@@ -1,20 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.3.1
5
- - 2.2.5
6
- - 2.1.10
7
- - 1.9.3
8
- - jruby-19mode
9
-
10
- env:
11
- - CI_REPORTS=shippable/testresults COVERAGE_REPORTS=shippable/codecoverage
12
-
13
- cache: true
14
-
15
- notifications:
16
- email:
17
- recipients:
18
- - jbowes@dashingrocket.com
19
- on_success: change
20
- on_failure: always