coverband 3.0.1 → 4.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6e6e4e2aa7c0271b100b0ce9dc5740719a85b6be
4
- data.tar.gz: 4be906bc977953bcba78c7d2bcf11f288fa21d15
2
+ SHA256:
3
+ metadata.gz: f4af70bbf7e6cdaf4fd8a83a22fe3586d040bdb03b255f0ede2daef2dd9ec5ae
4
+ data.tar.gz: 721b4a9029d26e2d182cf55280652f87a0cf1c3f40084bb692ac61417d7224ab
5
5
  SHA512:
6
- metadata.gz: f60a464c8df70d9663ae550ce40e85a3d3c72dc3e32fc27f5ea64af405b57b7354aec420b78cd83a3e60fe018cecd9b80d8f0ae26424a44b90a97f294a488345
7
- data.tar.gz: fee9a14503b7009ac42025df790d1c70ab78a33e79eb89bf18349ec25db1213ae6730036f866e1211cb9d4f652fda29becfacf18b0bf82052bc9834328af2056
6
+ metadata.gz: b8aeef26e11f9cb8e1b674bf97e55252acdbdee766f1870797ff6550495f5a06a2a3b17c92901843db7bdb5bb195d7a7d320fef4c49eddd4da0c36b00e8a8a9f
7
+ data.tar.gz: ce9ebbb91bbfe94e56646155417946e0d35ae1f757cf45047b12408855224ce9d9abcfa089c80c966222a507b13c2e5bc933ffb142d52643a36629b915a6f34f
data/Gemfile.rails4.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coverband (3.0.1.alpha)
4
+ coverband (4.0.0.alpha)
5
+ redis
5
6
  simplecov (> 0.11.1)
6
7
 
7
8
  GEM
@@ -157,7 +158,6 @@ DEPENDENCIES
157
158
  rack-test
158
159
  rails (~> 4)
159
160
  rake
160
- redis
161
161
  test-unit
162
162
 
163
163
  BUNDLED WITH
