bullet 4.7.1 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +17 -17
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile +9 -2
  6. data/Gemfile.mongoid-2.4 +22 -0
  7. data/Gemfile.mongoid-2.5 +22 -0
  8. data/Gemfile.mongoid-2.6 +22 -0
  9. data/Gemfile.mongoid-2.7 +22 -0
  10. data/Gemfile.mongoid-2.8 +22 -0
  11. data/Gemfile.mongoid-3.0 +22 -0
  12. data/Gemfile.mongoid-3.1 +22 -0
  13. data/Gemfile.rails-3.0 +21 -0
  14. data/Gemfile.rails-3.1 +21 -0
  15. data/Gemfile.rails-3.2 +21 -0
  16. data/Gemfile.rails-4.0 +21 -0
  17. data/{Gemfile.rails-3.0.20 → Gemfile.rails-4.1} +1 -1
  18. data/README.md +24 -23
  19. data/Rakefile +13 -6
  20. data/lib/bullet.rb +1 -1
  21. data/lib/bullet/active_record41.rb +97 -0
  22. data/lib/bullet/dependency.rb +11 -1
  23. data/lib/bullet/mongoid4x.rb +1 -1
  24. data/lib/bullet/registry/base.rb +1 -1
  25. data/lib/bullet/version.rb +1 -1
  26. data/spec/bullet/detector/association_spec.rb +8 -8
  27. data/spec/bullet/detector/base_spec.rb +1 -1
  28. data/spec/bullet/detector/counter_cache_spec.rb +12 -12
  29. data/spec/bullet/detector/n_plus_one_query_spec.rb +32 -32
  30. data/spec/bullet/detector/unused_eager_loading_spec.rb +18 -18
  31. data/spec/bullet/ext/object_spec.rb +2 -2
  32. data/spec/bullet/ext/string_spec.rb +2 -2
  33. data/spec/bullet/notification/base_spec.rb +19 -13
  34. data/spec/bullet/notification/counter_cache_spec.rb +2 -2
  35. data/spec/bullet/notification/n_plus_one_query_spec.rb +3 -3
  36. data/spec/bullet/notification/unused_eager_loading_spec.rb +2 -2
  37. data/spec/bullet/notification_collector_spec.rb +4 -4
  38. data/spec/bullet/rack_spec.rb +21 -21
  39. data/spec/bullet/registry/association_spec.rb +3 -3
  40. data/spec/bullet/registry/base_spec.rb +6 -6
  41. data/spec/bullet/registry/object_spec.rb +2 -2
  42. data/spec/integration/active_record3/association_spec.rb +107 -107
  43. data/spec/integration/active_record4/association_spec.rb +105 -105
  44. data/spec/integration/counter_cache_spec.rb +4 -4
  45. data/spec/integration/mongoid/association_spec.rb +52 -52
  46. data/spec/spec_helper.rb +0 -1
  47. data/test.sh +12 -11
  48. metadata +25 -38
  49. data/.ruby-gemset +0 -1
  50. data/.ruby-version +0 -1
  51. data/Gemfile.lock +0 -160
  52. data/Gemfile.mongoid-2.4.12 +0 -15
  53. data/Gemfile.mongoid-2.4.12.lock +0 -163
  54. data/Gemfile.mongoid-2.5.2 +0 -15
  55. data/Gemfile.mongoid-2.5.2.lock +0 -163
  56. data/Gemfile.mongoid-2.6.0 +0 -15
  57. data/Gemfile.mongoid-2.6.0.lock +0 -163
  58. data/Gemfile.mongoid-2.7.1 +0 -15
  59. data/Gemfile.mongoid-2.7.1.lock +0 -163
  60. data/Gemfile.mongoid-2.8.1 +0 -15
  61. data/Gemfile.mongoid-2.8.1.lock +0 -166
  62. data/Gemfile.mongoid-3.0.23 +0 -15
  63. data/Gemfile.mongoid-3.0.23.lock +0 -163
  64. data/Gemfile.mongoid-3.1.5 +0 -15
  65. data/Gemfile.mongoid-3.1.5.lock +0 -163
  66. data/Gemfile.mongoid.lock +0 -167
  67. data/Gemfile.rails-3.0.20.lock +0 -147
  68. data/Gemfile.rails-3.1.12 +0 -14
  69. data/Gemfile.rails-3.1.12.lock +0 -157
  70. data/Gemfile.rails-3.2.15 +0 -14
  71. data/Gemfile.rails-3.2.15.lock +0 -155
  72. data/Gemfile.rails-4.0.1 +0 -14
  73. data/Gemfile.rails-4.0.1.lock +0 -150
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23a5ae5e34731a4e77251140358e54f65cf0b679
4
- data.tar.gz: 8bd447a748a0a84fcd9eb05f45a7d0b0766e8d42
3
+ metadata.gz: 4ebb362baca8a029544d754fed872a09f7033377
4
+ data.tar.gz: f12124695713d21526305a4c381160048cdc93d6
5
5
  SHA512:
