coverband 4.2.0 → 4.2.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -9
  3. data/.travis.yml +9 -1
  4. data/Gemfile +2 -1
  5. data/Gemfile.rails4 +1 -0
  6. data/README.md +34 -13
  7. data/Rakefile +10 -2
  8. data/changes.md +25 -10
  9. data/coverband.gemspec +5 -1
  10. data/lib/coverband.rb +30 -18
  11. data/lib/coverband/adapters/base.rb +2 -7
  12. data/lib/coverband/adapters/file_store.rb +1 -1
  13. data/lib/coverband/at_exit.rb +2 -11
  14. data/lib/coverband/collectors/coverage.rb +29 -32
  15. data/lib/coverband/collectors/delta.rb +20 -24
  16. data/lib/coverband/configuration.rb +49 -19
  17. data/lib/coverband/integrations/background.rb +6 -4
  18. data/lib/coverband/integrations/{middleware.rb → background_middleware.rb} +2 -6
  19. data/lib/coverband/integrations/bundler.rb +8 -0
  20. data/lib/coverband/integrations/report_middleware.rb +15 -0
  21. data/lib/coverband/integrations/resque.rb +3 -5
  22. data/lib/coverband/reporters/base.rb +39 -13
  23. data/lib/coverband/reporters/html_report.rb +21 -27
  24. data/lib/coverband/reporters/web.rb +2 -21
  25. data/lib/coverband/utils/file_list.rb +16 -5
  26. data/lib/coverband/utils/file_path_helper.rb +2 -0
  27. data/lib/coverband/utils/html_formatter.rb +25 -8
  28. data/lib/coverband/utils/lines_classifier.rb +5 -0
  29. data/lib/coverband/utils/railtie.rb +11 -12
  30. data/lib/coverband/utils/result.rb +5 -44
  31. data/lib/coverband/utils/results.rb +51 -0
  32. data/lib/coverband/utils/source_file.rb +29 -5
  33. data/lib/coverband/utils/tasks.rb +11 -2
  34. data/lib/coverband/version.rb +1 -1
  35. data/public/application.js +27 -0
  36. data/test/benchmarks/benchmark.rake +10 -20
  37. data/test/coverband/adapters/file_store_test.rb +5 -5
  38. data/test/coverband/adapters/redis_store_test.rb +8 -7
  39. data/test/coverband/at_exit_test.rb +0 -2
  40. data/test/coverband/collectors/coverage_test.rb +57 -9
  41. data/test/coverband/collectors/delta_test.rb +27 -6
  42. data/test/coverband/configuration_test.rb +47 -7
  43. data/test/coverband/coverband_test.rb +0 -1
  44. data/test/coverband/integrations/background_middleware_test.rb +44 -0
  45. data/test/coverband/integrations/background_test.rb +1 -3
  46. data/test/coverband/integrations/report_middleware_test.rb +44 -0
  47. data/test/coverband/integrations/resque_worker_test.rb +4 -3
  48. data/test/coverband/integrations/test_resque_job.rb +3 -1
  49. data/test/coverband/reporters/base_test.rb +4 -4
  50. data/test/coverband/reporters/console_test.rb +1 -2
  51. data/test/coverband/reporters/html_test.rb +79 -16
  52. data/test/coverband/reporters/web_test.rb +0 -10
  53. data/test/coverband/utils/file_groups_test.rb +1 -1
  54. data/test/coverband/utils/file_list_test.rb +5 -5
  55. data/test/coverband/utils/html_formatter_test.rb +45 -0
  56. data/test/coverband/utils/result_test.rb +27 -47
  57. data/test/coverband/utils/results_test.rb +54 -0
  58. data/test/coverband/utils/s3_report_test.rb +2 -0
  59. data/test/coverband/utils/source_file_test.rb +50 -0
  60. data/test/forked/rails_full_stack_test.rb +101 -0
  61. data/test/forked/rails_rake_full_stack_test.rb +32 -0
  62. data/test/integration/full_stack_test.rb +17 -15
  63. data/test/rails4_dummy/Rakefile +6 -0
  64. data/test/rails4_dummy/config/application.rb +8 -9
  65. data/test/rails4_dummy/config/coverband.rb +3 -3
  66. data/test/rails5_dummy/Rakefile +6 -0
  67. data/test/rails5_dummy/config/application.rb +6 -10
  68. data/test/rails5_dummy/config/coverband.rb +2 -2
  69. data/test/rails_test_helper.rb +23 -4
  70. data/test/test_helper.rb +26 -1
  71. data/test/unique_files.rb +6 -5
  72. data/views/file_list.erb +2 -2
  73. data/views/gem_list.erb +10 -1
  74. data/views/layout.erb +10 -3
  75. data/views/source_file.erb +13 -4
  76. data/views/source_file_loader.erb +1 -1
  77. metadata +79 -9
  78. data/test/coverband/integrations/middleware_test.rb +0 -96
  79. data/test/integration/rails_full_stack_test.rb +0 -95
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e214b1bd6119046657daa64ed6d69f77f821c6c670b72e98d307ede5f08e61f
4
- data.tar.gz: 469d9470799f90b5b52d53d3a630fae75b3b6bff0390375987902331878f530e
3
+ metadata.gz: e20f401f319399c3eb6aab9f562105addeedd4dcea5e3de3db3e5a763e92fe5d
4
+ data.tar.gz: bc20a849db5868dd73a448269bc9d74e6b58674793807bcdcf36a33cecd8825b
5
5
  SHA512:
