coverband 1.0.1 → 1.0.2

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
2
  SHA1:
3
- metadata.gz: ff5daaf6442d4b70be9c7f3888150f0a12a70661
4
- data.tar.gz: b0c48c0017f95a99b2a2215bbee1109808e8c5a8
3
+ metadata.gz: 053a4656762684a3293fdaf19c267660d8f1a495
4
+ data.tar.gz: 372ce2923b56e30cfe94ac2345e62b3db1974518
5
5
  SHA512:
6
- metadata.gz: 5a273640660fe4a87f2c7bc325865ad90f5ae0ce22d9f730d9e9002f9282e6421beccab62f5a973b6c6472c4ddf41745400815c133f1094309d70a54464b2772
7
- data.tar.gz: cac85909606d5fd2f45b93dd795dc3be8375d69e3651909d58c9982de0e1f4ff120615997e6af8031d03f8b90f889d3fc8cc2c7b6f9775433be6d8502c5860ba
6
+ metadata.gz: 7673df791c9d6f443d7b04436656d0e6800fd414e9c6363be6a6bfe89dc39b39437cd91954639cbc1f519001f66d5ba52af0ffa1120d217583c66985322c8256
7
+ data.tar.gz: c41882f81a929e15aa9068ddc03774a6fa6af3040dd3405f9b2ca334f8c4f742a9ec54df4dc1e637ed4120383ec1582990965e73334b720e8fbc383dba883bcc
data/README.md CHANGED
@@ -6,12 +6,14 @@ A gem to measure production code coverage. Coverband allows easy configuration t
6
6
  * Ignore directories to avoid overhead data collection on vendor, lib, etc.
7
7
  * Take a baseline to get initial app loading coverage.
8
8
 