6
- metadata.gz: a7ce09517d39050d29067444ab0d9d21653fbf7aad7c983e6fd6bd01ccb4a56616f59f741676594775f41abe64e77c252f6cbedebe8bb3d35a952a7df153f72f
7
- data.tar.gz: f810b77bb0a1c7c7809d7c2eeac56cf967e46abb5b0241da65689175bf49a08e1a79f6f51afa0098a34ee73c9cea282b3f0c0e5053f5cebc8080309366292567
6
+ metadata.gz: 7aac621e2ddb3931bb385017401121641027980ebddf0d82d1b43c9a71040a7c2eba3af2c4cb7862d69f9c31c99ac1e124f6a60bd9be6e8388199c187effc98f
7
+ data.tar.gz: 721e946c60ebc8de7bd6c609abb90a9fd29c5c4df2ac275b8bb607e64cffcd86887fa7fc0c82fdd86303faf77d251519b49314dc9af1032131af039b9fd5f868
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ benchmark_profile*
11
11
  /nbproject/private/
12
12
  coverage/
13
13
  .coveralls.yml
14
+ Gemfile*.lock
@@ -1,20 +1,20 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.1.0
4
4
  gemfile:
5
- - Gemfile.rails-4.0.1
6
- - Gemfile.rails-3.2.15
7
- - Gemfile.rails-3.1.12
8
- - Gemfile.rails-3.0.20
9
- - Gemfile.mongoid-3.1.5
10
- - Gemfile.mongoid-3.0.23
11
- - Gemfile.mongoid-2.7.1
12
- - Gemfile.mongoid-2.8.1
13
- - Gemfile.mongoid-2.6.0
14
- - Gemfile.mongoid-2.5.2
15
- - Gemfile.mongoid-2.4.12
16
- env: DB=sqlite
17
- services: mongodb
18
- before_install:
19
- - gem uninstall json
20
- - gem install bundler
5
+ - Gemfile.rails-4.1
6
+ - Gemfile.rails-4.0
7
+ - Gemfile.rails-3.2
8
+ - Gemfile.rails-3.1
9
+ - Gemfile.rails-3.0
10
+ - Gemfile.mongoid-3.1
11
+ - Gemfile.mongoid-3.0
12
+ - Gemfile.mongoid-2.8
13
+ - Gemfile.mongoid-2.7
14
+ - Gemfile.mongoid-2.6
15
+ - Gemfile.mongoid-2.5
16
+ - Gemfile.mongoid-2.4
17
+ env:
18
+ - DB=sqlite
19
+ services:
20
+ - mongodb
@@ -1,5 +1,20 @@
1
1
  # Next Release
2
2
 
