coverband 4.0.0 → 4.0.1.alpha

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -4
  3. data/changes.md +57 -52
  4. data/coverband.gemspec +3 -5
  5. data/lib/coverband.rb +6 -1
  6. data/lib/coverband/reporters/html_report.rb +36 -0
  7. data/lib/coverband/reporters/web.rb +16 -13
  8. data/lib/coverband/utils/file_list.rb +68 -0
  9. data/lib/coverband/utils/html_formatter.rb +119 -0
  10. data/lib/coverband/utils/lines_classifier.rb +54 -0
  11. data/lib/coverband/utils/result.rb +108 -0
  12. data/lib/coverband/utils/s3_report.rb +2 -4
  13. data/lib/coverband/utils/source_file.rb +208 -0
  14. data/lib/coverband/utils/tasks.rb +2 -6
  15. data/lib/coverband/version.rb +1 -1
  16. data/public/application.css +799 -0
  17. data/public/application.js +1708 -0
  18. data/public/colorbox/border.png +0 -0
  19. data/public/colorbox/controls.png +0 -0
  20. data/public/colorbox/loading.gif +0 -0
  21. data/public/colorbox/loading_background.png +0 -0
  22. data/public/favicon_green.png +0 -0
  23. data/public/favicon_red.png +0 -0
  24. data/public/favicon_yellow.png +0 -0
  25. data/public/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  26. data/public/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  27. data/public/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  28. data/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  29. data/public/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  30. data/public/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  31. data/public/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  32. data/public/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  33. data/public/images/ui-icons_222222_256x240.png +0 -0
  34. data/public/images/ui-icons_2e83ff_256x240.png +0 -0
  35. data/public/images/ui-icons_454545_256x240.png +0 -0
  36. data/public/images/ui-icons_888888_256x240.png +0 -0
  37. data/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  38. data/public/loading.gif +0 -0
  39. data/public/magnify.png +0 -0
  40. data/test/unit/full_stack_test.rb +2 -2
  41. data/test/unit/reports_console_test.rb +1 -1
  42. data/test/unit/{reports_simple_cov_test.rb → reports_html_test.rb} +4 -7
  43. data/test/unit/reports_web_test.rb +3 -4
  44. data/test/unit/utils_s3_report_test.rb +1 -3
  45. data/views/file_list.erb +45 -0
  46. data/views/layout.erb +39 -0
  47. data/views/source_file.erb +23 -0
  48. metadata +49 -17
  49. data/lib/coverband/reporters/simple_cov_report.rb +0 -45
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -34,9 +34,9 @@ class FullStackTest < Test::Unit::TestCase
34
34
  expected = [nil, nil, 1, nil, 1, 1, 2, nil, nil]
35
35
  assert_equal expected, Coverband.configuration.store.coverage[@rack_file]
36
36
 
37
- expected = nil
37
+ # expected = nil
38
38
  # TODO: read the html to test it matches expectations? or return data as a hash?
39
- # actual = Coverband::Reporters::SimpleCovReport.report(Coverband.configuration.store, open_report: false)
39
+ # actual = Coverband::Reporters::HTMLReport.report(Coverband.configuration.store, open_report: false)
40
40
  # assert_equal expected, actual
41
41
  end
42
42
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.expand_path('../test_helper', File.dirname(__FILE__))
4
4
 
5
- class SimpleCovReportTest < Test::Unit::TestCase
5
+ class HTMLReportTest < Test::Unit::TestCase
6
6
  BASE_KEY = Coverband::Adapters::RedisStore::BASE_KEY
7
7
 
8
8
  def setup
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.expand_path('../test_helper', File.dirname(__FILE__))
4
4
 
5
- class ReportsSimpleCovTest < Test::Unit::TestCase
5
+ class ReportHTMLTest < Test::Unit::TestCase
6
6
  BASE_KEY = Coverband::Adapters::RedisStore::BASE_KEY
7
7
 
8
8
  def setup
@@ -18,14 +18,11 @@ class ReportsSimpleCovTest < Test::Unit::TestCase
18
18
  config.s3_bucket = nil
19
19
  config.ignore = ['notsomething.rb']
20
20
  end
21
- Coverband.configuration.logger.stubs('info')
22
21
  mock_file_hash
23
22
  @store.send(:save_report, basic_coverage)
24
23
 
