bullet 6.0.0 → 6.0.1

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
  SHA256:
3
- metadata.gz: 749d1d92dc0373b1f2521c85825dfea656e985c438cdfafe774242b31f25c2d5
4
- data.tar.gz: 4e76a9da65613f2b9cf3802f4969f84c1e5bb9849c5892898fa9d999fde3900c
3
+ metadata.gz: 7f255102db3ae1250632db2b30a9e6f1bce87dab49b4dabee73709ffde82a4e0
4
+ data.tar.gz: 025ab0e3513546a56e984aa83a0b925d27e631bdfe61feb694b3e21ecfb6ffda
5
5
  SHA512:
6
- metadata.gz: 72f8f18edecb79d8631a215229afb71bb94050c0fcc65794a88dc3adf21545acf4ae38eb59bd6bdfa0e34609854ab149d02f47e761fba00452e28f2575306376
7
- data.tar.gz: 94058fcb502d63ce470b6dfa06d05dd367c8a7e251948040b91c22164d6583d8a82ab120bb2a42d109c121170042573c9964aaa55ebc0093c07adc1fb8f23fd5
6
+ metadata.gz: 23d701691dc1f2286ec11ffb26f548878bfa7ddd2ea8f20d97bb4c64df4e3a7a10f54adb16fa7cacd8bb8807dd1804e349c1b889e32530cbb7c57432ceec17da
7
+ data.tar.gz: 281a4a6619695a7db4098f1ed62066cd4e81cf9c2c3bf33fa83f87a205a5c4779e9c8125143a78ca482247ed2a271465b3011af84a5dfc67753cbad2357ee2ae
@@ -2,6 +2,7 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.0
5
+ - 2.6.0
5
6
  gemfile:
6
7
  - Gemfile.rails-6.0
7
8
  - Gemfile.rails-5.2
@@ -10,5 +11,21 @@ gemfile:
10
11
  - Gemfile.rails-4.2
11
12
  - Gemfile.rails-4.1
12
13
  - Gemfile.rails-4.0
14
+ matrix:
15
+ exclude:
16
+ - rvm: 2.3.0
17
+ gemfile: Gemfile.rails-6.0
18
+ - rvm: 2.6.0
19
+ gemfile: Gemfile.rails-5.2
20
+ - rvm: 2.6.0
21
+ gemfile: Gemfile.rails-5.1
22
+ - rvm: 2.6.0
23
+ gemfile: Gemfile.rails-5.0
24
+ - rvm: 2.6.0
25
+ gemfile: Gemfile.rails-4.2
26
+ - rvm: 2.6.0
27
+ gemfile: Gemfile.rails-4.1
28
+ - rvm: 2.6.0
29
+ gemfile: Gemfile.rails-4.0
13
30
  env:
14
31
  - DB=sqlite
@@ -1,6 +1,11 @@
1
1
  ## Next Release
2
2
 
3
- ## 6.0.0 (02/22/2019)
3
+ ## 6.0.1 (06/26/2019)
4
+
5
+ * Add Bullet::ActiveJob
6
+ * Prevent "Maximum call stack exceeded" errors when used with Turbolinks
7
+
8
+ ## 6.0.0 (04/25/2019)
4
9
 
5
10
  * Add XHR support to Bullet
6
11
  * Support Rails 6.0
data/README.md CHANGED
@@ -181,15 +181,27 @@ If you find Bullet does not work for you, *please disable your browser's cache*.
181
181
 
182
182
  ## Advanced
183
183
 
184
- ### Profile a job
184
+ ### Work with ActiveJob
185
185
 
186
- 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 the profile method and fetch warnings
186
+ Include `Bullet::ActiveJob` in your `ApplicationJob`.
187
187
 
188
188
  ```ruby
189
- Bullet.profile do
190
- # do anything
189
+ class ApplicationJob < ActiveJob::Base
190
+ include Bullet::ActiveJob if Rails.env.development?
191
+ end
192
+ ```
193
+
194
+ ### Work with other background job solution
191
195
 
192
- warnings = Bullet.warnings
196
+ Use the Bullet.profile method.
197
+
198
+ ```ruby
199
+ class ApplicationJob < ActiveJob::Base
200
+ around_perform do |_job, block|
201
+ Bullet.profile do
202
+ block.call
203
+ end
204
+ end
193
205
  end
194
206
  ```
195
207
 
@@ -458,4 +470,4 @@ Meanwhile, there's a line appended to `log/bullet.log`
458
470
  Post => [:comments]
