simplecov-cobertura 1.0.0 → 1.0.1
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 +4 -4
- data/lib/simplecov-cobertura.rb +46 -30
- data/simplecov-cobertura.gemspec +1 -1
- data/test/simplecov-cobertura_test.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d7c7d11c3b4ce40568ebab85bcd7b30ca458e9f
|
4
|
+
data.tar.gz: da1e2eb057565a9c7313f44d8ca6583862fbef31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b20ac65140f5f376fd0c736ef55f23b7833d5e9d9017d8f440d6431144f5987a038410dc9bb2fb4f212aa0385547a221af78025247024dab8b88367a20d23f09
|
7
|
+
data.tar.gz: 2efab639d9a76e680154c03e7551037561f373d697ff83e6d01b7b8860296e8a62525c4af9793e04a334b67e8567a7ed2046e75b9e8e3fc3b5becee9338689cf
|
data/lib/simplecov-cobertura.rb
CHANGED
@@ -18,46 +18,25 @@ class SimpleCov::Formatter::CoberturaFormatter
|
|
18
18
|
|
19
19
|
private
|
20
20
|
def result_to_xml(result)
|
21
|
-
root_dir = SimpleCov.root
|
22
|
-
|
23
21
|
doc = LibXML::XML::Document.new()
|
24
22
|
doc.root = LibXML::XML::Node.new('coverage')
|
25
23
|
coverage = doc.root
|
26
24
|
|
27
|
-
coverage
|
28
|
-
coverage['branch-rate'] = '0'
|
29
|
-
coverage['lines-covered'] = result.covered_lines.to_s
|
30
|
-
coverage['lines-valid'] = (result.covered_lines + result.missed_lines).to_s
|
31
|
-
coverage['branches-covered'] = '0'
|
32
|
-
coverage['branches-valid'] = '0'
|
33
|
-
coverage['branch-rate'] = '0'
|
34
|
-
coverage['complexity'] = '0'
|
35
|
-
coverage['version'] = '0'
|
36
|
-
coverage['timestamp'] = Time.now.to_i.to_s
|
25
|
+
set_coverage_attributes(coverage, result)
|
37
26
|
|
38
27
|
coverage << sources = LibXML::XML::Node.new('sources')
|
39
28
|
sources << source = LibXML::XML::Node.new('source')
|
40
|
-
source <<
|
29
|
+
source << SimpleCov.root
|
41
30
|
|
42
31
|
coverage << packages = LibXML::XML::Node.new('packages')
|
43
32
|
packages << package = LibXML::XML::Node.new('package')
|
44
|
-
package
|
45
|
-
package['line-rate'] = (result.covered_percent/100).round(2).to_s
|
46
|
-
package['branch-rate'] = '0'
|
47
|
-
package['complexity'] = '0'
|
33
|
+
set_package_attributes(package, result)
|
48
34
|
|
49
35
|
package << classes = LibXML::XML::Node.new('classes')
|
50
36
|
|
51
37
|
result.files.each do |file|
|
52
|
-
filename = file.filename
|
53
|
-
path = filename.gsub(File.join(root_dir, ''), '')
|
54
|
-
|
55
38
|
classes << class_ = LibXML::XML::Node.new('class')
|
56
|
-
class_
|
57
|
-
class_['filename'] = path
|
58
|
-
class_['line-rate'] = (file.covered_percent/100).round(2).to_s
|
59
|
-
class_['branch-rate'] = '0'
|
60
|
-
class_['complexity'] = '0'
|
39
|
+
set_class_attributes(class_, file)
|
61
40
|
|
62
41
|
class_ << methods = LibXML::XML::Node.new('methods')
|
63
42
|
class_ << lines = LibXML::XML::Node.new('lines')
|
@@ -65,15 +44,52 @@ class SimpleCov::Formatter::CoberturaFormatter
|
|
65
44
|
file.lines.each do |file_line|
|
66
45
|
if file_line.covered? || file_line.missed?
|
67
46
|
lines << line = LibXML::XML::Node.new('line')
|
68
|
-
line
|
69
|
-
line['branch'] = 'false'
|
70
|
-
line['hits'] = file_line.coverage.to_s
|
47
|
+
set_line_attributes(line, file_line)
|
71
48
|
end
|
72
49
|
end
|
73
50
|
end
|
74
51
|
|
75
|
-
|
76
|
-
|
52
|
+
set_xml_head(doc.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_coverage_attributes(coverage, result)
|
56
|
+
coverage['line-rate'] = (result.covered_percent/100).round(2).to_s
|
57
|
+
coverage['branch-rate'] = '0'
|
58
|
+
coverage['lines-covered'] = result.covered_lines.to_s
|
59
|
+
coverage['lines-valid'] = (result.covered_lines + result.missed_lines).to_s
|
60
|
+
coverage['branches-covered'] = '0'
|
61
|
+
coverage['branches-valid'] = '0'
|
62
|
+
coverage['branch-rate'] = '0'
|
63
|
+
coverage['complexity'] = '0'
|
64
|
+
coverage['version'] = '0'
|
65
|
+
coverage['timestamp'] = Time.now.to_i.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_package_attributes(package, result)
|
69
|
+
package['name'] = 'simplecov-cobertura'
|
70
|
+
package['line-rate'] = (result.covered_percent/100).round(2).to_s
|
71
|
+
package['branch-rate'] = '0'
|
72
|
+
package['complexity'] = '0'
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_class_attributes(class_, file)
|
76
|
+
filename = file.filename
|
77
|
+
path = filename.gsub(File.join(SimpleCov.root, ''), '')
|
78
|
+
class_['name'] = File.basename(filename, '.*')
|
79
|
+
class_['filename'] = path
|
80
|
+
class_['line-rate'] = (file.covered_percent/100).round(2).to_s
|
81
|
+
class_['branch-rate'] = '0'
|
82
|
+
class_['complexity'] = '0'
|
83
|
+
end
|
84
|
+
|
85
|
+
def set_line_attributes(line, file_line)
|
86
|
+
line['number'] = file_line.line_number.to_s
|
87
|
+
line['branch'] = 'false'
|
88
|
+
line['hits'] = file_line.coverage.to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
def set_xml_head(xml)
|
92
|
+
lines = xml.split("\n")
|
77
93
|
lines.insert(1, "<!DOCTYPE coverage SYSTEM \"#{DTD_URL}\">")
|
78
94
|
lines.insert(2, '<!-- Generated by simplecov-cobertura -->')
|
79
95
|
lines.join("\n")
|
data/simplecov-cobertura.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'simplecov-cobertura'
|
7
|
-
spec.version = '1.0.
|
7
|
+
spec.version = '1.0.1'
|
8
8
|
spec.authors = ['Jesse Bowes']
|
9
9
|
spec.email = ['jbowes@dashingrocket.com']
|
10
10
|
spec.summary = 'SimpleCov Cobertura Formatter'
|
@@ -24,6 +24,8 @@ class CoberturaFormatterTest < Test::Unit::TestCase
|
|
24
24
|
def test_format_dtd_validates
|
25
25
|
xml = @formatter.format(@result)
|
26
26
|
|
27
|
+
STDERR.puts xml
|
28
|
+
|
27
29
|
dtd_text = open(SimpleCov::Formatter::CoberturaFormatter::DTD_URL) { |io| io.read }
|
28
30
|
dtd = LibXML::XML::Dtd.new(dtd_text)
|
29
31
|
doc = LibXML::XML::Document.string(xml)
|