simplecov-phpunit 0.3.0 → 0.4.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 +4 -4
- data/README.md +2 -2
- data/assets/{css/style.css → style.css} +0 -0
- data/lib/simplecov-phpunit/simplecov-phpunit.rb +189 -172
- data/lib/simplecov-phpunit/version.rb +2 -2
- metadata +3 -11
- data/assets/css/bootstrap.min.css +0 -5
- data/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/assets/fonts/glyphicons-halflings-regular.svg +0 -288
- data/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/assets/js/bootstrap.min.js +0 -7
- data/assets/js/jquery.min.js +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e27b3f5fb187ab7e4111b1bbc570e5762e472d7e
|
4
|
+
data.tar.gz: f6274cd06ed99c24dbf081ee6a1bd7101b3d70cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf79f212dd2ddcff3634d92488f11fba7cef8acc6719dd6713978712224869ac82b0f9045d223523dbfc90b015b180b9169214eb504304c14f41a4d16cce3b3
|
7
|
+
data.tar.gz: 5339b0a04ff840d18027a27c3fb0d0a2d1cb3a721cdfd07cc67e96cbd3800e0a4a8aba1491d73723469c1d6244fefcd58c8ad86505003961e0977b199d62fecf
|
data/README.md
CHANGED
@@ -13,12 +13,12 @@ https://rubygems.org/gems/simplecov-phpunit
|
|
13
13
|
|
14
14
|
or via `Gemfile`:
|
15
15
|
|
16
|
-
gem 'simplecov-phpunit', '~>0.
|
16
|
+
gem 'simplecov-phpunit', '~>0.4'
|
17
17
|
|
18
18
|
or via `.gemspec`:
|
19
19
|
|
20
20
|
spec.add_development_dependency 'simplecov', '~>0.12'
|
21
|
-
spec.add_development_dependency 'simplecov-phpunit', '~>0.
|
21
|
+
spec.add_development_dependency 'simplecov-phpunit', '~>0.4'
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
File without changes
|
@@ -8,24 +8,36 @@ module SimpleCov
|
|
8
8
|
|
9
9
|
class PHPUnit < SimpleCov::Formatter::SimpleFormatter
|
10
10
|
|
11
|
-
def initialize
|
11
|
+
def initialize
|
12
12
|
super()
|
13
13
|
|
14
14
|
@base_dir_path = Dir.pwd
|
15
15
|
@coverage_dir_path = File.expand_path('coverage', @base_dir_path)
|
16
|
-
|
16
|
+
assets_dst_path = File.expand_path('_assets', @coverage_dir_path)
|
17
17
|
|
18
|
-
simplecov_phpunit_version = Gem::Specification.find_by_name('simplecov-phpunit').version.to_s
|
19
|
-
@version_html = %{<a href="https://github.com/TheFox/simplecov-phpunit">SimpleCov PHPUnit Formatter #{simplecov_phpunit_version}</a>}
|
20
|
-
@ruby_version_html = %{<a href="https://www.ruby-lang.org/en/">Ruby #{RUBY_VERSION}</a>}
|
21
18
|
|
22
|
-
simplecov_version = Gem::Specification.find_by_name('simplecov').version.to_s
|
23
|
-
@simplecov_version_html = %{<a href="https://github.com/colszowka/simplecov">SimpleCov #{simplecov_version}</a>}
|
24
19
|
|
25
|
-
|
26
|
-
assets_src_path = File.expand_path('assets', full_gem_path)
|
27
|
-
|
20
|
+
simplecov_phpunit_gem = Gem::Specification.find_by_name('simplecov-phpunit')
|
21
|
+
assets_src_path = File.expand_path('assets', simplecov_phpunit_gem.full_gem_path)
|
22
|
+
@simplecov_phpunit_version_html = %(<a href="https://github.com/TheFox/simplecov-phpunit">SimpleCov PHPUnit Formatter #{simplecov_phpunit_gem.version}</a>)
|
23
|
+
@ruby_version_html = %(<a href="https://www.ruby-lang.org/en/">Ruby #{RUBY_VERSION}</a>)
|
24
|
+
|
25
|
+
simplecov_gem = Gem::Specification.find_by_name('simplecov')
|
26
|
+
@simplecov_version_html = %(<a href="https://github.com/colszowka/simplecov">SimpleCov #{simplecov_gem.version}</a>)
|
27
|
+
|
28
|
+
|
29
|
+
FileUtils.rm_rf(assets_dst_path)
|
28
30
|
FileUtils.cp_r(assets_src_path, assets_dst_path)
|
31
|
+
|
32
|
+
|
33
|
+
@bootstrap_css_html = %(<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">)
|
34
|
+
|
35
|
+
@style_css_href = '_assets/style.css'
|
36
|
+
@style_css_html = %(<link href="#{@style_css_href}" rel="stylesheet" />)
|
37
|
+
|
38
|
+
@jquery_js_html = %(<script src="http://code.jquery.com/jquery-1.12.4.min.js" crossorigin="anonymous"></script>)
|
39
|
+
|
40
|
+
@bootstrap_js_html = %(<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>)
|
29
41
|
end
|
30
42
|
|
31
43
|
def format(result)
|
@@ -35,48 +47,51 @@ module SimpleCov
|
|
35
47
|
total_status = status_by_percent(result.files.covered_percent)
|
36
48
|
total_percent_f = '%.2f' % result.files.covered_percent
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
50
|
+
index_html = ''
|
51
|
+
index_html << <<-EOHTML
|
52
|
+
<!DOCTYPE html>
|
53
|
+
<html lang="en">
|
54
|
+
<head>
|
55
|
+
<meta charset="UTF-8" />
|
56
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
57
|
+
|
58
|
+
<title>Code Coverage for #{@base_dir_path}</title>
|
59
|
+
|
60
|
+
#{@bootstrap_css_html}
|
61
|
+
#{@style_css_html}
|
62
|
+
|
63
|
+
</head>
|
64
|
+
<div class="container">
|
65
|
+
<table class="table table-bordered">
|
66
|
+
<thead>
|
67
|
+
<tr>
|
68
|
+
<td> </td>
|
69
|
+
<td colspan="3"><div align="center"><strong>Code Coverage</strong></div></td>
|
70
|
+
</tr>
|
71
|
+
<tr>
|
72
|
+
<td> </td>
|
73
|
+
<td colspan="3"><div align="center"><strong>Lines</strong></div></td>
|
74
|
+
</tr>
|
75
|
+
</thead>
|
76
|
+
<tr>
|
77
|
+
<td class="#{total_status}">Total</td>
|
78
|
+
<td class="#{total_status} big">
|
79
|
+
<div class="progress">
|
80
|
+
<div class="progress-bar progress-bar-#{total_status}" role="progressbar" aria-valuenow="#{total_percent_f}" aria-valuemin="0" aria-valuemax="100" style="width: #{total_percent_f}%">
|
81
|
+
<span class="sr-only">#{total_percent_f}% covered (#{total_status})</span>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
</td>
|
85
|
+
<td class="#{total_status} small"><div align="right">#{total_percent_f}%</div></td>
|
86
|
+
<td class="#{total_status} small"><div align="right">#{result.files.covered_lines} / #{result.files.lines_of_code}</div></td>
|
87
|
+
</tr>
|
88
|
+
EOHTML
|
75
89
|
|
76
90
|
result.files.each do |file|
|
77
91
|
relative_file_path = file.filename[@base_dir_path.size.next..-1]
|
78
92
|
# file_name = File.basename(file.filename)
|
79
|
-
html_file_path =
|
93
|
+
html_file_path =
|
94
|
+
relative_file_path
|
80
95
|
.split('/')
|
81
96
|
.join('_') + '.html'
|
82
97
|
|
@@ -85,79 +100,78 @@ module SimpleCov
|
|
85
100
|
file_status = status_by_percent(file.covered_percent)
|
86
101
|
file_percent_f = '%.2f' % file.covered_percent
|
87
102
|
|
88
|
-
|
89
|
-
|
90
|
-
<
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
</div>
|
97
|
-
</div>
|
98
|
-
</td>
|
99
|
-
<td class="#{file_status} small"><div align="right">#{file_percent_f}%</div></td>
|
100
|
-
<td class="#{file_status} small"><div align="right">#{file.covered_lines.count} / #{file.lines_of_code}</div></td>
|
101
|
-
</tr>
|
102
|
-
|
103
|
-
})
|
104
|
-
|
105
|
-
@html_file = File.open("#{@coverage_dir_path}/#{html_file_path}", 'wb')
|
106
|
-
@html_file.write(%{<!DOCTYPE html>
|
107
|
-
<html lang="en">
|
108
|
-
<head>
|
109
|
-
<meta charset="UTF-8" />
|
110
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
111
|
-
|
112
|
-
<title>Code Coverage for #{file.filename}</title>
|
113
|
-
|
114
|
-
<link href="_assets/css/bootstrap.min.css" rel="stylesheet">
|
115
|
-
<link href="_assets/css/style.css" rel="stylesheet">
|
116
|
-
|
117
|
-
</head>
|
118
|
-
<body>
|
119
|
-
<header>
|
120
|
-
<div class="container">
|
121
|
-
<div class="row">
|
122
|
-
<div class="col-md-12">
|
123
|
-
<ol class="breadcrumb">
|
124
|
-
<li><a href="index.html">#{@base_dir_path}</a></li>
|
125
|
-
<li class="active">#{relative_file_path}</li>
|
126
|
-
</ol>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
</div>
|
130
|
-
</header>
|
131
|
-
<div class="container">
|
132
|
-
<table class="table table-bordered">
|
133
|
-
<thead>
|
134
|
-
<tr>
|
135
|
-
<td> </td>
|
136
|
-
<td colspan="3"><div align="center"><strong>Code Coverage</strong></div></td>
|
137
|
-
</tr>
|
138
|
-
<tr>
|
139
|
-
<td> </td>
|
140
|
-
<td colspan="3"><div align="center"><strong>Lines</strong></div></td>
|
141
|
-
</tr>
|
142
|
-
</thead>
|
143
|
-
<tbody>
|
144
|
-
<tr>
|
145
|
-
<td class="#{file_status}">Covered</td>
|
146
|
-
<td class="#{file_status} big">
|
147
|
-
<div class="progress">
|
148
|
-
<div class="progress-bar progress-bar-#{file_status}" role="progressbar" aria-valuenow="#{file_percent_f}" aria-valuemin="0" aria-valuemax="100" style="width: #{file_percent_f}%">
|
149
|
-
<span class="sr-only">#{file_percent_f}% covered (#{file_status})</span>
|
103
|
+
index_html << <<-EOHTML
|
104
|
+
<tr>
|
105
|
+
<td class="#{file_status}"><span class="glyphicon glyphicon-file"></span> <a href="#{html_file_path}">#{relative_file_path}</a></td>
|
106
|
+
<td class="#{file_status} big">
|
107
|
+
<div class="progress">
|
108
|
+
<div class="progress-bar progress-bar-#{file_status}" role="progressbar" aria-valuenow="100.00" aria-valuemin="0" aria-valuemax="100" style="width: #{file_percent_f}%">
|
109
|
+
<span class="sr-only">#{file_percent_f}% covered (#{file_status})</span>
|
110
|
+
</div>
|
150
111
|
</div>
|
151
|
-
</
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
112
|
+
</td>
|
113
|
+
<td class="#{file_status} small"><div align="right">#{file_percent_f}%</div></td>
|
114
|
+
<td class="#{file_status} small"><div align="right">#{file.covered_lines.count} / #{file.lines_of_code}</div></td>
|
115
|
+
</tr>
|
116
|
+
EOHTML
|
117
|
+
|
118
|
+
html = ''
|
119
|
+
html << <<-EOHTML
|
120
|
+
<!DOCTYPE html>
|
121
|
+
<html lang="en">
|
122
|
+
<head>
|
123
|
+
<meta charset="UTF-8" />
|
124
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
125
|
+
|
126
|
+
<title>Code Coverage for #{file.filename}</title>
|
127
|
+
|
128
|
+
#{@bootstrap_css_html}
|
129
|
+
#{@style_css_html}
|
130
|
+
|
131
|
+
</head>
|
132
|
+
<body>
|
133
|
+
<header>
|
134
|
+
<div class="container">
|
135
|
+
<div class="row">
|
136
|
+
<div class="col-md-12">
|
137
|
+
<ol class="breadcrumb">
|
138
|
+
<li><a href="index.html">#{@base_dir_path}</a></li>
|
139
|
+
<li class="active">#{relative_file_path}</li>
|
140
|
+
</ol>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
</header>
|
145
|
+
<div class="container">
|
146
|
+
<table class="table table-bordered">
|
147
|
+
<thead>
|
148
|
+
<tr>
|
149
|
+
<td> </td>
|
150
|
+
<td colspan="3"><div align="center"><strong>Code Coverage</strong></div></td>
|
151
|
+
</tr>
|
152
|
+
<tr>
|
153
|
+
<td> </td>
|
154
|
+
<td colspan="3"><div align="center"><strong>Lines</strong></div></td>
|
155
|
+
</tr>
|
156
|
+
</thead>
|
157
|
+
<tbody>
|
158
|
+
<tr>
|
159
|
+
<td class="#{file_status}">Covered</td>
|
160
|
+
<td class="#{file_status} big">
|
161
|
+
<div class="progress">
|
162
|
+
<div class="progress-bar progress-bar-#{file_status}" role="progressbar" aria-valuenow="#{file_percent_f}" aria-valuemin="0" aria-valuemax="100" style="width: #{file_percent_f}%">
|
163
|
+
<span class="sr-only">#{file_percent_f}% covered (#{file_status})</span>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
</td>
|
167
|
+
<td class="#{file_status} small"><div align="right">#{file_percent_f}%</div></td>
|
168
|
+
<td class="#{file_status} small"><div align="right">#{file.covered_lines.count} / #{file.lines_of_code}</div></td>
|
169
|
+
</tr>
|
170
|
+
</tbody>
|
171
|
+
</table>
|
172
|
+
<table id="code" class="table table-borderless table-condensed">
|
173
|
+
<tbody>
|
174
|
+
EOHTML
|
161
175
|
|
162
176
|
file.lines.each do |line|
|
163
177
|
# puts " line #{line.line_number} #{line.coverage} #{line.status} #{line.src}"
|
@@ -165,70 +179,73 @@ module SimpleCov
|
|
165
179
|
line_coverage = line.coverage ? line.coverage : ''
|
166
180
|
line_src = CGI.escapeHTML(line.src.chomp)
|
167
181
|
|
168
|
-
|
182
|
+
html << %(<tr)
|
169
183
|
|
170
184
|
if line.covered?
|
171
|
-
|
185
|
+
html << %( class="covered-by-large-tests")
|
172
186
|
elsif line.missed?
|
173
|
-
|
187
|
+
html << %( class="danger")
|
174
188
|
elsif line.skipped?
|
175
|
-
|
176
|
-
else
|
189
|
+
html << %( class="warning")
|
177
190
|
end
|
178
191
|
|
179
|
-
|
192
|
+
html << %(><td><div align="right"><a name="#{line.line_number}"></a><a href="##{line.line_number}">#{line.line_number}</a></div></td><td><div align="left">#{line_coverage}</div></td><td class="codeLine"><span class="default">#{line_src}</span></td></tr>)
|
180
193
|
end
|
181
194
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
195
|
+
html << <<-EOHTML
|
196
|
+
</tbody>
|
197
|
+
</table>
|
198
|
+
<footer>
|
199
|
+
<hr/>
|
200
|
+
<h4>Legend</h4>
|
201
|
+
<p>
|
202
|
+
<span class="success"><strong>Executed</strong></span>
|
203
|
+
<span class="danger"><strong>Not Executed</strong></span>
|
204
|
+
<span class="warning"><strong>Skipped Code</strong></span>
|
205
|
+
</p>
|
206
|
+
<p>
|
207
|
+
<small>Generated by #{@simplecov_phpunit_version_html} using #{@ruby_version_html} and #{@simplecov_version_html} at #{result.created_at.strftime('%F %T %z')}.</small>
|
208
|
+
</p>
|
209
|
+
</footer>
|
210
|
+
</div>
|
198
211
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
</html>
|
204
|
-
|
212
|
+
#{@jquery_js_html}
|
213
|
+
#{@bootstrap_js_html}
|
214
|
+
|
215
|
+
</body>
|
216
|
+
</html>
|
217
|
+
EOHTML
|
205
218
|
|
206
|
-
|
219
|
+
html_file = File.open("#{@coverage_dir_path}/#{html_file_path}", 'wb')
|
220
|
+
html_file.write(html.gsub(/^\t{6}/, ''))
|
221
|
+
html_file.close
|
207
222
|
end
|
208
223
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
</html>
|
229
|
-
|
230
|
-
|
231
|
-
|
224
|
+
index_html << <<-EOHTML
|
225
|
+
</table>
|
226
|
+
<footer>
|
227
|
+
<hr/>
|
228
|
+
<h4>Legend</h4>
|
229
|
+
<p>
|
230
|
+
<span class="danger"><strong>Low</strong>: 0% to 49%</span>
|
231
|
+
<span class="warning"><strong>Medium</strong>: 50% to 89%</span>
|
232
|
+
<span class="success"><strong>High</strong>: 90% to 100%</span>
|
233
|
+
</p>
|
234
|
+
<p>
|
235
|
+
<small>Generated by #{@simplecov_phpunit_version_html} using #{@ruby_version_html} and #{@simplecov_version_html} at #{result.created_at.strftime('%F %T %z')}.</small>
|
236
|
+
</p>
|
237
|
+
</footer>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
#{@jquery_js_html}
|
241
|
+
#{@bootstrap_js_html}
|
242
|
+
|
243
|
+
</html>
|
244
|
+
EOHTML
|
245
|
+
|
246
|
+
index_html_file = File.open(File.expand_path('index.html', @coverage_dir_path), 'wb')
|
247
|
+
index_html_file.write(index_html.gsub(/^\t{5}/, ''))
|
248
|
+
index_html_file.close
|
232
249
|
|
233
250
|
puts 'done'
|
234
251
|
puts
|