6
- metadata.gz: f1b0f503941ab9dbc2dee6a184fe6d6d937a5f505a5c9112ae7343197372586d6cb42df758f24effde0ee30fb359c0e2e651c64a1f5ee4c9a588a4499683dc73
7
- data.tar.gz: ee700abfe4c730011dcc5c1c8521f55a2cc7ec5149e44b08187c8d09419023160a0f7c8aaba4b2aa0bb405eb13f4aeee1d8ce9cabce4860738d4ea94cac63c04
6
+ metadata.gz: 5f2303765376cd244a692d1254ef8f7fe57180ee12712d3763921811c7d278fb3ffb2dfa4a1400b86b01809c0acfa8173c7569aeb65be3f860e53dad01dfbc83
7
+ data.tar.gz: c3456663cc5b9f9ecfce60603234f4aed32ef9f3875cb0ca60ae11e66211f70bb64c6f0b8772b5295c8065d4d8245f107d596cd21140ba7ab146c97ef8353324
@@ -2,14 +2,21 @@ AllCops:
2
2
  TargetRubyVersion: 2.4
3
3
  Exclude:
4
4
  - docs/**/*
5
+ - test/rails4_dummy/**/*
6
+ - test/rails5_dummy/**/*
7
+ - test/fixtures/**/*
8
+ # Get the code passing first then we will enable for tests
9
+ - test/**/*
5
10
  Documentation:
6
11
  Enabled: false
7
12
  Metrics/MethodLength:
8
13
  Enabled: false
9
14
  Metrics/LineLength:
10
- Max: 120
15
+ Max: 160
11
16
  Metrics/BlockNesting:
12
17
  Max: 5
18
+ Metrics/BlockLength:
19
+ Max: 30
13
20
  Metrics/CyclomaticComplexity:
14
21
  Enabled: false
15
22
  Metrics/PerceivedComplexity:
@@ -22,38 +29,51 @@ Metrics/ModuleLength:
22
29
  Enabled: false
23
30
  Metrics/ParameterLists:
24
31
  Max: 10
25
- Style/AccessorMethodName:
26
- Enabled: false
27
- Style/PredicateName:
32
+ Naming/AccessorMethodName:
28
33
  Enabled: false
34
+ Naming/PredicateName:
35
+ Enabled: true
29
36
  Style/TernaryParentheses:
30
37
  Enabled: false
31
38
  Style/MutableConstant:
32
39
  Enabled: false
40
+ Style/IdenticalConditionalBranches:
41
+ Enabled: false
42
+ Style/ClassVars:
43
+ Enabled: false
44
+ Style/MultilineBlockChain:
45
+ Enabled: false
33
46
  Style/FrozenStringLiteralComment:
34
47
  Enabled: true
35
48
  Style/GuardClause:
36
49
  Enabled: true
37
50
  Style/NumericPredicate:
38
- Enabled: false
51
+ Enabled: true
39
52
  Style/NumericLiterals:
40
53
  Enabled: false
41
54
  Style/NumericLiteralPrefix:
42
55
  Enabled: false
43
56
  Style/ClassAndModuleChildren:
44
57
  Enabled: false
58
+ Style/SymbolProc:
59
+ Enabled: false
60
+ Style/RegexpLiteral:
61
+ Enabled: false
45
62
  Performance/Casecmp:
46
63
  Enabled: false
