bullet 4.14.4 → 4.14.5

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: bbb4f34774c895c76a37a414109e24ca1217a2a5
4
- data.tar.gz: bb7632755a33243163cfccd5285fd305c74adac0
3
+ metadata.gz: 6a56f8b0100130149fc7c45ceb660b4b100b84b8
4
+ data.tar.gz: 44a4a67d0ab54bbc6ab8cfef656257e40131e7ab
5
5
  SHA512:
6
- metadata.gz: 3e09a8384a358f7db6f3fee7b94a613af8f08ee0e4079394a595f794737f8b397e80c3ac76f0808e8d1c3993e14c97a65162497baad8652b130f76d69646b55c
7
- data.tar.gz: 904ed8a5c66a7d2d9479f0e4d82246d0f1f818548bbcfc33bc13eaf4b8e42dc2ce75fb4481741c9ae5597fcb6f84528b1671eb9bfe46be8985d20a9f2917acd2
6
+ metadata.gz: bdb47a4a12f599a6c35113a13ba9ed3559c220e06731beb2ff86d4bec9de0a019425c47d3b19c22e987d7106a930a15c985c56f057edd521a6a5000a76c126d8
7
+ data.tar.gz: 872c82a3e4d7ce373064c7738a45a012e1a001c35b428c49380635723d119bb3828a48e336eed733cdd2bf48905f6ad627dc6061a20b51ebf0b294aa093ca3a4
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.2
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
4
6
  gemfile:
5
7
  - Gemfile.rails-4.2
6
8
  - Gemfile.rails-4.1
@@ -8,6 +10,7 @@ gemfile:
8
10
  - Gemfile.rails-3.2
9
11
  - Gemfile.rails-3.1
10
12
  - Gemfile.rails-3.0
13
+ - Gemfile.mongoid-4.0
11
14
  - Gemfile.mongoid-3.1
12
15
  - Gemfile.mongoid-3.0
13
16
  - Gemfile.mongoid-2.8
@@ -19,3 +22,25 @@ env:
19
22
  - DB=sqlite
20
23
  services:
21
24
  - mongodb
25
+ matrix:
26
+ exclude:
27
+ - rvm: 2.2
28
+ gemfile: Gemfile.rails-3.0
29
+ - rvm: 2.2
30
+ gemfile: Gemfile.rails-3.1
31
+ - rvm: 2.2
32
+ gemfile: Gemfile.rails-3.2
33
+ - rvm: 2.2
34
+ gemfile: Gemfile.mongoid-3.1
35
+ - rvm: 2.2
36
+ gemfile: Gemfile.mongoid-3.0
37
+ - rvm: 2.2
38
+ gemfile: Gemfile.mongoid-2.8
39
+ - rvm: 2.2
40
+ gemfile: Gemfile.mongoid-2.7
41
+ - rvm: 2.2
42
+ gemfile: Gemfile.mongoid-2.6
43
+ - rvm: 2.2
44
+ gemfile: Gemfile.mongoid-2.5
45
+ - rvm: 2.2
46
+ gemfile: Gemfile.mongoid-2.4
@@ -1,5 +1,12 @@
1
1
  # Next Release
2
2
 
3
+ ## 4.14.5
4
+
5
+ * Don't execute query when running `to_sql`
6
+ * Send backtrace to `uniform_notifier`
7
+ * Fix sse response check
8
+ * Dynamically delegate available notifiers to UniformNotifier
9
+
3
10
  ## 4.14.4
4
11
 
5
12
  * Fix false N + 1 warnings on Rails 4.2
@@ -10,11 +17,11 @@
10
17
 
11
18
  ## 4.14.2
12
19
 
13
- * Hotfix nil object when add_impossible_object
20
+ * Hotfix nil object when `add_impossible_object`
14
21
 
15
22
  ## 4.14.1
16
23
 
17
- * Fix has_one then has_many associations in rails 4.2
24
+ * Fix `has_one` then `has_many` associations in rails 4.2
18
25
  * Append js and dom to html body in proper position
19
26
 
20
27
  ## 4.14.0 (10/03/2014)
@@ -8,7 +8,5 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', github: 'mongoid/mongoid'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.4.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.5.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.6.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.7.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 2.8.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 3.0.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 3.1.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'mongoid', '~> 4.0.0'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
@@ -8,8 +8,6 @@ gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
8
8
  gem 'activerecord-import'
9
9
 
10
10
  gem "rspec"
11
- gem "guard"
12
- gem "guard-rspec"
13
11
 
14
12
  gem 'coveralls', require: false
15
13
 