data/README.md CHANGED
@@ -4,191 +4,120 @@ Build Status: [![Build Status](https://travis-ci.org/danmayer/coverband.svg?bran
4
4
 
5
5
  <p align="center">
6
6
  <a href="#key-features">Key Features</a> •
7
- <a href="#coverband-demo">Coverband Demo</a> •
8
- <a href="#how-to-use">How To Use</a> •
9
7
  <a href="#installation">Installation</a> •
10
8
  <a href="#configuration">Configuration</a> •
9
+ <a href="#coverband-demo">Coverband Demo</a> •
10
+ <a href="#how-to-use">How To Use</a> •
11
11
  <a href="#usage">Usage</a> •
12
12
  <a href="#license">License</a> •
13
13
  <a href="/changes.md">Change Log / Roadmap</a>
14
14
  </p>
15
15
 
16
- A gem to measure production code usage, showing each line of code that is executed. Coverband allows easy configuration to collect and report on production code usage. It can be used as Rack middleware, wrapping a block with sampling, or manually configured to meet any need (like usage during background jobs).
16
+ A gem to measure production code usage, showing a counter for the number of times each line of code that is executed. Coverband allows easy configuration to collect and report on production code usage. It reports in the background via a thread or can be used as Rack middleware, or manually configured to meet any need.
17
17
 
18
- Note: Coverband is not intended for test code coverage, for that just check out [SimpleCov](https://github.com/colszowka/simplecov).
18
+ __Note:__ Coverband is not intended for test code coverage, for that we recommended using [SimpleCov](https://github.com/colszowka/simplecov).
19
19
 
20
20
  ## Key Features
21
21
 
22
22
  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.
23
23
 
24
24
  * Low performance overhead
25
- * Various controls from sampling, data collection rate, etc to further control performance
26
- * Ignore directories to avoid overhead data collection on vendor, lib, etc.
25
+ * Very simple setup and configuration
26
+ * Out of the box support for all standard code execution paths (web, cron, background jobs, rake tasks, etc)
27
+ * Easy to understand actionable insights from the report
27
28
  * Development mode, offers deep insight of code usage details (number of LOC execution during single request, etc) during development.
28
- * Easy setup for any Ruby Rack based web framework (Rails, Sinatra, etc)
29
- * Allows for integration with any other Ruby application flows (background jobs, crons, scripts)
30
-
31
- ## Coverband Demo
32
-
33
- 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 configuration and understanding of basic usage.
34
-
35
- # How To Use
36
-
37
- Below is my Coverband workflow, which hopefully will help other best use this library.
38
-
39
- * install coverband
40
- * start your app and hit a few endpoints
41
- * validate data collection and code coverage with `rake coverband:coverage`
42
- * test setup in development (hit endpoints and generate new report)
43
- * deploy to staging and verify functionality
44
- * deploy to production and verify functionality
45
- * every 2 weeks or so, with major releases
46
- * clear old coverage: `rake coverband:clear`
47
- * deploy and verify coverage is matching expectations
48
- * __COVERAGE DRIFT__
49
- * we are working to address this early in the 3.0.x feature set
50
- * https://github.com/danmayer/coverband/issues/118
51
- * if you never clear you have lines of code drift from when they were recorded
52
- * if you clear on every deploy you don't capture as useful of data
53
- * there is a tradeoff on accuracy and data value
54
- * I recommend clearing after major code changes, significant releases, or some regular schedule.
55
-
56
- ## Example Output
57
-
58
- Since Coverband is [Simplecov](https://github.com/colszowka/simplecov) output compatible it should work with any of the `SimpleCov::Formatter`'s available. The output below is produced using the default Simplecov HTML formatter.
59
-
60
- Index Page
61
- ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_index.png)
62
-
63
- Details on a example Sinatra app
64
- ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_details.png)
29
+ * Mountable web interface to easily share reports
65
30
 
66
31
 
67
32
  # Installation
68
33
 
69
- Follow the below section to install and configure Coverband.
70
-
71
- ![coverband installation](https://raw.githubusercontent.com/danmayer/coverband/master/docs/coverband-install-resize.gif)
72
-
73
- ## Prerequisites
74
-
75
- * Coverband 3.0 requres Ruby 2.3+
34
+ Coverband should be near zero config for Rails apps, if you have an issue with that, please [file an issue](https://github.com/danmayer/coverband/issues).
76
35
 
77
36
  ## Gem Installation
78
37
 
79
- Add this line to your application's Gemfile:
38
+ Add this line to your application's `Gemfile`, remember to `bundle install` after updating:
80
39
 
81
40
  ```bash
82
41
  gem 'coverband'
83
42
  ```
84
43
 
85
- And then execute:
86
-
87
- ```bash
88
- $ bundle
89
- ```
90
-
91
- Or install it yourself as:
92
-
93
- ```bash
94
- $ gem install coverband
95
- ```
44
+ ## Rails
96
45
 
97
- # Configuration
46
+ The Railtie integration means you shouldn't need to do anything anything else.
98
47
 
99
- After you have the gem, you will want to setup the needed integration:
48
+ * By default Coverband will try to stored data to Redis
49
+ * Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
100
50
 
101
- 1. Coverband Config File Setup
102
- 2. Configure Rake
103
- 3. Insert Coverband Rack Middleware
51
+ ## Sinatra
104
52
 
105
- ### 1. Coverband Config File Setup
106
-
107
- You need to configure cover band you can either do that passing in all configuration options to `Coverband.configure` in block format, or a simpler style is to call `Coverband.configure` with nothing while will load `config/coverband.rb` expecting it to configure the app correctly. Below is an example config file for a Rails 5 app:
53
+ For the best coverage you want this loaded as early as possible. I have been putting it directly in my `config.ru` but you could use an initializer, though you may end up missing some boot up coverage. To start collection require Coverband as early as possible.
108
54
 
109
55
  ```ruby
110
- #config/coverband.rb
111
- Coverband.configure do |config|
112
- config.root = Dir.pwd
113
- config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: ENV['REDIS_URL'])) if defined? Redis
114
- config.ignore = %w[vendor .erb$ .slim$]
115
- # add paths that you deploy to that might be different than your local dev root path
116
- config.root_paths = []
117
-
118
- # reporting frequency, how often coverage data is sent to the store
119
- # if you are debugging changes to coverband I recommend setting to 100.0
120
- config.reporting_frequency = Rails.env.production? ? 1.0 : 100.0
121
- config.logger = Rails.logger
56
+ require 'coverband'
57
+ require File.dirname(__FILE__) + '/config/environment'
122
58
 
123
- # config options false, true, or 'debug'. Always use false in production
124
- # true and debug can give helpful and interesting code usage information
125
- # they both increase the performance overhead of the gem a little.
126
- # they can also help with initially debugging the installation.
127
- # config.verbose = 'debug'
128
- end
59
+ use Coverband::Middleware
60
+ run ActionController::Dispatcher.new
129
61
  ```
130
62
 
131
- ### 2. Configure Rake
63
+ # Report Generation
132
64
 
133
- Either add the below to your `Rakefile` or to a file included in your Rakefile such as `lib/tasks/coverband.rake` if you want to break it up that way.
65
+ There are two primary ways to generate and view the report
134
66
 
135
- ```ruby
136
- require 'coverband'
137
- Coverband.configure
138
- require 'coverband/utils/tasks'
139
- ```
140
- This should give you access to a number of Coverband tasks
67
+ ## Rake Tasks
68
+
69
+ After installing the gem in Rails you should have these Rake tasks
141
70
 
142
71
  ```bash
143
72
  rake -T coverband
144
- rake coverband:clear # reset coverband coverage data
145
- rake coverband:coverage # report runtime coverband code coverage
73
+ rake coverband:coverage # report runtime Coverband code coverage
74
+ rake coverband:clear # reset Coverband coverage data, helpful for development, debugging, etc
146
75
  ```
147
76
 
148
- ### 3. Configure Rack to use the Coverband middleware
77
+ You can view the report different ways, but the easiest is the Rake task which opens the SimpleCov formatted HTML.
149
78
 
150
- The middleware is what makes Coverband gather metrics while a webapp app runs.
79
+ `rake coverband:coverage`
151
80
 
152
- #### For Rails apps
81
+ This should auto-open in your browser, but if it doesn't the output file should be in `coverage/index.html`
153
82
 
154
- There are a number of options for starting Coverband and when to insert it into your middleware stack. At the moment this is my recommendation, to ensure you capture usage data on any files required by other plugins.
83
+ ## Viewing the Report in App
155
84
 
156
- Then add the middleware to your Rails rake middle ware stack:
85
+ First setup Coverband to [write reports to S3](#writing-coverband-results-to-s3) you can host the S3 file with a built in rack app in Coverband. Just configure your Rails route `config/routes.rb`
157
86
 
158
- ```ruby
159
- # config/application.rb
160
- [...]
161
-
162
- module MyApplication
163
- class Application < Rails::Application
164
- [...]
165
-
166
- # Coverband needs to be setup before any of the initializers to capture usage of them
167
- require 'coverband'
168
- Coverband.configure
169
- config.middleware.use Coverband::Middleware
170
-
171
- # if one uses before_eager_load as I did previously
172
- # any files that get loaded as part of railties will have no coverage
173
- config.before_initialize do
174
- Coverband.start
175
- end
176
- end
87
+ ```
88
+ Rails.application.routes.draw do
89
+ # ... lots of routes
90
+ mount Coverband::Reporters::Web.new, at: '/coverage'
177
91
  end
178
92
  ```
179
93
 
180
- #### For Sinatra apps
94
+ __NOTE__: ADD PASSWORD PROTECTION OR YOU CAN EXPOSE ALL YOUR SOURCE CODE
181
95
 
182
- For the best coverage you want this loaded as early as possible. I have been putting it directly in my `config.ru` but you could use an initializer, though you may end up missing some boot up coverage.
96
+ It is easy to add basic protection around the coverage data, below shows how you can use devise or basic auth, by adding a bit of code to your `config/routes.rb` file.
183
97
 
184
- ```ruby
185
- require File.dirname(__FILE__) + '/config/environment'
98
+ ```
99
+ # protect with existing Rails devise configuration
100
+ devise_constraint = lambda do |request|
101
+ request.env['warden'] && request.env['warden'].authenticate? && request.env['warden'].user.admin?
102
+ end
186
103
 
187
- require 'coverband'
188
- Coverband.configure
104
+ # protect with http basic auth
105
+ # curl --user foo:bar http://localhost:3000/coverage
106
+ Rails.application.routes.draw do
107
+ # ... lots of routes
189
108
 
190
- use Coverband::Middleware
191
- run ActionController::Dispatcher.new
109
+ # Create a Rack wrapper around the Coverband Web Reporter to support & prompt the user for basic authentication.
110
+ AuthenticatedCoverband = Rack::Builder.new do
111
+ use Rack::Auth::Basic do |username, password|
112
+ username == 'foo' && password == 'bar'
113
+ end
114
+
115
+ run Coverband::Reporters::Web.new
116
+ end
117
+
118
+ # Connect the wrapper app to your desired endpoint.
119
+ mount AuthenticatedCoverband, at: '/coverage'
120
+ end
192
121
  ```
193
122
 
194
123
  # Verify Correct Installation
@@ -199,55 +128,21 @@ run ActionController::Dispatcher.new
199
128
  * make another request, or enough that your reporting frequency will trigger
200
129
  * run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
201
130
 
202
- ## Installation Session
203
-
204
- These are the steps taken to install and configure Coverband
205
-
206
- ```
207
- rails new coverage_example
208
- cd coverage_example
209
- atom .
210
-
211
- # open Gemfile, add lines
212
- gem 'redis'
213
- gem 'coverband', '>= 3.0.0.alpha2', require: false
214
-
215
- bundle install
216
-
217
- # create config/coverband.rb
218
- # copy the config from the readme
219
- # If you don't set REDIS_URL, remove that to use default localhost
220
-
221
- # Make some code so we can look at the coverage
222
- rails generate scaffold blogs
223
- rake db:migrate
224
-
225
- # open Rakefile, add lines
226
- require 'coverband'
227
- Coverband.configure
228
- require 'coverband/utils/tasks'
229
-
230
- # verify rake
231
- rake -T coverband
232
-
233
- # configure config/application.rb
234
- # copy lines from readme
235
-
236
- # start up your app
237
- rake coverband:coverage
238
- # view boot up coverage
239
-
240
- rails s
131
+ # Coverband Demo
241
132
 
242
- open http://localhost:3000/blogs
133
+ 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.
243
134
 
244
- # click around some to trigger usage
135
+ # How To Use
245
136
 
246
- # view updated coverage
247
- rake coverband:coverage
248
- ```
137
+ Below is my Coverband workflow, which hopefully will help other best use this library.
249
138
 
250
- # Usage
139
+ * <a href="#installation">Install Coverband</a>
140
+ * Start your app and hit a few endpoints
141
+ * Validate data collection and code coverage with `rake coverband:coverage`
142
+ * If you see app startup and recent visits showing, setup is correct
143
+ * I generally configure the mountable web endpoint to [view the data via the web-app](https://github.com/danmayer/coverband#viewing--hosting-s3-coverband-results-in-app)
144
+ * After Coverband has been verified to be working on production, I let it run for a few weeks.
145
+ * Then I view the report and start submitting PRs for the team to review delete large related sets of code that no longer are in use.
251
146
 
252
147
  ### Example apps
253
148
 
@@ -255,132 +150,92 @@ rake coverband:coverage
255
150
  - [Sinatra app](https://github.com/danmayer/churn-site)
256
151
  - [Non Rack Ruby app](https://github.com/danmayer/coverband_examples)
257
152
 
258
- ### View Coverage
153
+ ### Example Output
259
154
 
260
- You can view the report different ways, but the easiest is the Rake task which opens the SimpleCov formatted HTML.
261
-
262
- `rake coverband:coverage`
263
-
264
- This should auto-open in your browser, but if it doesn't the output file should be in `coverage/index.html`
265
-
266
- ### Clear Coverage
267
-
268
- If your code has changed and your coverage line data doesn't seem to match run time. You probably need to clear your old line data... You will need to run this in the environment you wish to clear the data from.
269
-
270
- `rake coverband:clear`
271
-
272
- ### Automated Clearing Line Coverage Data
273
-
274
- After a deploy where code has changed significantly. This is to avoid coverage drift
155
+ Since Coverband is [Simplecov](https://github.com/colszowka/simplecov) output compatible it should work with any of the `SimpleCov::Formatter`'s available. The output below is produced using the default Simplecov HTML formatter.
275
156
 
276
- The line numbers previously recorded in Redis may no longer match the current state of the files.
277
- If being slightly out of sync isn't as important as gathering data over a long period,
278
- you can live with minor inconsistency for some files.
157
+ Index Page
158
+ ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_index.png)
279
159
 
280
- As often as you like or as part of a deploy hook you can clear the recorded Coverband data with the following command.
160
+ Details on a example Sinatra app
161
+ ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_details.png)
281
162
 
282
- ```ruby
283
- # defaults to the currently configured Coverband.configuration.redis
284
- Coverband::Reporter.clear_coverage
285
- # or pass in the current target redis
286
- Coverband::Reporter.clear_coverage(Redis.new(:host => 'target.com', :port => 6789))
287
- ```
288
- You can also do this with the included rake tasks.
163
+ ### Advanced Coverband Config
289
164
 
290
- ### Manual Configuration (for example for background jobs)
165
+ You may need to configure Coverband you can either do that passing in all configuration options to `Coverband.configure` in block format, or a simpler style is to call `Coverband.configure` with no params which will load `config/coverband.rb` expecting it to configure the app correctly.
291
166
 
292
- It is easy to use Coverband outside of a Rack environment. Make sure you configure Coverband in whatever environment you are using (such as `config/initializers/*.rb`). Then you can hook into before and after events to add coverage around background jobs, or for any non Rack code.
167
+ * See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
168
+ * I strongly recommend setting up the S3 report adapter, which can't be automatically configured
169
+ * By default Coverband will try to stored data to Redis
170
+ * Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
293
171
 
294
- For example if you had a base Resque class, you could use the `before_perform` and `after_perform` hooks to add Coverband
172
+ Below is an example config file for a Rails 5 app:
295
173
 
296
174
  ```ruby
297
- require 'coverband'
298
- Coverband.configure
299
- Coverband.start
175
+ #config/coverband.rb
176
+ Coverband.configure do |config|
177
+ # configure S3 integration
178
+ config.s3_bucket = 'coverband-demo'
179
+ config.s3_region = 'us-east-1'
180
+ config.s3_access_key_id = ENV['AWS_ACCESS_KEY_ID']
181
+ config.s3_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
300
182
 
301
- def after_perform(*args)
302
- if @recording_samples
303
- Coverband::Collectors::Coverage.instance.report_coverage
304
- end
183
+ # config options false, true, or 'debug'. Always use false in production
184
+ # true and debug can give helpful and interesting code usage information
185
+ # they both increase the performance overhead of the gem a little.
186
+ # they can also help with initially debugging the installation.
187
+ config.verbose = false
305
188
  end
306
189
  ```
307
190
 
308
- or sidekiq middleware:
191
+ ### Writing Coverband Results to S3
309
192
 
310
- ```ruby
311
- # capture code usage in background jobs
312
- class CoverbandMiddleware
313
- def call(_worker, _msg, _queue)
314
- Coverband.start
315
- yield
316
- ensure
317
- Coverband::Collectors::Coverage.instance.report_coverage
318
- end
319
- end
320
-
321
- ...
322
- chain.add Sidekiq::CoverbandMiddleware
193
+ If you add some additional Coverband configuration your coverage html report will be written directly to S3, update `config/coverband.rb` like below.
194
+
195
+ ```
196
+ # configure S3 integration
197
+ config.s3_bucket = 'coverband-demo'
198
+ config.s3_region = 'us-east-1'
199
+ config.s3_access_key_id = ENV['AWS_ACCESS_KEY_ID']
200
+ config.s3_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
323
201
  ```
324
202
 
325
- In general you can run Coverband anywhere by using the lines below. This can be useful to wrap all cron jobs, background jobs, or other code run outside of web requests. I recommend trying to run both background and cron jobs at 100% coverage as the performance impact is less important and often old code hides around those jobs.
203
+ Alternatively, Coverband if you don't set via the `config.s3_*` accessor methods will look for the standard S3 environment variables.
326
204
 
205
+ ```
206
+ ENV['AWS_BUCKET']
207
+ ENV['AWS_REGION']
208
+ ENV['AWS_ACCESS_KEY_ID']
209
+ ENV['AWS_SECRET_ACCESS_KEY']
210
+ ```
327
211
 
328
- ```ruby
329
- require "coverband"
330
- Coverband.configure
331
- Coverband.start
212
+ ### Clear Coverage
332
213
 
333
- # do whatever
334
- Coverband::Collectors::Coverage.instance.report_coverage
214
+ Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging Coberband itself.
335
215
 
336
- ```
216
+ `rake coverband:clear`
337
217
 
338
- ### Manual Configuration (for cron jobs / Raketasks)
218
+ ### Adding Rake Tasks outside of Rails
339
219
 
340
- A question about [supporting cron jobs and Rake tasks](https://github.com/danmayer/coverband/issues/106) was asked by [@ndbroadbent](https://github.com/ndbroadbent), there are a couple ways to go about it including his good suggestion.
220
+ Rails apps should automaticallly include the tasks via the Railtie.
341
221
 
342
- He extended the Coverband Rake tasks by adding `lib/tasks/coverband.rake` with support to wrap all Rake tasks with coverband support.
222
+ For non Rails apps, either add the below to your `Rakefile` or to a file included in your `Rakefile` such as `lib/tasks/coverband.rake` if you want to break it up that way.
343
223
 
344
- ```
224
+ ```ruby
345
225
  require 'coverband'
346
226
  Coverband.configure
347
227
  require 'coverband/utils/tasks'
348
-
349
- # Wrap all Rake tasks with Coverband
350
- current_tasks = Rake.application.top_level_tasks
351
- if current_tasks.any? && current_tasks.none? { |t| t.to_s.match?(/^coverband:/) }
352
- current_tasks.unshift 'coverband:start'
353
- current_tasks.push 'coverband:stop_and_save'
354
- end
355
-
356
- namespace :coverband do
357
- task :start do
358
- Coverband.start
359
- end
360
-
361
- task :stop_and_save do
362
- Coverband::Collectors::Coverage.instance.report_coverage
363
- end
364
- end
365
228
  ```
366
229
 
367
- That is a interesting approach and if you Run all your cron jobs as Rake tasks might work well for you. In a production application where we run Coverband, we run all of our Cron jobs with the `rails runner` script. We took this alternative approach which will wrap all runner jobs with Coverband recording, by creating `lib/railties/coverage_runner.rb`.
230
+ Verify it works
368
231
 
369
- ```
370
- require 'rails'
371
-
372
- # Capture code coverage during our cron jobs
373
- class CoverageRunner < ::Rails::Railtie
374
- runner do
375
- Coverband.start
376
- at_exit do
377
- Coverband::Collectors::Coverage.instance.report_coverage
378
- end
379
- end
380
- end
232
+ ```bash
233
+ rake -T coverband
234
+ rake coverband:clear # reset coverband coverage data
235
+ rake coverband:coverage # report runtime coverband code coverage
381
236
  ```
382
237
 
383
- ### safe_reload_files: Forcing Coverband to Track Coverage on Files loaded during boot
238
+ ### Forcing Coverband to Track Coverage on files loaded during boot `safe_reload_files`
384
239
 
385
240
  The way Coverband is built it will record and report code usage in production for anything `required` or `loaded` after calling `Coverband.start`. This means some of Rails initial files and Gems are loaded before you can generally call `Coverband.start` for example if you use the `application.rb` to initialize and start Coverband, that file will be reported as having no coverage, as it can't possibly start Coverband before the file is loaded.
386
241
 
@@ -400,20 +255,18 @@ By adding any files above you will get reporting on those files as part of your
400
255
 
401
256
  By default Coverband has assumed you are trying to track your application code usage not all the supporting framework and library (Gems) code usage. There has been some good points and reasons folks want to track library usage, for example to find out which Gems they aren't actually using in production. See some of the discussion on [issue 21](https://github.com/danmayer/coverband/issues/21).
402
257
 
403
- * Using the Tracepoint Collector
404
- * just make sure to set `Coverband.configuration.include_gems = true` in your config options
405
- * note by tracking all the additional usage this can have significant performance impacts of the Tracepoint implementation
406
- * Using the Coverage Collector
407
- * use the `safe_reload_files` feature to add the path of all gem files you wish to track
408
- * --- or ---
409
- * ensure you call `Coverband.start` before loading all your gems
410
- * while possible this is currently hard as Rails and most environments load your whole Gemfile
411
- * looking for an improve and easier way to support this.
258
+ How to collect gem usage with Coverband:
259
+
260
+ * use the `safe_reload_files` feature to add the path of all gem files you wish to track
261
+ * --- or ---
262
+ * ensure you call `require 'coverband'` which triggers `Coverband.start` before loading all your gems
263
+ * while possible this is currently hard as Rails and most environments load your whole Gemfile
264
+ * we are looking for an improve and easier way to support this.
412
265
 
413
266
 
414
267
  ### Verbose Debug / Development Mode
415
268
 
416
- Note: To debug issues getting coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. This makes it easy to follow in development mode. Be careful to not leave these on in production as they will affect performance.
269
+ Note: To debug issues getting Coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. This makes it easy to follow in development mode. Be careful to not leave these on in production as they will affect performance.
417
270
 
418
271
  ---
419
272
 
@@ -435,57 +288,6 @@ If you are trying to debug locally wondering what code is being run during a req
435
288
  ...
436
289
  [517, 1617], [516, 38577]]
437
290
 
438
- ### Writing Coverband Results to S3
439
-
440
- If you add some additional Coverband configuration your coverage html report will be written directly to S3, update `config/coverband.rb` like below.
441
-
442
- ```
443
- # configure S3 integration
444
- config.s3_bucket = 'coverband-demo'
445
- config.s3_region = 'us-east-1'
446
- config.s3_access_key_id = ENV['AWS_ACCESS_KEY_ID']
447
- config.s3_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
448
- ```
449
-
450
- ### Viewing / Hosting S3 Coverband results in app
451
-
452
- Beyond writing to S3 you can host the S3 file with a build in Sintatra app in Coverband. Just configure your Rails route `config/routes.rb`
453
-
454
- ```
455
- Rails.application.routes.draw do
456
- # ... lots of routes
457
- mount Coverband::Reporters::Web.new, at: '/coverage'
458
- end
459
- ```
460
-
461
- __NOTE__: ADD PASSWORD PROTECTION OR YOU CAN EXPOSE ALL YOUR SOURCE CODE
462
-
463
- It is easy to add some basic protect around the coverage data, below shows how you can use devise or basic auth, by adding a bit of code to your `config/routes.rb` file.
464
-
465
- ```
466
- # protect with existing Rails devise configuration
467
- devise_constraint = lambda do |request|
468
- request.env['warden'] && request.env['warden'].authenticate? && request.env['warden'].user.admin?
469
- end
470
-
471
- # protect with http basic auth
472
- # curl --user foo:bar http://localhost:3000/coverage
473
- Rails.application.routes.draw do
474
- # ... lots of routes
475
-
476
- # Create a Rack wrapper around the Coverband Web Reporter to support & prompt the user for basic authentication.
477
- AuthenticatedCoverband = Rack::Builder.new do
478
- use Rack::Auth::Basic do |username, password|
479
- username == 'foo' && password == 'bar'
480
- end
481
-
482
- run Coverband::Reporters::Web.new
483
- end
484
-
485
- # Connect the wrapper app to your desired endpoint.
486
- mount AuthenticatedCoverband, at: '/coverage'
487
- end
488
- ```
489
291
 
490
292
  ### Conflicting .Simplecov: Issue with Missing or 0% Coverage Report
491
293
 
@@ -511,6 +313,11 @@ You could see some confusing results... To avoid this issue Coverband has a Rake
511
313
 
512
314
  This will build the report after disabling any `.simplecov` applied settings.
513
315
 
316
+ # Prerequisites
317
+
318
+ * Coverband 3.0.X+ requires Ruby 2.3+
319
+ * Coverband currently requires Redis for production usage
320
+
514
321
  # Contributing To Coverband
515
322
 
516
323
  If you are working on adding features, PRs, or bugfixes to Coverband this section should help get you going.
@@ -536,7 +343,7 @@ If you submit a change please make sure the tests and benchmarks are passing.
536
343
  ### Known Issues
537
344
 
538
345
  * __total fail__ on front end code, because of the precompiled template step basically coverage doesn't work well for `erb`, `slim`, and the like.
539
- * related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option.
346
+ * related it will try to report something, but the line numbers reported for `ERB` files are often off and aren't considered useful. I recommend filtering out .erb using the `config.ignore` option. The default configuration excludes these files
540
347
  * If you have SimpleCov filters, you need to clear them prior to generating your coverage report. As the filters will be applied to Coverband as well and can often filter out everything we are recording.
541
348
  * coverage doesn't show for Rails `config/application.rb` or `config/boot.rb` as they get loaded when loading the Rake environment prior to starting the `Coverage` library.
542
349