9
- At the moment, Coverband relies on Ruby's `set_trace_func` hook. I attempted to use the standard lib's `Coverage` support but it proved buggy when sampling or stoping and starting collection. When [Coverage is patched](https://bugs.ruby-lang.org/issues/9572) in future Ruby versions it would likely be better. Using `set_trace_func` has some limitations where it doesn't collect covered lines, but I have been impressed with the coverage it shows for both Sinatra and Rails applications.
9
+ At the moment, Coverband relies on Ruby's `set_trace_func` hook. I attempted to use the standard lib's `Coverage` support but it proved buggy when sampling or stopping and starting collection. When [Coverage is patched](https://bugs.ruby-lang.org/issues/9572) in future Ruby versions it would likely be better. Using `set_trace_func` has some limitations where it doesn't collect covered lines, but I have been impressed with the coverage it shows for both Sinatra and Rails applications.
10
10
 
11
11
  ###### Success:
12
12
  After running in production for 30 minutes, we were able very easily delete 2000 LOC after looking through the data. We expect to be able to clean up much more after it has collected more data.
13
13
 
14
- This has now been running in production on many applications for months. I will clean up configurations, documentation, and strive to get a 1.0 release out soon.
14
+ ###### Performance Impact
15
+
16
+ At the moment the performance impact of standard Ruby runtime coverage can be pretty large. Once getting things working. I highly recommend adding [coverband_ext](https://github.com/danmayer/coverband_ext) to the project which should shave the performance overhead down to something very reasonable. The two ways to deal with performance right now are lowering the sample rate and using the C extension. Often for smaller projects using the C extension makes 100% coverage possible.
15
17
 
16
18
  ## Installation
17
19
 
@@ -45,17 +47,20 @@ Details on a example Sinatra app
45
47
 
46
48
  ## Notes
47
49
 
48
- * Using Redis 2.x gem, while supported, is extremely slow and not recommended. It will have a much larger impact on overhead performance.
49
- * This has been tested in Ruby 1.9.3, 2 and is running in production on Sinatra, Rails 2.3.x, and Rails 3.2.x
50
- * No 1.8.7 support
51
- * There is a performance impact which is why the gem supports sampling. On low traffic sites I am running a sample rake of 20% and on very high traffic sites I am sampling at 1%, which still gives excellent data
52
- * I believe there are possible ways to get even better data using the new [Ruby2 TracePoint API](http://www.ruby-doc.org/core/TracePoint.html)
53
- * Make sure to ignore any folders like `vendor` and possibly `lib` as it can help reduce performance overhead
50
+ * Coverband has been running in production on Ruby 1.9.3, 2.x, 2.1.x on Sinatra, Rails 2.3.x, Rails 3.0.x, Rails 3.1.x, and Rails 3.2.x
51
+ * No 1.8.7 support, Coverband requires Ruby 1.9.3+
52
+ * There is a performance impact which is why the gem supports sampling. On low traffic sites I am running a sample rate of 20% and on very high traffic sites I am sampling at 1%, which still gives useful data
53
+ * The impact with the pure Ruby coverband can't be rather significant on sampled requests
54
+ * Most of the overhead is in the Ruby coverage collector, you can now use [coverband_ext](https://github.com/danmayer/coverband_ext) to run a C extension collector which is MUCH faster.
55
+ * Using Redis 2.x gem, while supported, is slow and not recommended. It will have a larger impact on overhead performance. Although the Ruby collection dwarfs the redis time, so it likely doesn't matter much.
56
+ * Make sure to ignore any folders like `vendor` and possibly `lib` as it can help reduce performance overhead. Or ignore specific frequently hit in app files for better perf.
54
57
 
55
58
  ## Usage
56
59
 
57
60
  After installing the gem. There are a few steps to gather data, view reports, and for cleaning up the data.
58
61
 
62
+ See an [example Sinatra app](https://github.com/danmayer/churn-site) and example [non rack ruby app](https://github.com/danmayer/coverband_examples) configured with coverband.
63
+
59
64
  1. First configure cover band options using the config file, See the section below
60
65
  2. Then configure Rake, with helpful tasks. Make sure things are working by recording your Coverband baseline. See the section below
61
66
  3. Setup the rack middleware, the middleware is what makes Coverband gather metrics when your app runs. See below for details
@@ -67,9 +72,10 @@ After installing the gem. There are a few steps to gather data, view reports, an
67
72
 
68
73
  #### Configure Coverband Options
69
74
 
70
- You need to configure cover band you can either do that passing in all configuration options to `Coverband.configure` in block format, or a much 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 Sinatra app:
75
+ 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 Sinatra app:
71
76
 
72
77
  ```ruby
78
+ #config/coverband.rb
73
79
  require 'json'
74
80
 
75
81
  baseline = Coverband.parse_baseline
@@ -77,36 +83,32 @@ baseline = Coverband.parse_baseline
77
83
  Coverband.configure do |config|
78
84
  config.root = Dir.pwd
79
85
  if defined? Redis
80
- config.redis = Redis.new(:host => 'redis.host.com', :port => 49182, :db => 1)
86
+ config.redis = Redis.new(:host => 'redis.host.com', :port => 49182, :db => 1)
81
87
  end
82
88
  config.coverage_baseline = baseline
83
- config.root_paths = ['/app/']
84
- config.ignore = ['vendor']
89
+ config.root_paths = ['/app/'] # /app/ is needed for heroku deployments
90
+ # regex paths can help if you are seeing files duplicated for each capistrano deployment release
91
+ #config.root_paths = ['/server/apps/my_app/releases/\d+/']
92
+ config.ignore = ['vendor','lib/scrazy_i18n_patch_thats_hit_all_the_time.rb']
85
93
  # Since rails and other frameworks lazy load code. I have found it is bad to allow
86
94
  # initial requests to record with coverband. This ignores first 15 requests
87
- config.startup_delay = 15
88
- config.percentage = 60.0
95
+ config.startup_delay = Rails.env.production? ? 15 : 2
96
+ config.percentage = Rails.env.production? ? 30.0 : 100.0
97
+
98
+ config.logger = Rails.logger
99
+
100
+ #stats help you collect how often you are sampling requests and other info
89
101
  if defined? Statsd
90
- config.stats = Statsd.new('statsd.host.com', 8125)
102
+ config.stats = Statsd.new('statsd.host.com', 8125)
91
103
  end
104
+ # config options false, true, or 'debug'. Always use false in production
105
+ # true and debug can give helpful and interesting code usage information
106
+ # they both increase the performance overhead of the gem a little.
107
+ # they can also help with initially debugging the installation.
92
108
  config.verbose = Rails.env.production? ? false : true
93
109
  end
94
110
  ```
95
111
 
96
- Here is a alternative configuration example, allowing for production and development settings:
97
-
98
- ```ruby
99
- Coverband.configure do |config|
100
- config.root = Dir.pwd
101
- config.redis = Redis.new
102
- config.coverage_baseline = JSON.parse(File.read('./tmp/coverband_baseline.json'))
103
- config.root_paths = ['/app/']
104
- config.ignore = ['vendor']
105
- config.startup_delay = Rails.env.production? ? 10 : 1
106
- config.percentage = Rails.env.production? ? 15.0 : 100.0
107
- end
108
- ```
109
-
110
112
  #### Configuring Rake
111
113
 
112
114
  Either add the below to your `Rakefile` or to a file included in your Rakefile such as `lib/tasks/coverband` if you want to break it up that way.
@@ -125,7 +127,7 @@ rake coverband:clear # reset coverband coverage data
125
127
  rake coverband:coverage # report runtime coverband code coverage
126
128
  ```
127
129
 
128
- The default Coverband baseline task will try to load the Rails environment. For a non Rails application you can make your own baseline. Below for example is how I take a baseline on a Sinatra app.
130
+ The default Coverband baseline task will try to detect your app as either Rack or Rails environment. It will load the app to take a baseline reading. If the baseline task doesn't load your app well you can override the default baseline to create a better baseline yourself. Below for example is how I take a baseline on a pretty simple Sinatra app.
129
131
 
130
132
  ```ruby
131
133
  namespace :coverband do
@@ -139,7 +141,8 @@ namespace :coverband do
139
141
  end
140
142
  ```
141
143
 
142
- To verify that rake is working run `rake coverband:baseline` and then run `rake coverband:coverage` to view what your baseline coverage looks like before any runtime traffic has been recorded.
144
+ To verify that rake is working run `rake coverband:baseline`
145
+ then run `rake coverband:coverage` to view what your baseline coverage looks like before any runtime traffic has been recorded.
143
146
 
144
147
  #### Configure rack middleware
145
148
 
@@ -162,11 +165,13 @@ It is easy to use Coverband outside of a Rack environment. Make sure you configu
162
165
  For example if you had a base Resque class, you could use the `before_perform` and `after_perform` hooks to add Coverband
163
166
 
164
167
  ```ruby
168
+ require 'coverband'
169
+ Coverband.configure
170
+
165
171
  def before_perform(*args)
166
172
  if (rand * 100.0) <= Coverband.configuration.percentage
167
- @@coverband ||= Coverband::Base.new
168
173
  @recording_samples = true
169
- @@coverband.start
174
+ Coverband::Base.instance.start
170
175
  else
171
176
  @recording_samples = false
172
177
  end
@@ -174,23 +179,20 @@ end
174
179
 
175
180
  def after_perform(*args)
176
181
  if @recording_samples
177
- @@coverband.stop
178
- @@coverband.save
182
+ Coverband::Base.instance.stop
183
+ Coverband::Base.instance.save
179
184
  end
180
185
  end
181
186
  ```
182
187
 
183
- In general you can run Coverband anywhere by using the lines below
188
+ 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.
189
+
184
190
 
185
191
  ```ruby
186
- require 'coverband'
187
-
188
- Coverband.configure do |config|
189
- config.redis = Redis.new
190
- config.percentage = 50.0
191
- end
192
+ require "coverband"
193
+ Coverband.configure
192
194
 
193
- coverband = Coverband::Base.new
195
+ coverband = Coverband::Base.instance
194
196
 
195
197
  #manual
196
198
  coverband.start
@@ -203,7 +205,7 @@ coverband.sample {
203
205
  }
204
206
  ```
205
207
 
206
- ## Clearing Line Coverage Data
208
+ #### Clearing Line Coverage Data
207
209
 
208
210
  After a deploy where code has changed.
209
211
  The line numbers previously recorded in Redis may no longer match the current state of the files.
@@ -221,7 +223,7 @@ Coverband::Reporter.clear_coverage(Redis.new(:host => 'target.com', :port => 678
221
223
  You can also do this with the included rake tasks.
222
224
 
223
225
 
224
- ## Verbose debug mode for development
226
+ ### Verbose debug mode for development
225
227
 
226
228
  If you are trying to debug locally wondering what code is being run during a request. The verbose modes `config.verbose = true` and `config.verbose = 'debug'` can be useful. With true set it will output the number of lines executed per file, to the passed in log. The files are sorted from least used file to most active file. I have even run that mode in production without much of a problem. The debug verbose mode outputs both file usage and provides the number of calls per line of code. For example if you see something like below which indicates that the `application_helper` has 43150 lines executed. That might seem odd. Then looking at the breakdown of `application_helper` we can see that line `516` was executed 38,577 times. That seems bad, and is likely worth investigating perhaps memoizing or cacheing is required.
227
229
 
@@ -240,11 +242,29 @@ If you are trying to debug locally wondering what code is being run during a req
240
242
  [[448, 1], [202, 1],
241
243
  ...
242
244
  [517, 1617], [516, 38577]]
245
+
246
+ ### Merge coverage data over time
247
+
248
+ If you are clearing data on every deploy. You might want to write the data out to a file first. Then you could merge the data into the final results later.
243
249
 
250
+ ```ruby
251
+ data = JSON.generate Coverband::Reporter.get_current_scov_data
252
+ File.write("blah.json", data)
253
+ # Then later on, pass it in to the html reporter:
254
+ data = JSON.parse(File.read("blah.json"))
255
+ Coverband::Reporter.report :additional_scov_data => [data]
256
+ ```
257
+
258
+ #### Known issues
244
259
 
245
- ## TODO
260
+ * `set_trace_func` isn't perfect in sending each line of code executed and can be a bit wonky in a few places. Such as missing the `end` lines in code blocks. If you notice examples of this send them to me.
261
+ * If you don't have a baseline recorded your coverage can look odd like you are missing a bunch of data. It would be good if coverband gave a more actionable warning in this situation.
262
+ * 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.
263
+ * 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.
246
264
 
247
- * Fix network performance by logging to files that purge later (far more time lost in set_trace_func than sending files, hence not a high priority)
265
+ ### TODO
266
+
267
+ * Fix network performance by logging to files that purge later (like NR) (far more time lost in set_trace_func than sending files, hence not a high priority, but would be cool)
248
268
  * Add support for [zadd](http://redis.io/topics/data-types-intro) so one could determine single call versus multiple calls on a line, letting us determine the most executed code in production.
249
269
  * Possibly add ability to record code run for a given route
250
270
  * Improve client code api, around manual usage of sampling (like event usage)
@@ -252,17 +272,27 @@ If you are trying to debug locally wondering what code is being run during a req
252
272
  * blank rails app
253
273
  * blank Sinatra app
254
274
  * report on Coverband files that haven't recorded any coverage (find things like events and crons that aren't recording, or dead files)
255
- * ability to change the cover band config at runtime by changing the config pushed to the Redis hash. In memory cache around the changes to only make that call periodically.
275
+ * 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.
276
+
277
+ ## Contributing
278
+
279
+ 1. Fork it
280
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
281
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
282
+ 4. Push to the branch (`git push origin my-new-feature`)
283
+ 5. Create new Pull Request
256
284
 
257
285
  ## Resources
258
286
 
287
+ These notes of kind of for myself, but if anyone is seriously interested in contributing to the project, these resorces might be helpfu. I learned a lot looking at various existing projects and open source code.
288
+
259
289
  ##### Ruby Std-lib Coverage
260
290
 
261
291
  * [Fixed bug causing segfaults on 1.9.X](https://www.ruby-forum.com/topic/1811306)
262
292
  * [Current Coverage Bug causing issues on 2.1.1](https://bugs.ruby-lang.org/issues/9572)
263
293
  * [Ruby Coverage docs](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/coverage/rdoc/Coverage.html)
264
294
 
265
- ##### other
295
+ ##### Other
266
296
 
267
297
  * [erb code coverage](http://stackoverflow.com/questions/13030909/how-to-test-code-coverage-for-rails-erb-templates)
268
298
  * [more erb code coverage](https://github.com/colszowka/simplecov/issues/38)
@@ -273,14 +303,7 @@ If you are trying to debug locally wondering what code is being run during a req
273
303
  * [Jruby coverage bug](http://jira.codehaus.org/browse/JRUBY-6106?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel)
274
304
  * [learn from oboe ruby code](https://github.com/appneta/oboe-ruby#writing-custom-instrumentation)
275
305
  * [learn from stackprof](https://github.com/tmm1/stackprof#readme)
276
-
277
- ## Contributing
278
-
279
- 1. Fork it
280
- 2. Create your feature branch (`git checkout -b my-new-feature`)
281
- 3. Commit your changes (`git commit -am 'Add some feature'`)
282
- 4. Push to the branch (`git push origin my-new-feature`)
283
- 5. Create new Pull Request
306
+ * I believe there are possible ways to get even better data using the new [Ruby2 TracePoint API](http://www.ruby-doc.org/core/TracePoint.html)
284
307
 
285
308
  ## MIT License
286
309
  See the file license.txt for copying permission.
@@ -10,6 +10,8 @@ require 'coverband/middleware'
10
10
 
11
11
  module Coverband
12
12
 
13
+ CONFIG_FILE = './config/coverband.rb'
14
+
13
15
  class << self
14
16
  attr_accessor :configuration_data
15
17
  end
@@ -23,12 +25,16 @@ module Coverband
23
25
  end
24
26
 
25
27
  def self.configure(file = nil)
26
- self.configuration_data ||= Configuration.new
28
+ configuration
27
29
  if block_given?
28
30
  yield(configuration)
29
31
  else
30
- file ||= './config/coverband.rb'
31
- require file
32
+ if File.exists?(CONFIG_FILE)
33
+ file ||= CONFIG_FILE
34
+ require file
35
+ else
36
+ raise ArgumentError, "configure requires a block or the existance of a #{CONFIG_FILE} in your project"
37
+ end
32
38
  end
33
39
  end
34
40
 
@@ -89,7 +89,7 @@ module Coverband
89
89
  if @reporter
90
90
  if @reporter.class.name.match(/redis/i)
91
91
  before_time = Time.now
92
- @stats.increment "coverband.files.recorded_files", @files.length if @stats
92
+ @stats.count "coverband.files.recorded_files", @files.length if @stats
93
93
  @reporter.store_report(@files.dup)
94
94
  time_spent = Time.now - before_time
95
95
  @stats.timing "coverband.files.recorded_time", time_spent if @stats
@@ -132,17 +132,17 @@ module Coverband
132
132
  end
133
133
  end
134
134
 
135
+ # file from ruby coverband at this method call is a full path
136
+ # file from native coverband is also a full path
137
+ #
138
+ # at the moment the full paths don't merge so the 'last' one wins and each deploy
139
+ # with a normal capistrano setup resets coverage.
140
+ #
141
+ # should we make it relative in this method (slows down collection)
142
+ # -- OR --
143
+ # we could have the reporter MERGE the results after normalizing the filenames
144
+ # (went with this route see report_scov previous_line_hash)
135
145
  def add_file_without_checks(file, line)
136
- # file from ruby coverband at this method call is a full path
137
- # file from native coverband is also a full path
138
- #
139
- # at the moment the full paths don't merge so the 'last' one wins and each deploy
140
- # with a normal capistrano setup resets coverage.
141
- #
142
- # should we make it relative in this method (slows down collection)
143
- # -- OR --
144
- # we could have the reporter MERGE the results after normalizing the filenames
145
- # (went with this route see report_scov previous_line_hash)
146
146
  if @verbose
147
147
  @file_usage[file] += 1
148
148
  @file_line_usage[file] = Hash.new(0) unless @file_line_usage.include?(file)
@@ -12,7 +12,9 @@ module Coverband
12
12
  if Coverband.configuration.verbose
13
13
  Coverband.configuration.logger.info results.inspect
14
14
  end
15
-
15
+
16
+ config_dir = File.dirname(Coverband.configuration.baseline_file)
17
+ Dir.mkdir config_dir unless File.exists?(config_dir)
16
18
  File.open(Coverband.configuration.baseline_file, 'w') {|f| f.write(results.to_json) }
17
19
  end
18
20
 
@@ -24,18 +26,20 @@ module Coverband
24
26
  return
25
27
  end
26
28
  redis = Coverband.configuration.redis
27
- roots = Coverband.configuration.root_paths
29
+ roots = get_roots
28
30
  existing_coverage = Coverband.configuration.coverage_baseline
29
31
  open_report = options.fetch(:open_report){ true }
30
32
 
31
- roots << "#{current_root}/"
32
-
33
33
  if Coverband.configuration.verbose
34
34
  Coverband.configuration.logger.info "fixing root: #{roots.join(', ')}"
35
35
  end
36
36
 
37
37
  if Coverband.configuration.reporter=='scov'
38
- report_scov(redis, existing_coverage, roots, open_report)
38
+ additional_scov_data = options.fetch(:additional_scov_data){ [] }
39
+ if Coverband.configuration.verbose
40
+ print additional_scov_data
41
+ end
42
+ report_scov(redis, existing_coverage, additional_scov_data, roots, open_report)
39
43
  else
40
44
  lines = redis.smembers('coverband').map{|key| report_line(redis, key) }
41
45
  Coverband.configuration.logger.info lines.join("\n")
@@ -48,6 +52,12 @@ module Coverband
48
52
  redis.del("coverband")
49
53
  end
50
54
 
55
+ def self.get_roots
56
+ roots = Coverband.configuration.root_paths
57
+ roots << "#{current_root}/"
58
+ roots
59
+ end
60
+
51
61
  def self.current_root
52
62
  File.expand_path(Coverband.configuration.root)
53
63
  end
@@ -84,7 +94,12 @@ module Coverband
84
94
  merged
85
95
  end
86
96
 
87
- def self.report_scov(redis, existing_coverage, roots, open_report)
97
+
98
+ def self.get_current_scov_data
99
+ get_current_scov_data_imp(Coverband.configuration.redis, get_roots)
100
+ end
101
+
102
+ def self.get_current_scov_data_imp(redis, roots)
88
103
  scov_style_report = {}
89
104
  redis.smembers('coverband').each do |key|
90
105
  next if Coverband.configuration.ignore.any?{ |i| key.match(i)}
@@ -101,8 +116,17 @@ module Coverband
101
116
  end
102
117
  end
103
118
  scov_style_report = fix_file_names(scov_style_report, roots)
119
+ scov_style_report
120
+ end
121
+
122
+ def self.report_scov(redis, existing_coverage, additional_scov_data, roots, open_report)
123
+ scov_style_report = get_current_scov_data_imp redis, roots
104
124
  existing_coverage = fix_file_names(existing_coverage, roots)
105
125
  scov_style_report = merge_existing_coverage(scov_style_report, existing_coverage)
126
+
127
+ additional_scov_data.each do |data|
128
+ scov_style_report = merge_existing_coverage(scov_style_report, data)
129
+ end
106
130
 
107
131
  if Coverband.configuration.verbose
108
132
  Coverband.configuration.logger.info "report: "
@@ -139,9 +163,13 @@ module Coverband
139
163
  # /Users/danmayer/projects/cover_band_server/app/rb: ["54", "55"]
140
164
  # /Users/danmayer/projects/cover_band_server/views/layout/erb: ["0", "33", "36", "37", "38", "39", "40", "62", "63", "66", "65532", "65533"]
141
165
  def self.report_line(redis, key)
142
- "#{key}: #{redis.smembers("coverband.#{key}").inspect}" #" fix line styles
166
+ "#{key}: #{line_members(redis, key)}"
143
167
  end
144
168
 
169
+ def self.line_members(redis, key)
170
+ redis.smembers("coverband.#{key}").inspect
171
+ end
172
+
145
173
  def self.filename_from_key(key, roots)
146
174
  filename = key
147
175
  roots.each do |root|
@@ -25,24 +25,26 @@ namespace :coverband do
25
25
  rescue Exception
26
26
  #ignore
27
27
  end }
28
- end
29
- if File.exists?("#{Rails.root}/lib")
30
- Dir.glob("#{Rails.root}/lib/**/*.rb").sort.each { |file|
28
+ if File.exists?("#{Rails.root}/lib")
29
+ Dir.glob("#{Rails.root}/lib/**/*.rb").sort.each { |file|
31
30
  begin
32
31
  require_dependency file
33
32
  rescue Exception
34
33
  #ignoring file
35
34
  end}
35
+ end
36
36
  end
37
37
  }
38
38
  end
39
39
 
40
40
  ###
41
- # note: If have set a ton of simplecov filters you might want to override them and clear the filters or run the task below.
41
+ # note: If your project has set many simplecov filters.
42
+ # You might want to override them and clear the filters.
43
+ # Or run the task `coverage_no_filters` below.
42
44
  ###
43
45
  desc "report runtime coverband code coverage"
44
46
  task :coverage => :environment do
45
- Coverband::Reporter.report
47
+ Coverband::Reporter.report
46
48
  end
47
49
 
48
50
  def clear_simplecov_filters
@@ -51,12 +53,17 @@ namespace :coverband do
51
53
  end
52
54
  end
53
55
 
54
- desc "report runtime coverband code coverage"
56
+ desc "report runtime coverband code coverage after disabling simplecov filters"
55
57
  task :coverage_no_filters => :environment do
56
58
  clear_simplecov_filters
57
59
  Coverband::Reporter.report
58
60
  end
59
61
 
62
+ ###
63
+ # You likely want to clear coverage after significant code changes.
64
+ # You may want to have a hook that saves current coverband data on deploy
65
+ # and then resets the redis data.
66
+ ###
60
67
  desc "reset coverband coverage data"
61
68
  task :clear => :environment do
62
69
  Coverband::Reporter.clear_coverage
@@ -1,3 +1,3 @@
1
1
  module Coverband
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.2.2
161
+ rubygems_version: 2.4.5
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Rack middleware to help measure production code coverage