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 +4 -4
- data/.travis.yml +17 -0
- data/CHANGELOG.md +6 -1
- data/README.md +18 -6
- data/lib/bullet.rb +1 -0
- data/lib/bullet/active_job.rb +15 -0
- data/lib/bullet/active_record4.rb +1 -2
- data/lib/bullet/bullet_xhr.js +19 -8
- data/lib/bullet/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f255102db3ae1250632db2b30a9e6f1bce87dab49b4dabee73709ffde82a4e0
|
4
|
+
data.tar.gz: 025ab0e3513546a56e984aa83a0b925d27e631bdfe61feb694b3e21ecfb6ffda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23d701691dc1f2286ec11ffb26f548878bfa7ddd2ea8f20d97bb4c64df4e3a7a10f54adb16fa7cacd8bb8807dd1804e349c1b889e32530cbb7c57432ceec17da
|
7
|
+
data.tar.gz: 281a4a6619695a7db4098f1ed62066cd4e81cf9c2c3bf33fa83f87a205a5c4779e9c8125143a78ca482247ed2a271465b3011af84a5dfc67753cbad2357ee2ae
|
data/.travis.yml
CHANGED
@@ -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
|
data/CHANGELOG.md
CHANGED
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
|
-
###
|
184
|
+
### Work with ActiveJob
|
185
185
|
|
186
|
-
|
186
|
+
Include `Bullet::ActiveJob` in your `ApplicationJob`.
|
187
187
|
|
188
188
|
```ruby
|
189
|
-
|
190
|
-
|
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
|
-
|
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 -
|
473
|
+
Copyright (c) 2009 - 2019 Richard Huang (flyerhzm@gmail.com), released under the MIT license
|
data/lib/bullet.rb
CHANGED
@@ -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'
|
@@ -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
|
-
|
191
|
+
|
193
192
|
end
|
194
193
|
end
|
195
194
|
end
|
data/lib/bullet/bullet_xhr.js
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
(function() {
|
2
2
|
var oldOpen = window.XMLHttpRequest.prototype.open;
|
3
3
|
var oldSend = window.XMLHttpRequest.prototype.send;
|
4
|
-
|
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
|
19
|
+
function bulletXHRSend() {
|
9
20
|
if (this.onload) {
|
10
21
|
this._storedOnload = this.onload;
|
11
22
|
}
|
12
|
-
this.
|
23
|
+
this.addEventListener('load', bulletXHROnload);
|
13
24
|
return oldSend.apply(this, arguments);
|
14
25
|
}
|
15
|
-
function
|
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 =
|
57
|
-
window.XMLHttpRequest.prototype.send =
|
67
|
+
window.XMLHttpRequest.prototype.open = bulletXHROpen;
|
68
|
+
window.XMLHttpRequest.prototype.send = bulletXHRSend;
|
58
69
|
})();
|
data/lib/bullet/version.rb
CHANGED
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.
|
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-
|
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
|