459
471
  ```
460
472
 
461
- Copyright (c) 2009 - 2016 Richard Huang (flyerhzm@gmail.com), released under the MIT license
473
+ Copyright (c) 2009 - 2019 Richard Huang (flyerhzm@gmail.com), released under the MIT license
@@ -14,6 +14,7 @@ module Bullet
14
14
  autoload :ActiveRecord, "bullet/#{active_record_version}" if active_record?
15
15
  autoload :Mongoid, "bullet/#{mongoid_version}" if mongoid?
16
16
  autoload :Rack, 'bullet/rack'
17
+ autoload :ActiveJob, 'bullet/active_job'
17
18
  autoload :Notification, 'bullet/notification'
18
19
  autoload :Detector, 'bullet/detector'
19
20
  autoload :Registry, 'bullet/registry'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bullet
4
+ module ActiveJob
5
+ def self.included(base)
6
+ base.class_eval do
7
+ around_perform do |_job, block|
8
+ Bullet.profile do
9
+ block.call
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -181,7 +181,6 @@ module Bullet
181
181
  ::ActiveRecord::Associations::HasManyAssociation.class_eval do
182
182
  alias_method :origin_has_cached_counter?, :has_cached_counter?
183
183
 
184
- # rubocop:disable Style/MethodCallWithoutArgsParentheses
185
184
  def has_cached_counter?(reflection = reflection())
186
185
  result = origin_has_cached_counter?(reflection)
187
186
  if Bullet.start? && !result
@@ -189,7 +188,7 @@ module Bullet
189
188
  end
190
189
  result
191
190
  end
192
- # rubocop:enable Style/MethodCallWithoutArgsParentheses
191
+
193
192
  end
194
193
  end
195
194
  end
@@ -1,21 +1,32 @@
1
1
  (function() {
2
2
  var oldOpen = window.XMLHttpRequest.prototype.open;
3
3
  var oldSend = window.XMLHttpRequest.prototype.send;
4
- function newOpen(method, url, async, user, password) {
4
+
5
+ /**
6
+ * Return early if we've already extended prototype. This prevents
7
+ * "maximum call stack exceeded" errors when used with Turbolinks.
8
+ * See https://github.com/flyerhzm/bullet/issues/454
9
+ */
10
+ if (isBulletInitiated()) return;
11
+
12
+ function isBulletInitiated() {
13
+ return oldOpen.name == 'bulletXHROpen' && oldSend.name == 'bulletXHRSend';
14
+ }
15
+ function bulletXHROpen(_, url) {
5
16
  this._storedUrl = url;
6
17
  return oldOpen.apply(this, arguments);
7
18
  }
8
- function newSend(data) {
19
+ function bulletXHRSend() {
9
20
  if (this.onload) {
10
21
  this._storedOnload = this.onload;
11
22
  }
12
- this.onload = newOnload;
23
+ this.addEventListener('load', bulletXHROnload);
13
24
  return oldSend.apply(this, arguments);
14
25
  }
15
- function newOnload() {
26
+ function bulletXHROnload() {
16
27
  if (
17
28
  this._storedUrl.startsWith(
18
- window.location.protocol + '//' + window.location.host,
29
+ window.location.protocol + '//' + window.location.host
19
30
  ) ||
20
31
  !this._storedUrl.startsWith('http') // For relative paths
21
32
  ) {
@@ -30,7 +41,7 @@
30
41
  var newHtml = oldHtml.concat(JSON.parse(bulletFooterText));
31
42
  newHtml = newHtml.slice(newHtml.length - 10, newHtml.length); // rotate through 10 most recent
32
43
  document.getElementById(
33
- 'bullet-footer',
44
+ 'bullet-footer'
34
45
  ).innerHTML = `${header}<br>${newHtml.join('<br>')}`;
35
46
  }, 0);
36
47
  }
@@ -53,6 +64,6 @@
53
64
  return this._storedOnload.apply(this, arguments);
54
65
  }
55
66
  }
56
- window.XMLHttpRequest.prototype.open = newOpen;
57
- window.XMLHttpRequest.prototype.send = newSend;
67
+ window.XMLHttpRequest.prototype.open = bulletXHROpen;
68
+ window.XMLHttpRequest.prototype.send = bulletXHRSend;
58
69
  })();
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bullet
4
- VERSION = '6.0.0'
4
+ VERSION = '6.0.1'
5
5
  end
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: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-25 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -69,6 +69,7 @@ files:
69
69
  - Rakefile
70
70
  - bullet.gemspec
71
71
  - lib/bullet.rb
72
+ - lib/bullet/active_job.rb
72
73
  - lib/bullet/active_record4.rb
73
74
  - lib/bullet/active_record41.rb
74
75
  - lib/bullet/active_record42.rb