data/README.md CHANGED
@@ -55,8 +55,10 @@ config.after_initialize do
55
55
  Bullet.rails_logger = true
56
56
  Bullet.bugsnag = true
57
57
  Bullet.airbrake = true
58
+ Bullet.rollbar = true
58
59
  Bullet.add_footer = true
59
60
  Bullet.stacktrace_includes = [ 'your_gem', 'your_middleware' ]
61
+ Bullet.slack = { webhook_url: 'http://some.slack.url', foo: 'bar' }
60
62
  end
61
63
  ```
62
64
 
@@ -69,12 +71,14 @@ The code above will enable all seven of the Bullet notification systems:
69
71
  * `Bullet.rails_logger`: add warnings directly to the Rails log
70
72
  * `Bullet.bugsnag`: add notifications to bugsnag
71
73
  * `Bullet.airbrake`: add notifications to airbrake
74
+ * `Bullet.rollbar`: add notifications to rollbar
72
75
  * `Bullet.console`: log warnings to your browser's console.log (Safari/Webkit browsers or Firefox w/Firebug installed)
73
76
  * `Bullet.growl`: pop up Growl warnings if your system has Growl installed. Requires a little bit of configuration
74
77
  * `Bullet.xmpp`: send XMPP/Jabber notifications to the receiver indicated. Note that the code will currently not handle the adding of contacts, so you will need to make both accounts indicated know each other manually before you will receive any notifications. If you restart the development server frequently, the 'coming online' sound for the Bullet account may start to annoy - in this case set :show_online_status to false; you will still get notifications, but the Bullet account won't announce it's online status anymore.
75
78
  * `Bullet.raise`: raise errors, useful for making your specs fail unless they have optimized queries
76
79
  * `Bullet.add_footer`: adds the details in the bottom left corner of the page
77
80
  * `Bullet.stacktrace_includes`: include paths with any of these substrings in the stack trace, even if they are not in your main app
81
+ * `Bullet.slack`: add notifications to slack
78
82
 
79
83
  Bullet also allows you to disable any of its detectors.
80
84
 
@@ -154,8 +158,9 @@ The Bullet gem uses rack middleware to profile requests. If you want to use Bull
154
158
  ```ruby
155
159
  Bullet.profile do
156
160
  # do anything
161
+
162
+ warnings = Bullet.warnings
157
163
  end