25
- SimpleCov.expects(:track_files)
26
- SimpleCov.expects(:add_not_loaded_files).returns({})
27
- SimpleCov::Result.any_instance.expects(:format!)
28
- SimpleCov.stubs(:root)
29
- Coverband::Reporters::SimpleCovReport.report(@store, open_report: false)
24
+ html = Coverband::Reporters::HTMLReport.report(@store,
25
+ html: true, open_report: false)
26
+ assert_match 'Generated by', html
30
27
  end
31
28
  end
@@ -9,7 +9,7 @@ ENV['RACK_ENV'] = 'test'
9
9
 
10
10
  if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
11
11
  module Coverband
12
- class S3WebTest < Test::Unit::TestCase
12
+ class WebTest < Test::Unit::TestCase
13
13
  include Rack::Test::Methods
14
14
 
15
15
  def app
@@ -20,7 +20,7 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
20
20
  Coverband.configuration.s3_bucket = nil
21
21
  end
22
22
 
23
- # TODO add tests for all endpoints
23
+ # TODO: add tests for all endpoints
24
24
  test 'renders index content' do
25
25
  get '/'
26
26
  assert last_response.ok?
@@ -28,8 +28,7 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
28
28
  end
29
29
 
30
30
  test 'renders show content' do
31
- Coverband.configuration.s3_bucket = 'coverage-bucket'
32
- Coverband::Utils::S3Report.any_instance.expects(:retrieve).returns('content')
31
+ Coverband::Reporters::HTMLReport.expects(:report).returns('content')
33
32
  get '/show'
34
33
  assert last_response.ok?
35
34
  assert_equal 'content', last_response.body
@@ -4,9 +4,7 @@ require 'aws-sdk'
4
4
  module Coverband
5
5
  class S3ReportTest < Test::Unit::TestCase
6
6
  def html_version
7
- Gem::Specification.find_by_name('simplecov-html').version.version.to_s
8
- rescue StandardError
9
- '0.10.1'
7
+ Coverband::VERSION
10
8
  end
11
9
 
12
10
  test 'it writes the coverage report to s3' do
