bullet_instructure 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +75 -0
- data/Gemfile +19 -0
- data/Gemfile.mongoid +14 -0
- data/Gemfile.mongoid-2.4 +19 -0
- data/Gemfile.mongoid-2.5 +19 -0
- data/Gemfile.mongoid-2.6 +19 -0
- data/Gemfile.mongoid-2.7 +19 -0
- data/Gemfile.mongoid-2.8 +19 -0
- data/Gemfile.mongoid-3.0 +19 -0
- data/Gemfile.mongoid-3.1 +19 -0
- data/Gemfile.mongoid-4.0 +19 -0
- data/Gemfile.rails-3.0 +19 -0
- data/Gemfile.rails-3.1 +19 -0
- data/Gemfile.rails-3.2 +19 -0
- data/Gemfile.rails-4.0 +19 -0
- data/Gemfile.rails-4.1 +19 -0
- data/Guardfile +8 -0
- data/Hacking.md +74 -0
- data/MIT-LICENSE +20 -0
- data/README.md +428 -0
- data/Rakefile +52 -0
- data/bullet_instructure.gemspec +27 -0
- data/lib/bullet.rb +196 -0
- data/lib/bullet/active_record3.rb +148 -0
- data/lib/bullet/active_record3x.rb +128 -0
- data/lib/bullet/active_record4.rb +128 -0
- data/lib/bullet/active_record41.rb +121 -0
- data/lib/bullet/dependency.rb +81 -0
- data/lib/bullet/detector.rb +9 -0
- data/lib/bullet/detector/association.rb +67 -0
- data/lib/bullet/detector/base.rb +6 -0
- data/lib/bullet/detector/counter_cache.rb +59 -0
- data/lib/bullet/detector/n_plus_one_query.rb +89 -0
- data/lib/bullet/detector/unused_eager_loading.rb +84 -0
- data/lib/bullet/ext/object.rb +9 -0
- data/lib/bullet/ext/string.rb +5 -0
- data/lib/bullet/mongoid2x.rb +56 -0
- data/lib/bullet/mongoid3x.rb +56 -0
- data/lib/bullet/mongoid4x.rb +56 -0
- data/lib/bullet/notification.rb +10 -0
- data/lib/bullet/notification/base.rb +97 -0
- data/lib/bullet/notification/counter_cache.rb +13 -0
- data/lib/bullet/notification/n_plus_one_query.rb +28 -0
- data/lib/bullet/notification/unused_eager_loading.rb +13 -0
- data/lib/bullet/notification_collector.rb +24 -0
- data/lib/bullet/rack.rb +81 -0
- data/lib/bullet/registry.rb +7 -0
- data/lib/bullet/registry/association.rb +13 -0
- data/lib/bullet/registry/base.rb +40 -0
- data/lib/bullet/registry/object.rb +13 -0
- data/lib/bullet/version.rb +4 -0
- data/perf/benchmark.rb +121 -0
- data/rails/init.rb +1 -0
- data/spec/bullet/detector/association_spec.rb +26 -0
- data/spec/bullet/detector/base_spec.rb +8 -0
- data/spec/bullet/detector/counter_cache_spec.rb +56 -0
- data/spec/bullet/detector/n_plus_one_query_spec.rb +138 -0
- data/spec/bullet/detector/unused_eager_loading_spec.rb +88 -0
- data/spec/bullet/ext/object_spec.rb +17 -0
- data/spec/bullet/ext/string_spec.rb +13 -0
- data/spec/bullet/notification/base_spec.rb +83 -0
- data/spec/bullet/notification/counter_cache_spec.rb +12 -0
- data/spec/bullet/notification/n_plus_one_query_spec.rb +14 -0
- data/spec/bullet/notification/unused_eager_loading_spec.rb +12 -0
- data/spec/bullet/notification_collector_spec.rb +32 -0
- data/spec/bullet/rack_spec.rb +97 -0
- data/spec/bullet/registry/association_spec.rb +26 -0
- data/spec/bullet/registry/base_spec.rb +44 -0
- data/spec/bullet/registry/object_spec.rb +24 -0
- data/spec/bullet_spec.rb +41 -0
- data/spec/integration/active_record3/association_spec.rb +651 -0
- data/spec/integration/active_record4/association_spec.rb +649 -0
- data/spec/integration/counter_cache_spec.rb +63 -0
- data/spec/integration/mongoid/association_spec.rb +258 -0
- data/spec/models/address.rb +3 -0
- data/spec/models/author.rb +3 -0
- data/spec/models/base_user.rb +5 -0
- data/spec/models/category.rb +7 -0
- data/spec/models/city.rb +3 -0
- data/spec/models/client.rb +4 -0
- data/spec/models/comment.rb +4 -0
- data/spec/models/company.rb +3 -0
- data/spec/models/country.rb +3 -0
- data/spec/models/document.rb +5 -0
- data/spec/models/entry.rb +3 -0
- data/spec/models/firm.rb +4 -0
- data/spec/models/folder.rb +2 -0
- data/spec/models/mongoid/address.rb +7 -0
- data/spec/models/mongoid/category.rb +8 -0
- data/spec/models/mongoid/comment.rb +7 -0
- data/spec/models/mongoid/company.rb +7 -0
- data/spec/models/mongoid/entry.rb +7 -0
- data/spec/models/mongoid/post.rb +12 -0
- data/spec/models/mongoid/user.rb +5 -0
- data/spec/models/newspaper.rb +3 -0
- data/spec/models/page.rb +2 -0
- data/spec/models/person.rb +3 -0
- data/spec/models/pet.rb +3 -0
- data/spec/models/post.rb +10 -0
- data/spec/models/relationship.rb +4 -0
- data/spec/models/student.rb +3 -0
- data/spec/models/submission.rb +4 -0
- data/spec/models/teacher.rb +3 -0
- data/spec/models/user.rb +4 -0
- data/spec/models/writer.rb +2 -0
- data/spec/spec_helper.rb +103 -0
- data/spec/support/bullet_ext.rb +55 -0
- data/spec/support/mongo_seed.rb +65 -0
- data/spec/support/rack_double.rb +55 -0
- data/spec/support/sqlite_seed.rb +229 -0
- data/tasks/bullet_tasks.rake +9 -0
- data/test.sh +15 -0
- metadata +246 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f544f9a658e76fd12f2003b689c259c657333ef
|
4
|
+
data.tar.gz: 8555491148f0d57271f30b66f8788907c9ea51c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 158b0026414dd5c7aeab6b2a4b0ca9a0edea22e5e2aea2d2d05a2c69b9add83d8983a6c743bcfd354562297fd3726f90490e9553017f7f80243fbfc7cba96a7e
|
7
|
+
data.tar.gz: 388275bea2523a7dcb80ca9922783b79d9f0729864699b72cfd003a0bdb6d73a0cd7766a19dbd0bfe18e79f553803acc970ed3222a78862b75aef8adfbeddec3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.2
|
4
|
+
gemfile:
|
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
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Next Release
|
2
|
+
|
3
|
+
## 4.12.0 (not released yet)
|
4
|
+
|
5
|
+
* Use primary_key rather than id for bullet_ar_key
|
6
|
+
* Rename bullet_ar_key to bullet_key
|
7
|
+
* Fix rails sse detect
|
8
|
+
|
9
|
+
## 4.11.0 (06/24/2014)
|
10
|
+
|
11
|
+
* Support empty? call on ar associations
|
12
|
+
* Skip detecting if object is a new record
|
13
|
+
|
14
|
+
## 4.10.0 (06/06/2014)
|
15
|
+
|
16
|
+
* Handle join query smarter
|
17
|
+
* Support mongoid 4.0
|
18
|
+
* Thread safe
|
19
|
+
* Add debug mode
|
20
|
+
|
21
|
+
## 4.9.0 (04/30/2014)
|
22
|
+
|
23
|
+
* Add Bullet.stacktrace_includes option
|
24
|
+
* Applied keyword argument fixes on Ruby 2.2.0
|
25
|
+
* Add bugsnag notifier
|
26
|
+
* Support rails 4.1.0
|
27
|
+
|
28
|
+
## 4.8.0 (02/16/2014)
|
29
|
+
|
30
|
+
* Support rails 4.1.0.beta1
|
31
|
+
* Update specs to be RSpec 3.0 compatible
|
32
|
+
* Update latest minor version activerecord and mongoid on travis
|
33
|
+
|
34
|
+
## 4.7.0 (11/03/2013)
|
35
|
+
|
36
|
+
* Add coverall support
|
37
|
+
* Add helper to profile code outside a request
|
38
|
+
* Add activesupport dependency
|
39
|
+
* Add Bullet.raise notification
|
40
|
+
* Add Bullet.add_footer notification
|
41
|
+
* Fix activerecord4 warnings in test code
|
42
|
+
|
43
|
+
## 4.6.0 (04/18/2013)
|
44
|
+
|
45
|
+
* Fix Bullet::Rack to support sinatra
|
46
|
+
|
47
|
+
## 4.5.0 (03/24/2013)
|
48
|
+
|
49
|
+
* Add api way to access captured associatioin
|
50
|
+
* Allow disable n_plus_one_query, unused_eager_loading and counter_cache respectively
|
51
|
+
* Add whitelist
|
52
|
+
|
53
|
+
## 4.4.0 (03/15/2013)
|
54
|
+
|
55
|
+
* Remove disable_browser_cache option
|
56
|
+
* Compatible with Rails 4.0.0.beta1
|
57
|
+
|
58
|
+
## 4.3.0 (12/28/2012)
|
59
|
+
|
60
|
+
* Fix content-length for non ascii html
|
61
|
+
* Add mongoid 2.5.x support
|
62
|
+
|
63
|
+
## 4.2.0 (09/29/2012)
|
64
|
+
|
65
|
+
* Add Bullet::Dependency to check AR and mongoid version
|
66
|
+
* Add Rails 4 support
|
67
|
+
* Add airbrake notifier support
|
68
|
+
|
69
|
+
## 4.1.0 (05/30/2012)
|
70
|
+
|
71
|
+
* Add mongoid 3 support
|
72
|
+
|
73
|
+
## 4.0.0 (05/09/2012)
|
74
|
+
|
75
|
+
* Add mongoid support
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails'
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'activerecord-import'
|
9
|
+
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'guard'
|
12
|
+
gem 'guard-rspec'
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails'
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'mongoid', github: 'mongoid/mongoid'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
data/Gemfile.mongoid-2.4
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 2.4.12'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-2.5
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 2.5.2'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-2.6
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 2.6.0'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-2.7
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 2.7.1'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-2.8
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 2.8'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-3.0
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 3.0.23'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-3.1
ADDED
@@ -0,0 +1,19 @@
|
|
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 'mongoid', '~> 3.1.6'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.mongoid-4.0
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails', '~> 4.0.5'
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'mongoid', '~> 4.0.0.beta2'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.rails-3.0
ADDED
@@ -0,0 +1,19 @@
|
|
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 'activerecord-import'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.rails-3.1
ADDED
@@ -0,0 +1,19 @@
|
|
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 'activerecord-import'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.rails-3.2
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails', '~> 3.2.18'
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'activerecord-import'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.rails-4.0
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails', '~> 4.0.5'
|
6
|
+
gem 'sqlite3', platforms: [:ruby]
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'activerecord-import'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Gemfile.rails-4.1
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rails', '~> 4.1.1'
|
6
|
+
gem 'sqlite3'
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
|
8
|
+
gem 'activerecord-import'
|
9
|
+
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard"
|
12
|
+
gem "guard-rspec"
|
13
|
+
|
14
|
+
gem 'coveralls', require: false
|
15
|
+
|
16
|
+
platforms :rbx do
|
17
|
+
gem 'rubysl', '~> 2.0'
|
18
|
+
gem 'rubinius-developer_tools'
|
19
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2, :all_after_pass => false, :all_on_start => false, :cli => "--color --format nested --fail-fast" do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
end
|
data/Hacking.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Bullet Overview for Developers
|
2
|
+
|
3
|
+
This file aims to give developers a quick tour of the bullet internals, making
|
4
|
+
it (hopefully) easier to extend or enhance the Bullet gem.
|
5
|
+
|
6
|
+
## General Control Flow aka. 10000 Meter View
|
7
|
+
|
8
|
+
When Rails is initialized, Bullet will extend ActiveRecord (and if you're using
|
9
|
+
Rails 2.x ActiveController too) with the relevant modules and methods found
|
10
|
+
in lib/bullet/active_recordX.rb and lib/bullet/action_controller2.rb. If you're
|
11
|
+
running Rails 3, Bullet will integrate itself as a middleware into the Rack
|
12
|
+
stack, so ActionController does not need to be extended.
|
13
|
+
|
14
|
+
The ActiveRecord extensions will call methods in a given detector class, when
|
15
|
+
certain methods are called.
|
16
|
+
|
17
|
+
Detector classes contain all the logic to recognize
|
18
|
+
a noteworthy event. If such an event is detected, an instance of the
|
19
|
+
corresponding Notification class is created and stored in a Set instance in the
|
20
|
+
main Bullet module (the 'notification collector').
|
21
|
+
|
22
|
+
Notification instances contain the message that will be displayed, and will
|
23
|
+
use a Presenter class to display their message to the user.
|
24
|
+
|
25
|
+
So the flow of a request goes like this:
|
26
|
+
1. Bullet.start_request is called, which resets all the detectors and empties
|
27
|
+
the notification collector
|
28
|
+
2. The request is handled by Rails, and the installed ActiveRecord extensions
|
29
|
+
trigger Detector callbacks
|
30
|
+
3. Detectors once called, will determine whether something noteworthy happend.
|
31
|
+
If yes, then a Notification is created and stored in the notification collector.
|
32
|
+
4. Rails finishes handling the request
|
33
|
+
5. For each notification in the collector, Bullet will iterate over each
|
34
|
+
Presenter and will try to generate an inline message that will be appended to
|
35
|
+
the generated response body.
|
36
|
+
6. The response is returned to the client.
|
37
|
+
7. Bullet will try to generate an out-of-channel message for each notification.
|
38
|
+
8. Bullet calls end_request for each detector.
|
39
|
+
9. Goto 1.
|
40
|
+
|
41
|
+
## Adding Notification Types
|
42
|
+
|
43
|
+
If you want to add more kinds of things that Bullet can detect, a little more
|
44
|
+
work is needed than if you were just adding a Presenter, but the concepts are
|
45
|
+
similar.
|
46
|
+
|
47
|
+
* Add the class to the DETECTORS constant in the main Bullet module
|
48
|
+
* Add (if needed) Rails monkey patches to Bullet.enable
|
49
|
+
* Add an autoload directive to lib/bullet/detector.rb
|
50
|
+
* Create a corresponding notification class in the Bullet::Notification namespace
|
51
|
+
* Add an autoload directive to lib/bullet/notification.rb
|
52
|
+
|
53
|
+
As a rule of thumb, you can assume that each Detector will have its own
|
54
|
+
Notification class. If you follow the principle of Separation of Concerns I
|
55
|
+
can't really think of an example where one would deviate from this rule.
|
56
|
+
|
57
|
+
Since the detection of pathological associations is a bit hairy, I'd recommend
|
58
|
+
having a look at the counter cache detector and associated notification to get
|
59
|
+
a feel for what is needed to get off the ground.
|
60
|
+
|
61
|
+
### Detectors
|
62
|
+
|
63
|
+
The only things you'll need to consider when building your Detector class is
|
64
|
+
that it will need to supply the .start_request, .end_request and .clear class
|
65
|
+
methods.
|
66
|
+
|
67
|
+
Simple implementations are provided by Bullet::Detector::Base for start_request
|
68
|
+
and end_request, you will have to supply your own clear method.
|
69
|
+
|
70
|
+
### Notifications
|
71
|
+
|
72
|
+
For notifications you will want to supply a #title and #body instance method,
|
73
|
+
and check to see if the #initialize and #full_notice methods in the
|
74
|
+
Bullet::Notification::Base class fit your needs.
|