158
- warnings = Bullet.warnings
159
164
  ```
160
165
 
161
166
  ### Work with sinatra
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.required_rubygems_version = ">= 1.3.6"
19
19
 
20
20
  s.add_runtime_dependency "activesupport", ">= 3.0.0"
21
- s.add_runtime_dependency "uniform_notifier", ">= 1.6.0"
21
+ s.add_runtime_dependency "uniform_notifier", "~> 1.9.0"
22
22
 
23
23
  s.files = `git ls-files`.split("\n")
24
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -29,7 +29,7 @@ module Bullet
29
29
  attr_reader :notification_collector, :whitelist
30
30
  attr_accessor :add_footer, :orm_pathches_applied
31
31
 
32
- delegate :alert=, :console=, :growl=, :rails_logger=, :xmpp=, :airbrake=, :bugsnag=, :to => UniformNotifier
32
+ delegate *UniformNotifier::AVAILABLE_NOTIFIERS.map { |notifier| "#{notifier}=" }, :to => UniformNotifier
33
33
 
34
34
  def raise=(should_raise)
35
35
  UniformNotifier.raise=(should_raise ? Notification::UnoptimizedQueryError : false)
@@ -160,7 +160,7 @@ module Bullet
160
160
 
161
161
  def footer_info
162
162
  info = []
163
- for_each_active_notifier_with_notification do |notification|
163
+ notification_collector.collection.each do |notification|
164
164
  info << notification.short_notice
165
165
  end
166
166
  info
@@ -176,14 +176,17 @@ module Bullet
176
176
  end
177
177
 
178
178
  def profile
179
- Bullet.start_request if Bullet.enable?
179
+ if Bullet.enable?
180
+ begin
181
+ Bullet.start_request
180
182
 
181
- yield
183
+ yield
182
184
 
183
- if Bullet.enable? && Bullet.notification?
184
- Bullet.perform_out_of_channel_notifications
185
+ Bullet.perform_out_of_channel_notifications if Bullet.notification?
186
+ ensure
187
+ Bullet.end_request
188
+ end
185
189
  end
186
- Bullet.end_request if Bullet.enable?
187
190
  end
188
191
 
189
192
  private
@@ -40,6 +40,7 @@ module Bullet
40
40
  # add includes in scope
41
41
  alias_method :origin_find_with_associations, :find_with_associations
42
42
  def find_with_associations
43
+ return origin_find_with_associations { |r| yield r } if block_given?
43
44
  records = origin_find_with_associations
44
45
  associations = (eager_load_values + includes_values).uniq
45
46
  records.each do |record|
@@ -57,6 +57,7 @@ module Bullet
57
57
  # add includes in scope
58
58
  alias_method :origin_find_with_associations, :find_with_associations
59
59
  def find_with_associations
60
+ return origin_find_with_associations { |r| yield r } if block_given?
60
61
  records = origin_find_with_associations
61
62
  associations = (eager_load_values + includes_values).uniq
62
63
  records.each do |record|
@@ -86,7 +86,10 @@ module Bullet
86
86
  value = object_associations[bullet_key]
87
87
  if value
88
88
  value.each do |v|
89
- result = v.is_a?(Hash) ? v.has_key?(associations) : v == associations
89
+ # associations == v comparision order is important here because
90
+ # v variable might be a squeel node where :== method is redefined,
91
+ # so it does not compare values at all and return unexpected results
92
+ result = v.is_a?(Hash) ? v.has_key?(associations) : associations == v
90
93
  return true if result
91
94
  end
92
95
  end
@@ -15,6 +15,12 @@ module Bullet
15
15
  "N+1 Query #{@path ? "in #{@path}" : 'detected'}"
16
16
  end
17
17
 
18
+ def notification_data
19
+ super.merge(
20
+ :backtrace => @callers
21
+ )
22
+ end
23
+
18
24
  protected
19
25
  def call_stack_messages
20
26
  (['N+1 Query method call stack'] + @callers).join( "\n " )
@@ -10,7 +10,7 @@ module Bullet
10
10
  return @app.call(env) unless Bullet.enable?
11
11
  Bullet.start_request
12
12
  status, headers, response = @app.call(env)
13
- return [status, headers, response] if file?(headers) || sse?(response) || empty?(response)
13
+ return [status, headers, response] if file?(headers) || sse?(headers) || empty?(response)
14
14
 
15
15
  response_body = nil
16
16
  if Bullet.notification?
@@ -20,8 +20,6 @@ module Bullet
20
20
  append_to_html_body(response_body, Bullet.gather_inline_notifications)
21
21
  headers['Content-Length'] = response_body.bytesize.to_s
22
22
  end
23
- end
24
- if Bullet.enable? && Bullet.notification?
25
23
  Bullet.perform_out_of_channel_notifications(env)
26
24
  end
27
25
  [status, headers, response_body ? [response_body] : response]
@@ -60,8 +58,8 @@ module Bullet
60
58
  headers["Content-Transfer-Encoding"] == "binary"
61
59
  end
62
60
 
63
- def sse?(response)
64
- response.respond_to?(:stream) && response.stream.is_a?(ActionController::Live::Buffer)
61
+ def sse?(headers)
62
+ headers["Content-Type"] == "text/event-stream"
65
63
  end
66
64
 
67
65
  def html_request?(headers, response)
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Bullet
3
- VERSION = "4.14.4"
3
+ VERSION = "4.14.5"
4
4
  end
@@ -65,7 +65,7 @@ module Bullet
65
65
  end
66
66
 
67
67
  it "should change response body if notification is active" do
68
- expect(Bullet).to receive(:notification?).and_return(true).twice
68
+ expect(Bullet).to receive(:notification?).and_return(true)
69
69
  expect(Bullet).to receive(:gather_inline_notifications).and_return("<bullet></bullet>")
70
70
  expect(Bullet).to receive(:perform_out_of_channel_notifications)
71
71
  status, headers, response = middleware.call([200, {"Content-Type" => "text/html"}])
@@ -77,7 +77,7 @@ module Bullet
77
77
  response = Support::ResponseDouble.new
78
78
  response.body = "<html><head></head><body>é</body></html>"
79
79
  app.response = response
80
- expect(Bullet).to receive(:notification?).and_return(true).twice
80
+ expect(Bullet).to receive(:notification?).and_return(true)
81
81
  expect(Bullet).to receive(:gather_inline_notifications).and_return("<bullet></bullet>")
82
82
  status, headers, response = middleware.call([200, {"Content-Type" => "text/html"}])
83
83
  expect(headers["Content-Length"]).to eq("58")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.14.4
4
+ version: 4.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: uniform_notifier
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.0
33
+ version: 1.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.0
40
+ version: 1.9.0
41
41
  description: help to kill N+1 queries and unused eager loading.
42
42
  email:
43
43
  - flyerhzm@gmail.com