3
+ ## 4.8.0 (02/16/2014)
4
+
5
+ * Support rails 4.1.0.beta1
6
+ * Update specs to be RSepc 3.0 compatible
7
+ * Update latest minor version activerecord and mongoid on travis
8
+
9
+ ## 4.7.0 (11/03/2013)
10
+
11
+ * Add coverall support
12
+ * Add helper to profile code outside a request
13
+ * Add activesupport dependency
14
+ * Add Bullet.raise notification
15
+ * Add Bullet.add_footer notification
16
+ * Fix activerecord4 warnings in test code
17
+
3
18
  ## 4.6.0 (04/18/2013)
4
19
 
5
20
  * Fix Bullet::Rack to support sinatra
data/Gemfile CHANGED
@@ -3,8 +3,10 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'rails', github: 'rails/rails'
6
- gem 'sqlite3'
7
- gem 'mysql2'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
8
10
  gem 'activerecord-import'
9
11
 
10
12
  gem "rspec"
@@ -12,3 +14,8 @@ gem "guard"
12
14
  gem "guard-rspec"
13
15
 
14
16
  gem 'coveralls', require: false
17
+
18
+ platforms :rbx do
19
+ gem 'rubysl', '~> 2.0'
20
+ gem 'rubinius-developer_tools'
21
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 2.4.12'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 2.5.2'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 2.6.0'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 2.7.1'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 2.8'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 3.0.23'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,22 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.16'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+ gem 'mongoid', '~> 3.1.6'
12
+
13
+ gem "rspec"
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+
17
+ gem 'coveralls', require: false
18
+
19
+ platforms :rbx do
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'rubinius-developer_tools'
22
+ end
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.0.20'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+
12
+ gem "rspec"
13
+ gem "guard"
14
+ gem "guard-rspec"
15
+
16
+ gem 'coveralls', require: false
17
+
18
+ platforms :rbx do
19
+ gem 'rubysl', '~> 2.0'
20
+ gem 'rubinius-developer_tools'
21
+ end
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.1.12'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+
12
+ gem "rspec"
13
+ gem "guard"
14
+ gem "guard-rspec"
15
+
16
+ gem 'coveralls', require: false
17
+
18
+ platforms :rbx do
19
+ gem 'rubysl', '~> 2.0'
20
+ gem 'rubinius-developer_tools'
21
+ end
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 3.2.15'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+
12
+ gem "rspec"
13
+ gem "guard"
14
+ gem "guard-rspec"
15
+
16
+ gem 'coveralls', require: false
17
+
18
+ platforms :rbx do
19
+ gem 'rubysl', '~> 2.0'
20
+ gem 'rubinius-developer_tools'
21
+ end
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rails', '~> 4.0.1'
6
+ gem 'sqlite3', platforms: [:ruby]
7
+ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
+ gem 'mysql2', platforms: [:ruby]
9
+ gem 'activerecord-jdbcmysql-adapter', platforms: [:jruby]
10
+ gem 'activerecord-import'
11
+
12
+ gem "rspec"
13
+ gem "guard"
14
+ gem "guard-rspec"
15
+
16
+ gem 'coveralls', require: false
17
+
18
+ platforms :rbx do
19
+ gem 'rubysl', '~> 2.0'
20
+ gem 'rubinius-developer_tools'
21
+ end
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails', '3.0.20'
5
+ gem 'rails', '4.1.0.beta1'
6
6
  gem 'sqlite3'
7
7
  gem 'mysql2'
8
8
  gem 'activerecord-import'