47
- Style/MultilineMethodCallIndentation:
64
+ Performance/RegexpMatch:
65
+ Enabled: false
66
+ Layout/MultilineMethodCallIndentation:
48
67
  Enabled: true
49
- Style/MultilineOperationIndentation:
68
+ Layout/MultilineOperationIndentation:
50
69
  Enabled: true
51
70
  Lint/RescueException:
52
71
  Enabled: true
72
+ Lint/UselessAccessModifier:
73
+ Enabled: true
53
74
  Lint/ShadowingOuterLocalVariable:
54
75
  Enabled: true
55
76
  Style/FormatString:
56
77
  Enabled: true
57
- Lint/Eval:
78
+ Security/Eval:
58
79
  Enabled: true
59
-
@@ -9,11 +9,19 @@ gemfile:
9
9
  - Gemfile.rails4
10
10
  services:
11
11
  - redis-server
12
+ script:
13
+ - bundle exec rake rubocop
14
+ - bundle exec rake
15
+ - bundle exec rake forked_tests
16
+ addons:
17
+ chrome: stable
12
18
  before_install:
13
19
  - echo 'this is a hack to clear default bundler and force bundler 1.17.3'
14
20
  - ls /home/travis/.rvm/gems/
15
21
  - rm /home/travis/.rvm/gems/ruby-2.3.7@global/specifications/bundler-2.0.1.gemspec || true
16
- - rm /home/travis/.rvm/gems/ruby-2.5.4@global/specifications/bundler-2.0.1.gemspec || true
22
+ - rm /home/travis/.rvm/gems/ruby-2.4.6@global/specifications/bundler-2.0.1.gemspec || true
23
+ - rm /home/travis/.rvm/gems/ruby-2.5.5@global/specifications/bundler-2.0.1.gemspec || true
17
24
  - gem uninstall bundler || true
18
25
  - gem install bundler -v '1.17.3'
19
26
  - bundler --version
27
+ - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
data/Gemfile CHANGED
@@ -5,5 +5,6 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in coverband.gemspec
6
6
  gemspec
7
7
  gem 'rails', '~>5'
8
- # this is used for testing gem tracking
8
+ # these gems are used for testing gem tracking
9
+ gem 'pundit'
9
10
  gem 'rainbow', require: false
@@ -7,3 +7,4 @@ gemspec
7
7
  gem 'rails', '~>4'
8
8
  # this is used for testing gem tracking
9
9
  gem 'rainbow', require: false