@@ -0,0 +1,45 @@
1
+ <div class="file_list_container" id="<%= title_id %>">
2
+ <h2>
3
+ <span class="group_name"><%= title %></span>
4
+ (<span class="covered_percent"><span class="<%= coverage_css_class(source_files.covered_percent) %>"><%= source_files.covered_percent.round(2) %>%</span></span>
5
+ covered at
6
+ <span class="covered_strength">
7
+ <span class="<%= strength_css_class(source_files.covered_strength) %>">
8
+ <%= source_files.covered_strength.round(2) %>
9
+ </span>
10
+ </span> hits/line)
11
+ </h2>
12
+ <a name="<%= title_id %>"></a>
13
+ <div>
14
+ <b><%= source_files.length %></b> files in total.
15
+ <b><%= source_files.lines_of_code %></b> relevant lines.
16
+ <span class="green"><b><%= source_files.covered_lines %></b> lines covered</span> and
17
+ <span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
18
+ </div>
19
+ <table class="file_list">
20
+ <thead>
21
+ <tr>
22
+ <th>File</th>
23
+ <th>% covered</th>
24
+ <th>Lines</th>
25
+ <th>Relevant Lines</th>
26
+ <th>Lines covered</th>
27
+ <th>Lines missed</th>
28
+ <th>Avg. Hits / Line</th>
29
+ </tr>
30
+ </thead>
31
+ <tbody>
32
+ <% source_files.each do |source_file| %>
33
+ <tr>
34
+ <td class="strong"><%= link_to_source_file(source_file) %></td>
35
+ <td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
36
+ <td><%= source_file.lines.count %></td>
37
+ <td><%= source_file.covered_lines.count + source_file.missed_lines.count %></td>
38
+ <td><%= source_file.covered_lines.count %></td>
39
+ <td><%= source_file.missed_lines.count %></td>
40
+ <td><%= source_file.covered_strength %></td>
41
+ </tr>
42
+ <% end %>
43
+ </tbody>
44
+ </table>
45
+ </div>
data/views/layout.erb ADDED
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Code coverage for <%= Coverband::VERSION %></title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
7
+ <link href='<%= assets_path('application.css') %>' media='screen, projection, print' rel='stylesheet' type='text/css'>
8
+ <link rel="shortcut icon" type="image/png" href="<%= assets_path("favicon_#{coverage_css_class(result.source_files.covered_percent)}.png") %>" />
9
+ <link rel="icon" type="image/png" href="<%= assets_path('favicon.png') %>" />
10
+ </head>
11
+
12
+ <body>
13
+ <div id="loading">
14
+ <img src="<%= assets_path('loading.gif') %>" alt="loading"/>
15
+ </div>
16
+ <div id="wrapper" style="display:none;">
17
+ <div class="timestamp">Generated <%= timeago(Time.now) %></div>
18
+ <ul class="group_tabs"></ul>
19
+
20
+ <div id="content">
21
+ <%= formatted_file_list("All Files", result.source_files) %>
22
+
23
+ <% result.groups.each do |name, files| %>
24
+ <%= formatted_file_list(name, files) %>
25
+ <% end %>
26
+ </div>
27
+
28
+ <div id="footer">
29
+ Generated by <a href="http://github.com/danmayer/coverband">Coverband</a> v<%= Coverband::VERSION %>
30
+ </div>
31
+
32
+ <div class="source_files">
33
+ <% result.source_files.each do |source_file| %>
34
+ <%= formatted_source_file(source_file) %>
35
+ <% end %>
36
+ </div>
37
+ </div>
38
+ </body>
39
+ </html>
@@ -0,0 +1,23 @@
1
+ <div class="source_table" id="<%= id source_file %>">
2
+ <div class="header">
3
+ <h3><%= shortened_filename source_file %></h3>
4
+ <h4><span class="<%= coverage_css_class(source_file.covered_percent) %>"><%= source_file.covered_percent.round(2).to_s %> %</span> covered</h4>
5
+ <div>
6
+ <b><%= source_file.lines_of_code %></b> relevant lines.
7
+ <span class="green"><b><%= source_file.covered_lines.count %></b> lines covered</span> and
8
+ <span class="red"><b><%= source_file.missed_lines.count %></b> lines missed.</span>
9
+ </div>
10
+ </div>
11
+
12
+ <pre>
13
+ <ol>
14
+ <% source_file.lines.each do |line| %>
15
+ <li class="<%= line.status %>" data-hits="<%= line.coverage ? line.coverage : '' %>" data-linenumber="<%= line.number %>">
16
+ <% if line.covered? %><span class="hits"><%= line.coverage %></span><% end %>
17
+ <% if line.skipped? %><span class="hits">skipped</span><% end %>
18
+ <code class="ruby"><%= CGI.escapeHTML(line.src.chomp) %></code>
19
+ </li>
20
+ <% end %>
21
+ </ol>
22
+ </pre>
23
+ </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: test-unit
140
+ name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: classifier-reborn
154
+ name: test-unit
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: pry-byebug
168
+ name: classifier-reborn
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,13 +179,13 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: redis
182
+ name: pry-byebug
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
- type: :runtime
188
+ type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
@@ -193,19 +193,19 @@ dependencies:
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: simplecov
196
+ name: redis
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">"
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
- version: 0.11.1
201
+ version: '0'
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">"
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
- version: 0.11.1
208
+ version: '0'
209
209
  description: Rack middleware to help measure production code usage (LOC runtime usage)
210
210
  email:
211
211
  - dan@mayerdan.com
@@ -237,12 +237,41 @@ files:
237
237
  - lib/coverband/integrations/rack_server_check.rb
238
238
  - lib/coverband/reporters/base.rb
239
239
  - lib/coverband/reporters/console_report.rb
240
- - lib/coverband/reporters/simple_cov_report.rb
240
+ - lib/coverband/reporters/html_report.rb
241
241
  - lib/coverband/reporters/web.rb
242
+ - lib/coverband/utils/file_list.rb
243
+ - lib/coverband/utils/html_formatter.rb
244
+ - lib/coverband/utils/lines_classifier.rb
242
245
  - lib/coverband/utils/railtie.rb
246
+ - lib/coverband/utils/result.rb
243
247
  - lib/coverband/utils/s3_report.rb
248
+ - lib/coverband/utils/source_file.rb
244
249
  - lib/coverband/utils/tasks.rb
245
250
  - lib/coverband/version.rb