data/README.md CHANGED
@@ -3,14 +3,14 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/bullet.png)](http://badge.fury.io/rb/bullet)
4
4
  [![Build Status](https://secure.travis-ci.org/flyerhzm/bullet.png)](http://travis-ci.org/flyerhzm/bullet)
5
5
  [![Coverage Status](https://coveralls.io/repos/flyerhzm/bullet/badge.png?branch=master)](https://coveralls.io/r/flyerhzm/bullet)
6
-
6
+ <a href="https://codeclimate.com/github/flyerhzm/bullet"><img src="https://codeclimate.com/github/flyerhzm/bullet.png" /></a>
7
7
  [![Coderwall Endorse](http://api.coderwall.com/flyerhzm/endorsecount.png)](http://coderwall.com/flyerhzm)
8
8
 
9
9
  The Bullet gem is designed to help you increase your application's performance by reducing the number of queries it makes. It will watch your queries while you develop your application and notify you when you should add eager loading (N+1 queries), when you're using eager loading that isn't necessary and when you should use counter cache.
10
10
 
11
11
  Best practice is to use Bullet in development mode or custom mode (staging, profile, etc.). The last thing you want is your clients getting alerts about how lazy you are.
12
12
 
13
- Bullet gem now supports **activerecord** 3.0, 3.1, 3.2, 4.0 and **mongoid** >= 2.4.1.
13
+ Bullet gem now supports **activerecord** >= 3.0 and **mongoid** >= 2.4.1.
14
14
 
15
15
  If you use activercord 2.x, please use bullet <= 4.5.0
16
16
 
@@ -27,7 +27,6 @@ You can install it as a gem:
27
27
 
28
28
  ```
29
29
  gem install bullet
30
-
31
30
  ```
32
31
 
33
32
  or add it into a Gemfile (Bundler):
@@ -138,42 +137,44 @@ If you find bullet does not work for you, *please disable your browser's cache*.
138
137
 
139
138
  ## Advanced
140
139
 
141
- The bullet gem uses rack middleware to profile requests. If you want to use bullet without an http server, like to profile a job, you can do this:
140
+ ### Profile a job
141
+
142
+ The bullet gem uses rack middleware to profile requests. If you want to use bullet without an http server, like to profile a job, you can use use profile method and fetch warnings
142
143
 
143
144
  ```ruby
144
145
  Bullet.profile do
145
- # run job
146
+ # do anything
146
147
  end
148
+ warnings = Bullet.warnings
147
149
  ```
148
150
 
149
- Or to use it in test mode:
151
+ ### Run in tests
152
+
153
+ First you need to enable bullet in test environment.
150
154
 
151
155
  ```ruby
156
+ # config/environments/test.rb
157
+ config.after_initialize do
158
+ Bullet.enable = true
159
+ Bullet.bullet_logger = true
160
+ Bullet.raise = true # raise an error if n+1 query occurs
161
+ end
162
+ ```
163
+
164
+ Then wrap each test in bullet api.
165
+
166
+ ```ruby
167
+ # spec/spec_helper.rb
152
168
  before(:each) do
153
169
  Bullet.start_request if Bullet.enable?
154
170
  end
155
171
 
156
172
  after(:each) do
157
- if Bullet.enable? && Bullet.notification?
158
- Bullet.perform_out_of_channel_notifications
159
- end
173
+ Bullet.perform_out_of_channel_notifications if Bullet.enable? && Bullet.notification?
160
174
  Bullet.end_request if Bullet.enable?
161
175
  end
162
176
  ```
163
177
 
164
- Don't forget to enable bullet in your test environment.
165
-
166
- ### API access
167
-
168
- after `profile`, you can fetch warnings then do whatever you want
169
-
170
- ```ruby
171
- Bullet.profile do
172
- # run anything
173
- end
174
- warnings = Bullet.warnings
175
- ```
176
-
177
178
  ## Contributors
178
179
 
179
180
  [https://github.com/flyerhzm/bullet/contributors](https://github.com/flyerhzm/bullet/contributors)
@@ -402,4 +403,4 @@ In the meanwhile, there's a log appended into `log/bullet.log` file.
402
403
  ```
403
404
 
404
405
 
405
- Copyright (c) 2009 - 2013 Richard Huang (flyerhzm@gmail.com), released under the MIT license
406
+ Copyright (c) 2009 - 2014 Richard Huang (flyerhzm@gmail.com), released under the MIT license