10
+ gem 'pundit'
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  [![Build Status](https://travis-ci.org/danmayer/coverband.svg?branch=master)](https://travis-ci.org/danmayer/coverband)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/danmayer/coverband/badge.svg?branch=master)](https://coveralls.io/github/danmayer/coverband?branch=master)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1e6682f9540d75f26da7/maintainability)](https://codeclimate.com/github/danmayer/coverband/maintainability)
7
8
 
8
9
  <p align="center">
9
10
  <a href="#key-features">Key Features</a> •
@@ -24,9 +25,11 @@ A gem to measure production code usage, showing a counter for the number of time
24
25
  The primary goal of Coverband is giving deep insight into your production runtime usage of your application code, while having the least impact on performance possible.
25
26
 
26
27
  - Low performance overhead
27
- - Very simple setup and configuration
28
+ - Simple setup and configuration
28
29
  - Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
30
+ - Splits load time (Rails eager load) and Run time metrics
29
31
  - Easy to understand actionable insights from the report
32
+ - Tracks Gem usage
30
33
  - Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
31
34
  - Mountable web interface to easily share reports
32
35
 
@@ -52,9 +55,17 @@ gem 'coverband'
52
55
 
53
56
  If [tracking gem usage](#collecting-gem--library-usage), be sure to include coverband before other gems you would like to track.
54
57
 
58
+ ## Upgrading to Latest
59
+
60
+ ### No custom code or middleware required
61
+
62
+ With older versions of coverband, projects would report to redis using rack or sidekiq middleware. After coverband 4.0, this should no longer be required and could cause performance issues. Reporting to redis is now automatically done within a background thread with no custom code needed.
63
+
64
+ See [changelog](https://github.com/danmayer/coverband/blob/master/changes.md).
65
+
55
66
  ## Rails
56
67
 
57
- The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile.
68
+ The Railtie integration means you shouldn't need to do anything anything else other than ensure coverband is required after rails within your Gemfile. The only exception to this is gem tracking of `Bundle.require` which depends on requiring coverband within the application.rb. See [Collecting Gem / Library Usage](https://github.com/danmayer/coverband#collecting-gem--library-usage).
58
69
 
59
70
  ## Sinatra
60
71
 
@@ -64,7 +75,7 @@ For the best coverage you want this loaded as early as possible. I have been put
64
75
  require 'coverband'
65
76
  require File.dirname(__FILE__) + '/config/environment'
66
77
 
67
- use Coverband::Middleware
78
+ use Coverband::BackgroundMiddleware
68
79
  run ActionController::Dispatcher.new
69
80
  ```
70
81
 
@@ -92,7 +103,7 @@ end
92
103
 
93
104
  The web endpoint is a barebones endpoint that you can either expose direct (after authentication) or you can just link to the actions you wish to expose. The index is intended as a example to showcase all the features.
94
105
 
95
- ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_web_update.png)
106
+ ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_web_ui.png)
96
107
 
97
108
  > The web index as available on the Coverband Demo site
98
109
 
@@ -118,14 +129,6 @@ Index Page
118
129
  Details on an example Sinatra app
119
130
  ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_details.png)
120
131
 
121
- # Verify Correct Installation
122
-
123
- - boot up your application
124
- - run app and hit a controller (via a web request, at least one request must complete)
125
- - run `rake coverband:coverage` this will show app initialization coverage
126
- - make another request, or enough that your reporting frequency will trigger
127
- - run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
128
-
129
132
  # Coverband Demo
130
133
 
131
134
  Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://coverband-demo.herokuapp.com/). The [full source code for the demo](https://github.com/danmayer/coverband_demo) is available to help with installation, configuration, and understanding of basic usage.
@@ -261,7 +264,20 @@ end
261
264
 
262
265
  The `track_gems` feature exposes a Gems tab in the report which prints out the percentage usage of each Gem. See demo [here](https://coverband-demo.herokuapp.com/coverage?#_Gems).
263
266
 
264
- When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. Since `Coverband#start` is automatically called by default when coverband is required, list coverband before the other gems to be tracked within your Gemfile. The exception to this are gems like rails and resque. Since coverband has some specific intergrations for these frameworks, these two gems should be required first.
267
+ When tracking gems, it is important that `Coverband#start` is called before the gems to be tracked are required. The best way to do this is to require coverband before Bundle.require is called. Within rails, require coverband within the application.rb like so:
268
+
269
+ ```ruby
270
+ require 'coverband'
271
+ Bundler.require(*Rails.groups)
272
+ ```
273
+
274
+ If you are using the resque integration, resque needs to be required before coverband since the integration will not run unless resque is loaded. Within the application.rb just require resque before coverband.
275
+
276
+ ```ruby
277
+ require 'resque'
278
+ require 'coverband'
279
+ Bundler.require(*Rails.groups)
280
+ ```
265
281
 
266
282
  The track_gems config only exposes the overall usage of a gem. In order to see the detail of each file, enable the `gem_details` flag.
267
283
 
@@ -335,6 +351,7 @@ If you submit a change please make sure the tests and benchmarks are passing.
335
351
  - view test coverage: `open coverage/index.html`
336
352
  - run the benchmarks before and after your change to see impact
337
353
  - `rake benchmarks`
354
+ - run a single test by line number like rspec: `bundle exec m test/coverband/reporters/html_test.rb:29`
338
355
 
339
356
  ### Known Issues
340
357
 
@@ -352,6 +369,10 @@ What is the coverage data in Redis?
352
369
 
353
370
  `Coverband.configuration.store.coverage`
354
371
 
372
+ ## Logo
373
+
374
+ The Coverband logo was created by [Dave Woodall](http://davewoodall.com). Thanks Dave!
375
+
355
376
  # License
356
377
 
357
378
  This is a MIT License project...
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
-
5
4
  import 'test/benchmarks/benchmark.rake'
5
+ require 'rubocop/rake_task'
6
+
7
+ RuboCop::RakeTask.new
6
8
 
7
- task default: [:test, :benchmarks]
9
+ task default: %i[test benchmarks]
8
10
 
9
11
  task :test
10
12
  require 'rake/testtask'
@@ -17,6 +19,12 @@ Rake::TestTask.new(:test) do |test|
17
19
  test.verbose = true
18
20
  end
19
21
 
22
+ Rake::TestTask.new(:forked_tests) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.test_files = FileList['test/forked/**/*_test.rb']
25
+ test.verbose = true
26
+ end
27
+
20
28
  desc 'load irb with this gem'
21
29
  task :console do
22
30
  exec 'irb -I lib -r coverband'
data/changes.md CHANGED
@@ -16,6 +16,8 @@ Will be the fully modern release that drops maintenance legacy support in favor
16
16
  - add built-in support for easy loading via Railties
17
17
  - built in support for activejob, sidekiq, and other common frameworks
18
18
  - reduced configuration options
19
+ - support oneshot
20
+ - drop middleware figure out a way to kick off background without middelware
19
21
  - options on reporting
20
22
  - background reporting
21
23
  - or middleware reporting
@@ -54,29 +56,42 @@ This is a possible gem to host experimental or more complex features, which woul
54
56
 
55
57
  Feature Ideas:
56
58
 
59
+ - per request coverage implemented via Ruby 2.6.0 coverage.clear https://bugs.ruby-lang.org/issues/15022
57
60
  - statsd adapters (it would allow passing in date ranges on usage)
58
- - move to SimpleCov console out, or make similar console tabular output
59
61
  - Possibly add ability to record code run for a given route
60
62
  - integrate recording with deploy tag or deploy timestamp
61
63
  - diff code usage across deployed versions
62
64
  - what methods increased usage or decreased
63
- - Improve client code api, around manual usage of sampling (like event usage)
64
65
  - ability to change the Coverband config at runtime by changing the config pushed to the Redis hash. In memory cache around the changes to only make that call periodically.
65
66
  - Opposed to just showing code usage on a route allow 'tagging' events which would record line coverage for that tag (this would allow tagging all code that modified an ActiveRecord model for example
66
67
  - additional adapters (tracepoint, ruby-profiler, etc)
67
- - code route tracing (entry point to all code executed for example /some_path -> code coverage of that path)
68
- - tagging of reported Coverage
69
- - allow only to collect coverage based on route (limiting or scoped coverage)
70
- - coverage over some other variable like a set of alpha users
68
+ - tagged coverage reports
69
+ - code route tracing (entry point to all code executed for example /some_path -> code coverage of that path)
70
+ - deploy git hash tagging of reported Coverage
71
+ - allow only to collect coverage based on route (limiting or scoped coverage)
72
+ - coverage over some other variable like a set of alpha users
71
73
  - document how to use this on staging / selenium test suite runs
72
74
  - possible add API to pull report at end of run
73
75
 
74
- # Alpha
76
+ # Alpha / Beta / Release Candidates
75
77
 
76
- ### Coverband 4.3.0?
78
+ ### Coverband 4.2.1
77
79
 
78
80
  - further improvements on eager_loading detection
79
- - ?
81
+ - fix on ignore configuration options
82
+ - fix broken static server
83
+ - fix issue where clear and coverage trigger coverage reports
84
+ - improved logging
85
+ - fix sorting of runtime coverage
86
+ - add runtime coverage to gem summary pages
87
+ - fix issue where reports didn't include files with 0 activity
88
+ - add Oneshot coverage support for Ruby 2.6.0 thanks @zwalker
89
+ - I would consider this our test oneshot release, please report any issues
90
+ - resolve regression on coverband rake tasks recording coverage
91
+ - improved runtime / eager loading tracking
92
+ - updated runtime relavent lines and runtime percentages
93
+ - fix on gem runtime code coverage support, thanks @kbaum
94
+ - display gems that are in loaded with 0 coverage, thanks @kbaum
80
95
 
81
96
  # Released
82
97
 
@@ -96,7 +111,7 @@ Feature Ideas:
96
111
  - move from thread based reporter instance to process based instance
97
112
  - thanks Karl Baum for much of the above mentioned work
98
113
  - clear coverage on individual files
99
- - we have a logo, thanks Dave Woodall
114
+ - we have a logo, thanks Dave Woodall, http://davewoodall.com
100
115
 
101
116
  ### Coverband 4.1.1
102
117
 
@@ -28,12 +28,16 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'm'
29
29
  spec.add_development_dependency 'memory_profiler'
30
30
  spec.add_development_dependency 'minitest'
31
+ spec.add_development_dependency 'minitest-fork_executor'
31
32
  spec.add_development_dependency 'mocha', '~> 1.7.0'
32
33
  spec.add_development_dependency 'rack'
33
34
  spec.add_development_dependency 'rack-test'
34
35
  spec.add_development_dependency 'rake'
35
36
  spec.add_development_dependency 'resque'
36
- # temporarily needed to fun tests for classifier-reborn as part of benchmarks
37
+ spec.add_development_dependency 'rubocop'
38
+ spec.add_development_dependency 'selenium-webdriver'
39
+ spec.add_development_dependency 'webdrivers', '~> 3.0'
40
+ # temporarily needed to run tests for classifier-reborn as part of benchmarks
37
41
  spec.add_development_dependency 'minitest-reporters'
38
42
 
39
43
  # TODO: used for benchmarking and tests I think we have other better benchmarking
@@ -26,10 +26,11 @@ require 'coverband/reporters/console_report'
26
26
  require 'coverband/integrations/background'
27
27
  require 'coverband/integrations/rack_server_check'
28
28
  require 'coverband/reporters/web'
29
- require 'coverband/integrations/middleware'
29
+ require 'coverband/integrations/background_middleware'
30
30
  require 'coverband/integrations/background'
31
31
 
32
32
  module Coverband
33
+ @@configured = false
33
34
  CONFIG_FILE = './config/coverband.rb'
34
35
  RUNTIME_TYPE = nil
35
36
  EAGER_TYPE = :eager_loading
@@ -37,10 +38,6 @@ module Coverband
37
38
  TYPES = [RUNTIME_TYPE, EAGER_TYPE]
38
39
  ALL_TYPES = TYPES + [:merged]
39
40
 
40
- class << self
41
- attr_accessor :configuration_data
42
- end
43
-
44
41
  def self.configure(file = nil)
45
42
  configuration_file = file || ENV.fetch('COVERBAND_CONFIG', CONFIG_FILE)
46
43
  configuration
@@ -49,45 +46,60 @@ module Coverband
49
46
  elsif File.exist?(configuration_file)
50
47
  load configuration_file
51
48
  else
52
- configuration.logger&.debug('using default configuration')
49
+ configuration.logger.debug('using default configuration')
53
50
  end
54
- coverage.reset_instance
51
+ @@configured = true
52
+ coverage_instance.reset_instance
55
53
  end
56
54
 
57
- def self.report_coverage(force_report = false)
58
- Coverband::Collectors::Coverage.instance.report_coverage(force_report)
55
+ def self.configured?
56
+ @@configured
57
+ end
58
+
59
+ def self.report_coverage
60
+ coverage_instance.report_coverage
59
61
  end
60
62
 
61
63
  def self.configuration
62
- self.configuration_data ||= Configuration.new
64
+ @configuration ||= Configuration.new
63
65
  end
64
66
 
65
67
  def self.start
66
68
  Coverband::Collectors::Coverage.instance
67
- # TODO Railtie sets up at_exit after forks, via middleware, perhaps this hsould be
69
+ # TODO: Railtie sets up at_exit after forks, via middleware, perhaps this should be
68
70
  # added if not rails or if rails but not rackserverrunning
69
- AtExit.register
70
- Background.start if configuration.background_reporting_enabled && !RackServerCheck.running?
71
+ AtExit.register unless tasks_to_ignore?
72
+ Background.start if configuration.background_reporting_enabled && !RackServerCheck.running? && !tasks_to_ignore?
73
+ end
74
+
75
+ def self.tasks_to_ignore?
76
+ (defined?(Rake) &&
77
+ Rake.respond_to?(:application) &&
78
+ (Rake&.application&.top_level_tasks || []).any? { |task| Coverband::Configuration::IGNORE_TASKS.include?(task) })
71
79
  end
72
80
 
73
81
  def self.eager_loading_coverage!
74
- coverage.eager_loading!
82
+ coverage_instance.eager_loading!
83
+ end
84
+
85
+ def self.eager_loading_coverage(&block)
86
+ coverage_instance.eager_loading(&block)
75
87
  end
76
88
 
77
89
  def self.runtime_coverage!
78
- coverage.runtime!
90
+ coverage_instance.runtime!
79
91
  end
80
92
 
81
- def self.coverage
93
+ private_class_method def self.coverage_instance
82
94
  Coverband::Collectors::Coverage.instance
83
95
  end
84
-
85
96
  unless ENV['COVERBAND_DISABLE_AUTO_START']
86
97
  # Coverband should be setup as early as possible
87
98
  # to capture usage of things loaded by initializers or other Rails engines
88
99
  configure
89
100
  start
90
101
  require 'coverband/utils/railtie' if defined? ::Rails::Railtie
91
- require 'coverband/integrations/resque' if defined? Resque
102
+ require 'coverband/integrations/resque' if defined? ::Resque
103
+ require 'coverband/integrations/bundler' if defined? ::Bundler
92
104
  end
93
105
  end