251
+ - public/application.css
252
+ - public/application.js
253
+ - public/colorbox/border.png
254
+ - public/colorbox/controls.png
255
+ - public/colorbox/loading.gif
256
+ - public/colorbox/loading_background.png
257
+ - public/favicon_green.png
258
+ - public/favicon_red.png
259
+ - public/favicon_yellow.png
260
+ - public/images/ui-bg_flat_0_aaaaaa_40x100.png
261
+ - public/images/ui-bg_flat_75_ffffff_40x100.png
262
+ - public/images/ui-bg_glass_55_fbf9ee_1x400.png
263
+ - public/images/ui-bg_glass_65_ffffff_1x400.png
264
+ - public/images/ui-bg_glass_75_dadada_1x400.png
265
+ - public/images/ui-bg_glass_75_e6e6e6_1x400.png
266
+ - public/images/ui-bg_glass_95_fef1ec_1x400.png
267
+ - public/images/ui-bg_highlight-soft_75_cccccc_1x100.png
268
+ - public/images/ui-icons_222222_256x240.png
269
+ - public/images/ui-icons_2e83ff_256x240.png
270
+ - public/images/ui-icons_454545_256x240.png
271
+ - public/images/ui-icons_888888_256x240.png
272
+ - public/images/ui-icons_cd0a0a_256x240.png
273
+ - public/loading.gif
274
+ - public/magnify.png
246
275
  - test/benchmarks/.gitignore
247
276
  - test/benchmarks/benchmark.rake
248
277
  - test/benchmarks/dog.rb
@@ -278,9 +307,12 @@ files:
278
307
  - test/unit/rails_full_stack_test.rb
279
308
  - test/unit/reports_base_test.rb
280
309
  - test/unit/reports_console_test.rb
281
- - test/unit/reports_simple_cov_test.rb
310
+ - test/unit/reports_html_test.rb
282
311
  - test/unit/reports_web_test.rb
283
312
  - test/unit/utils_s3_report_test.rb
313
+ - views/file_list.erb
314
+ - views/layout.erb
315
+ - views/source_file.erb
284
316
  homepage: https://github.com/danmayer/coverband
285
317
  licenses:
286
318
  - MIT
@@ -296,9 +328,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
296
328
  version: '0'
297
329
  required_rubygems_version: !ruby/object:Gem::Requirement
298
330
  requirements:
299
- - - ">="
331
+ - - ">"
300
332
  - !ruby/object:Gem::Version
301
- version: '0'
333
+ version: 1.3.1
302
334
  requirements: []
303
335
  rubyforge_project:
304
336
  rubygems_version: 2.7.3
@@ -341,6 +373,6 @@ test_files:
341
373
  - test/unit/rails_full_stack_test.rb
342
374
  - test/unit/reports_base_test.rb
343
375
  - test/unit/reports_console_test.rb
344
- - test/unit/reports_simple_cov_test.rb
376
+ - test/unit/reports_html_test.rb
345
377
  - test/unit/reports_web_test.rb
346
378
  - test/unit/utils_s3_report_test.rb
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Coverband
4
- module Reporters
5
- class SimpleCovReport < Base
6
- def self.report(store, options = {})
7
- begin
8
- require 'simplecov'
9
- rescue StandardError
10
- msg = 'coverband requires simplecov to generate a report, when config.reporter=scov'
11
- Coverband.configuration.logger.error msg
12
- return
13
- end
14
-
15
- scov_style_report = super(store, options)
16
- open_report = options.fetch(:open_report) { true }
17
-
18
- # set root to show files if user has simplecov profiles
19
- # https://github.com/danmayer/coverband/issues/59
20
- SimpleCov.root(current_root)
21
-
22
- # add in files never hit in coverband
23
- SimpleCov.track_files "#{current_root}/{app,lib,config}/**/*.{rb,haml,erb,slim}"
24
-
25
- # still apply coverband filters
26
- report_files = SimpleCov.add_not_loaded_files(scov_style_report)
27
- filtered_report_files = {}
28
- report_files.each_pair do |file, data|
29
- next if Coverband.configuration.ignore.any? { |i| file.match(i) }
30
- filtered_report_files[file] = data
31
- end
32
-
33
- SimpleCov::Result.new(filtered_report_files).format!
34
-
35
- if open_report
36
- `open #{SimpleCov.coverage_dir}/index.html`
37
- else
38
- Coverband.configuration.logger.info "report is ready and viewable: open #{SimpleCov.coverage_dir}/index.html"
39
- end
40
-
41
- Coverband::Utils::S3Report.instance.persist! if Coverband.configuration.s3_bucket
42
- end
43
- end
44
- end
45
- end