bullet 2.3.0 → 4.0.0
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.
- data/.travis.yml +5 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +44 -33
- data/Gemfile.rails-2.3.14 +16 -0
- data/Gemfile.rails-2.3.14.lock +65 -0
- data/Gemfile.rails-3.0.12 +17 -0
- data/Gemfile.rails-3.0.12.lock +116 -0
- data/Gemfile.rails-3.1.4 +18 -0
- data/Gemfile.rails-3.1.4.lock +134 -0
- data/README.textile +6 -6
- data/lib/bullet/active_record2.rb +12 -0
- data/lib/bullet/active_record3.rb +12 -0
- data/lib/bullet/detector/association.rb +11 -12
- data/lib/bullet/detector/counter.rb +6 -6
- data/lib/bullet/detector/n_plus_one_query.rb +9 -9
- data/lib/bullet/detector/unused_eager_association.rb +9 -9
- data/lib/bullet/ext/object.rb +5 -0
- data/lib/bullet/ext/string.rb +5 -0
- data/lib/bullet/mongoid.rb +56 -0
- data/lib/bullet/registry/object.rb +4 -6
- data/lib/bullet/version.rb +1 -1
- data/lib/bullet.rb +15 -9
- data/spec/bullet/detector/association_spec.rb +20 -16
- data/spec/bullet/detector/counter_spec.rb +8 -9
- data/spec/bullet/detector/n_plus_one_query_spec.rb +22 -22
- data/spec/bullet/detector/unused_eager_association_spec.rb +11 -11
- data/spec/bullet/ext/object_spec.rb +20 -0
- data/spec/bullet/ext/string_spec.rb +13 -0
- data/spec/bullet/registry/object_spec.rb +4 -4
- data/spec/integration/association_spec.rb +463 -401
- data/spec/integration/counter_spec.rb +27 -25
- data/spec/integration/mongoid/association_spec.rb +276 -0
- data/spec/integration/rails2/association_spec.rb +593 -0
- data/spec/integration/rails2/counter_spec.rb +39 -0
- data/spec/models/mongoid/address.rb +5 -0
- data/spec/models/mongoid/category.rb +6 -0
- data/spec/models/mongoid/comment.rb +5 -0
- data/spec/models/mongoid/company.rb +5 -0
- data/spec/models/mongoid/entry.rb +5 -0
- data/spec/models/mongoid/post.rb +8 -0
- data/spec/models/post.rb +12 -6
- data/spec/spec_helper.rb +32 -8
- data/spec/support/bullet_ext.rb +1 -1
- data/spec/support/mongo_seed.rb +41 -0
- data/spec/support/{seed.rb → sqlite_seed.rb} +1 -22
- data/test.result +2293 -0
- metadata +42 -22
- data/spec/integration/association_for_chris_spec.rb +0 -37
- data/spec/integration/association_for_peschkaj_spec.rb +0 -26
- data/spec/models/contact.rb +0 -3
- data/spec/models/deal.rb +0 -4
- data/spec/models/email.rb +0 -3
- data/spec/models/hotel.rb +0 -4
- data/spec/models/location.rb +0 -3
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
bullet (
|
|
4
|
+
bullet (4.0.0)
|
|
5
5
|
uniform_notifier (~> 1.0.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: http://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actionmailer (3.2.
|
|
11
|
-
actionpack (= 3.2.
|
|
12
|
-
mail (~> 2.4.
|
|
13
|
-
actionpack (3.2.
|
|
14
|
-
activemodel (= 3.2.
|
|
15
|
-
activesupport (= 3.2.
|
|
10
|
+
actionmailer (3.2.3)
|
|
11
|
+
actionpack (= 3.2.3)
|
|
12
|
+
mail (~> 2.4.4)
|
|
13
|
+
actionpack (3.2.3)
|
|
14
|
+
activemodel (= 3.2.3)
|
|
15
|
+
activesupport (= 3.2.3)
|
|
16
16
|
builder (~> 3.0.0)
|
|
17
17
|
erubis (~> 2.7.0)
|
|
18
18
|
journey (~> 1.0.1)
|
|
19
19
|
rack (~> 1.4.0)
|
|
20
|
-
rack-cache (~> 1.
|
|
20
|
+
rack-cache (~> 1.2)
|
|
21
21
|
rack-test (~> 0.6.1)
|
|
22
22
|
sprockets (~> 2.1.2)
|
|
23
|
-
activemodel (3.2.
|
|
24
|
-
activesupport (= 3.2.
|
|
23
|
+
activemodel (3.2.3)
|
|
24
|
+
activesupport (= 3.2.3)
|
|
25
25
|
builder (~> 3.0.0)
|
|
26
|
-
activerecord (3.2.
|
|
27
|
-
activemodel (= 3.2.
|
|
28
|
-
activesupport (= 3.2.
|
|
26
|
+
activerecord (3.2.3)
|
|
27
|
+
activemodel (= 3.2.3)
|
|
28
|
+
activesupport (= 3.2.3)
|
|
29
29
|
arel (~> 3.0.2)
|
|
30
30
|
tzinfo (~> 0.3.29)
|
|
31
31
|
activerecord-import (0.2.9)
|
|
32
32
|
activerecord (~> 3.0)
|
|
33
33
|
activerecord (~> 3.0)
|
|
34
|
-
activeresource (3.2.
|
|
35
|
-
activemodel (= 3.2.
|
|
36
|
-
activesupport (= 3.2.
|
|
37
|
-
activesupport (3.2.
|
|
34
|
+
activeresource (3.2.3)
|
|
35
|
+
activemodel (= 3.2.3)
|
|
36
|
+
activesupport (= 3.2.3)
|
|
37
|
+
activesupport (3.2.3)
|
|
38
38
|
i18n (~> 0.6)
|
|
39
39
|
multi_json (~> 1.0)
|
|
40
40
|
arel (3.0.2)
|
|
41
|
+
bson (1.6.2)
|
|
42
|
+
bson_ext (1.6.2)
|
|
43
|
+
bson (~> 1.6.2)
|
|
41
44
|
builder (3.0.0)
|
|
42
45
|
diff-lcs (1.1.3)
|
|
43
46
|
erubis (2.7.0)
|
|
@@ -50,13 +53,19 @@ GEM
|
|
|
50
53
|
hike (1.2.1)
|
|
51
54
|
i18n (0.6.0)
|
|
52
55
|
journey (1.0.3)
|
|
53
|
-
json (1.
|
|
56
|
+
json (1.7.0)
|
|
54
57
|
mail (2.4.4)
|
|
55
58
|
i18n (>= 0.4.0)
|
|
56
59
|
mime-types (~> 1.16)
|
|
57
60
|
treetop (~> 1.4.8)
|
|
58
61
|
mime-types (1.18)
|
|
59
|
-
|
|
62
|
+
mongo (1.6.2)
|
|
63
|
+
bson (~> 1.6.2)
|
|
64
|
+
mongoid (2.4.9)
|
|
65
|
+
activemodel (~> 3.1)
|
|
66
|
+
mongo (~> 1.3)
|
|
67
|
+
tzinfo (~> 0.3.22)
|
|
68
|
+
multi_json (1.3.4)
|
|
60
69
|
mysql (2.8.1)
|
|
61
70
|
perftools.rb (2.0.0)
|
|
62
71
|
polyglot (0.3.3)
|
|
@@ -67,17 +76,17 @@ GEM
|
|
|
67
76
|
rack
|
|
68
77
|
rack-test (0.6.1)
|
|
69
78
|
rack (>= 1.0)
|
|
70
|
-
rails (3.2.
|
|
71
|
-
actionmailer (= 3.2.
|
|
72
|
-
actionpack (= 3.2.
|
|
73
|
-
activerecord (= 3.2.
|
|
74
|
-
activeresource (= 3.2.
|
|
75
|
-
activesupport (= 3.2.
|
|
79
|
+
rails (3.2.3)
|
|
80
|
+
actionmailer (= 3.2.3)
|
|
81
|
+
actionpack (= 3.2.3)
|
|
82
|
+
activerecord (= 3.2.3)
|
|
83
|
+
activeresource (= 3.2.3)
|
|
84
|
+
activesupport (= 3.2.3)
|
|
76
85
|
bundler (~> 1.0)
|
|
77
|
-
railties (= 3.2.
|
|
78
|
-
railties (3.2.
|
|
79
|
-
actionpack (= 3.2.
|
|
80
|
-
activesupport (= 3.2.
|
|
86
|
+
railties (= 3.2.3)
|
|
87
|
+
railties (3.2.3)
|
|
88
|
+
actionpack (= 3.2.3)
|
|
89
|
+
activesupport (= 3.2.3)
|
|
81
90
|
rack-ssl (~> 1.3.2)
|
|
82
91
|
rake (>= 0.8.7)
|
|
83
92
|
rdoc (~> 3.4)
|
|
@@ -93,7 +102,7 @@ GEM
|
|
|
93
102
|
rspec-expectations (2.9.0)
|
|
94
103
|
diff-lcs (~> 1.1.3)
|
|
95
104
|
rspec-mocks (2.9.0)
|
|
96
|
-
sprockets (2.1.
|
|
105
|
+
sprockets (2.1.3)
|
|
97
106
|
hike (~> 1.2)
|
|
98
107
|
rack (~> 1.0)
|
|
99
108
|
tilt (~> 1.1, != 1.3.0)
|
|
@@ -103,19 +112,21 @@ GEM
|
|
|
103
112
|
treetop (1.4.10)
|
|
104
113
|
polyglot
|
|
105
114
|
polyglot (>= 0.3.1)
|
|
106
|
-
tzinfo (0.3.
|
|
107
|
-
uniform_notifier (1.0.
|
|
115
|
+
tzinfo (0.3.33)
|
|
116
|
+
uniform_notifier (1.0.2)
|
|
108
117
|
|
|
109
118
|
PLATFORMS
|
|
110
119
|
ruby
|
|
111
120
|
|
|
112
121
|
DEPENDENCIES
|
|
113
122
|
activerecord-import
|
|
123
|
+
bson_ext
|
|
114
124
|
bullet!
|
|
115
125
|
guard
|
|
116
126
|
guard-rspec
|
|
127
|
+
mongoid
|
|
117
128
|
mysql
|
|
118
129
|
perftools.rb
|
|
119
|
-
rails
|
|
130
|
+
rails (= 3.2.3)
|
|
120
131
|
rspec
|
|
121
132
|
sqlite3
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Use `bundle install` in order to install these gems
|
|
2
|
+
# Use `bundle exec rake` in order to run the specs using the bundle
|
|
3
|
+
source "http://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gemspec
|
|
6
|
+
|
|
7
|
+
gem 'rails', '2.3.14'
|
|
8
|
+
gem 'sqlite3'
|
|
9
|
+
gem 'mysql'
|
|
10
|
+
gem 'bson_ext'
|
|
11
|
+
|
|
12
|
+
gem "rspec"
|
|
13
|
+
gem "guard"
|
|
14
|
+
gem "guard-rspec"
|
|
15
|
+
|
|
16
|
+
gem "perftools.rb"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
bullet (2.3.1)
|
|
5
|
+
uniform_notifier (~> 1.0.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (2.3.14)
|
|
11
|
+
actionpack (= 2.3.14)
|
|
12
|
+
actionpack (2.3.14)
|
|
13
|
+
activesupport (= 2.3.14)
|
|
14
|
+
rack (~> 1.1.0)
|
|
15
|
+
activerecord (2.3.14)
|
|
16
|
+
activesupport (= 2.3.14)
|
|
17
|
+
activeresource (2.3.14)
|
|
18
|
+
activesupport (= 2.3.14)
|
|
19
|
+
activesupport (2.3.14)
|
|
20
|
+
bson (1.6.2)
|
|
21
|
+
bson_ext (1.6.2)
|
|
22
|
+
bson (~> 1.6.2)
|
|
23
|
+
diff-lcs (1.1.3)
|
|
24
|
+
ffi (1.0.11)
|
|
25
|
+
guard (1.0.2)
|
|
26
|
+
ffi (>= 0.5.0)
|
|
27
|
+
thor (~> 0.14.6)
|
|
28
|
+
guard-rspec (0.7.0)
|
|
29
|
+
guard (>= 0.10.0)
|
|
30
|
+
mysql (2.8.1)
|
|
31
|
+
perftools.rb (2.0.0)
|
|
32
|
+
rack (1.1.3)
|
|
33
|
+
rails (2.3.14)
|
|
34
|
+
actionmailer (= 2.3.14)
|
|
35
|
+
actionpack (= 2.3.14)
|
|
36
|
+
activerecord (= 2.3.14)
|
|
37
|
+
activeresource (= 2.3.14)
|
|
38
|
+
activesupport (= 2.3.14)
|
|
39
|
+
rake (>= 0.8.3)
|
|
40
|
+
rake (0.9.2.2)
|
|
41
|
+
rspec (2.10.0)
|
|
42
|
+
rspec-core (~> 2.10.0)
|
|
43
|
+
rspec-expectations (~> 2.10.0)
|
|
44
|
+
rspec-mocks (~> 2.10.0)
|
|
45
|
+
rspec-core (2.10.0)
|
|
46
|
+
rspec-expectations (2.10.0)
|
|
47
|
+
diff-lcs (~> 1.1.3)
|
|
48
|
+
rspec-mocks (2.10.1)
|
|
49
|
+
sqlite3 (1.3.6)
|
|
50
|
+
thor (0.14.6)
|
|
51
|
+
uniform_notifier (1.0.2)
|
|
52
|
+
|
|
53
|
+
PLATFORMS
|
|
54
|
+
ruby
|
|
55
|
+
|
|
56
|
+
DEPENDENCIES
|
|
57
|
+
bson_ext
|
|
58
|
+
bullet!
|
|
59
|
+
guard
|
|
60
|
+
guard-rspec
|
|
61
|
+
mysql
|
|
62
|
+
perftools.rb
|
|
63
|
+
rails (= 2.3.14)
|
|
64
|
+
rspec
|
|
65
|
+
sqlite3
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Use `bundle install` in order to install these gems
|
|
2
|
+
# Use `bundle exec rake` in order to run the specs using the bundle
|
|
3
|
+
source "http://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gemspec
|
|
6
|
+
|
|
7
|
+
gem 'rails', '3.0.12'
|
|
8
|
+
gem 'sqlite3'
|
|
9
|
+
gem 'mysql'
|
|
10
|
+
gem 'activerecord-import'
|
|
11
|
+
gem 'bson_ext'
|
|
12
|
+
|
|
13
|
+
gem "rspec"
|
|
14
|
+
gem "guard"
|
|
15
|
+
gem "guard-rspec"
|
|
16
|
+
|
|
17
|
+
gem "perftools.rb"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
bullet (2.3.1)
|
|
5
|
+
uniform_notifier (~> 1.0.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
abstract (1.0.0)
|
|
11
|
+
actionmailer (3.0.12)
|
|
12
|
+
actionpack (= 3.0.12)
|
|
13
|
+
mail (~> 2.2.19)
|
|
14
|
+
actionpack (3.0.12)
|
|
15
|
+
activemodel (= 3.0.12)
|
|
16
|
+
activesupport (= 3.0.12)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
erubis (~> 2.6.6)
|
|
19
|
+
i18n (~> 0.5.0)
|
|
20
|
+
rack (~> 1.2.5)
|
|
21
|
+
rack-mount (~> 0.6.14)
|
|
22
|
+
rack-test (~> 0.5.7)
|
|
23
|
+
tzinfo (~> 0.3.23)
|
|
24
|
+
activemodel (3.0.12)
|
|
25
|
+
activesupport (= 3.0.12)
|
|
26
|
+
builder (~> 2.1.2)
|
|
27
|
+
i18n (~> 0.5.0)
|
|
28
|
+
activerecord (3.0.12)
|
|
29
|
+
activemodel (= 3.0.12)
|
|
30
|
+
activesupport (= 3.0.12)
|
|
31
|
+
arel (~> 2.0.10)
|
|
32
|
+
tzinfo (~> 0.3.23)
|
|
33
|
+
activerecord-import (0.2.9)
|
|
34
|
+
activerecord (~> 3.0)
|
|
35
|
+
activerecord (~> 3.0)
|
|
36
|
+
activeresource (3.0.12)
|
|
37
|
+
activemodel (= 3.0.12)
|
|
38
|
+
activesupport (= 3.0.12)
|
|
39
|
+
activesupport (3.0.12)
|
|
40
|
+
arel (2.0.10)
|
|
41
|
+
bson (1.6.2)
|
|
42
|
+
bson_ext (1.6.2)
|
|
43
|
+
bson (~> 1.6.2)
|
|
44
|
+
builder (2.1.2)
|
|
45
|
+
diff-lcs (1.1.3)
|
|
46
|
+
erubis (2.6.6)
|
|
47
|
+
abstract (>= 1.0.0)
|
|
48
|
+
ffi (1.0.11)
|
|
49
|
+
guard (1.0.2)
|
|
50
|
+
ffi (>= 0.5.0)
|
|
51
|
+
thor (~> 0.14.6)
|
|
52
|
+
guard-rspec (0.7.0)
|
|
53
|
+
guard (>= 0.10.0)
|
|
54
|
+
i18n (0.5.0)
|
|
55
|
+
json (1.7.0)
|
|
56
|
+
mail (2.2.19)
|
|
57
|
+
activesupport (>= 2.3.6)
|
|
58
|
+
i18n (>= 0.4.0)
|
|
59
|
+
mime-types (~> 1.16)
|
|
60
|
+
treetop (~> 1.4.8)
|
|
61
|
+
mime-types (1.18)
|
|
62
|
+
mysql (2.8.1)
|
|
63
|
+
perftools.rb (2.0.0)
|
|
64
|
+
polyglot (0.3.3)
|
|
65
|
+
rack (1.2.5)
|
|
66
|
+
rack-mount (0.6.14)
|
|
67
|
+
rack (>= 1.0.0)
|
|
68
|
+
rack-test (0.5.7)
|
|
69
|
+
rack (>= 1.0)
|
|
70
|
+
rails (3.0.12)
|
|
71
|
+
actionmailer (= 3.0.12)
|
|
72
|
+
actionpack (= 3.0.12)
|
|
73
|
+
activerecord (= 3.0.12)
|
|
74
|
+
activeresource (= 3.0.12)
|
|
75
|
+
activesupport (= 3.0.12)
|
|
76
|
+
bundler (~> 1.0)
|
|
77
|
+
railties (= 3.0.12)
|
|
78
|
+
railties (3.0.12)
|
|
79
|
+
actionpack (= 3.0.12)
|
|
80
|
+
activesupport (= 3.0.12)
|
|
81
|
+
rake (>= 0.8.7)
|
|
82
|
+
rdoc (~> 3.4)
|
|
83
|
+
thor (~> 0.14.4)
|
|
84
|
+
rake (0.9.2.2)
|
|
85
|
+
rdoc (3.12)
|
|
86
|
+
json (~> 1.4)
|
|
87
|
+
rspec (2.10.0)
|
|
88
|
+
rspec-core (~> 2.10.0)
|
|
89
|
+
rspec-expectations (~> 2.10.0)
|
|
90
|
+
rspec-mocks (~> 2.10.0)
|
|
91
|
+
rspec-core (2.10.0)
|
|
92
|
+
rspec-expectations (2.10.0)
|
|
93
|
+
diff-lcs (~> 1.1.3)
|
|
94
|
+
rspec-mocks (2.10.1)
|
|
95
|
+
sqlite3 (1.3.6)
|
|
96
|
+
thor (0.14.6)
|
|
97
|
+
treetop (1.4.10)
|
|
98
|
+
polyglot
|
|
99
|
+
polyglot (>= 0.3.1)
|
|
100
|
+
tzinfo (0.3.33)
|
|
101
|
+
uniform_notifier (1.0.2)
|
|
102
|
+
|
|
103
|
+
PLATFORMS
|
|
104
|
+
ruby
|
|
105
|
+
|
|
106
|
+
DEPENDENCIES
|
|
107
|
+
activerecord-import
|
|
108
|
+
bson_ext
|
|
109
|
+
bullet!
|
|
110
|
+
guard
|
|
111
|
+
guard-rspec
|
|
112
|
+
mysql
|
|
113
|
+
perftools.rb
|
|
114
|
+
rails (= 3.0.12)
|
|
115
|
+
rspec
|
|
116
|
+
sqlite3
|
data/Gemfile.rails-3.1.4
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Use `bundle install` in order to install these gems
|
|
2
|
+
# Use `bundle exec rake` in order to run the specs using the bundle
|
|
3
|
+
source "http://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gemspec
|
|
6
|
+
|
|
7
|
+
gem 'rails', '3.1.4'
|
|
8
|
+
gem 'sqlite3'
|
|
9
|
+
gem 'mysql'
|
|
10
|
+
gem 'activerecord-import'
|
|
11
|
+
gem 'mongoid'
|
|
12
|
+
gem 'bson_ext'
|
|
13
|
+
|
|
14
|
+
gem "rspec"
|
|
15
|
+
gem "guard"
|
|
16
|
+
gem "guard-rspec"
|
|
17
|
+
|
|
18
|
+
gem "perftools.rb"
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
bullet (2.3.1)
|
|
5
|
+
uniform_notifier (~> 1.0.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (3.1.4)
|
|
11
|
+
actionpack (= 3.1.4)
|
|
12
|
+
mail (~> 2.3.0)
|
|
13
|
+
actionpack (3.1.4)
|
|
14
|
+
activemodel (= 3.1.4)
|
|
15
|
+
activesupport (= 3.1.4)
|
|
16
|
+
builder (~> 3.0.0)
|
|
17
|
+
erubis (~> 2.7.0)
|
|
18
|
+
i18n (~> 0.6)
|
|
19
|
+
rack (~> 1.3.6)
|
|
20
|
+
rack-cache (~> 1.1)
|
|
21
|
+
rack-mount (~> 0.8.2)
|
|
22
|
+
rack-test (~> 0.6.1)
|
|
23
|
+
sprockets (~> 2.0.3)
|
|
24
|
+
activemodel (3.1.4)
|
|
25
|
+
activesupport (= 3.1.4)
|
|
26
|
+
builder (~> 3.0.0)
|
|
27
|
+
i18n (~> 0.6)
|
|
28
|
+
activerecord (3.1.4)
|
|
29
|
+
activemodel (= 3.1.4)
|
|
30
|
+
activesupport (= 3.1.4)
|
|
31
|
+
arel (~> 2.2.3)
|
|
32
|
+
tzinfo (~> 0.3.29)
|
|
33
|
+
activerecord-import (0.2.9)
|
|
34
|
+
activerecord (~> 3.0)
|
|
35
|
+
activerecord (~> 3.0)
|
|
36
|
+
activeresource (3.1.4)
|
|
37
|
+
activemodel (= 3.1.4)
|
|
38
|
+
activesupport (= 3.1.4)
|
|
39
|
+
activesupport (3.1.4)
|
|
40
|
+
multi_json (~> 1.0)
|
|
41
|
+
arel (2.2.3)
|
|
42
|
+
bson (1.6.2)
|
|
43
|
+
bson_ext (1.6.2)
|
|
44
|
+
bson (~> 1.6.2)
|
|
45
|
+
builder (3.0.0)
|
|
46
|
+
diff-lcs (1.1.3)
|
|
47
|
+
erubis (2.7.0)
|
|
48
|
+
ffi (1.0.11)
|
|
49
|
+
guard (1.0.2)
|
|
50
|
+
ffi (>= 0.5.0)
|
|
51
|
+
thor (~> 0.14.6)
|
|
52
|
+
guard-rspec (0.7.0)
|
|
53
|
+
guard (>= 0.10.0)
|
|
54
|
+
hike (1.2.1)
|
|
55
|
+
i18n (0.6.0)
|
|
56
|
+
json (1.7.1)
|
|
57
|
+
mail (2.3.3)
|
|
58
|
+
i18n (>= 0.4.0)
|
|
59
|
+
mime-types (~> 1.16)
|
|
60
|
+
treetop (~> 1.4.8)
|
|
61
|
+
mime-types (1.18)
|
|
62
|
+
mongo (1.6.2)
|
|
63
|
+
bson (~> 1.6.2)
|
|
64
|
+
mongoid (2.4.9)
|
|
65
|
+
activemodel (~> 3.1)
|
|
66
|
+
mongo (~> 1.3)
|
|
67
|
+
tzinfo (~> 0.3.22)
|
|
68
|
+
multi_json (1.3.4)
|
|
69
|
+
mysql (2.8.1)
|
|
70
|
+
perftools.rb (2.0.0)
|
|
71
|
+
polyglot (0.3.3)
|
|
72
|
+
rack (1.3.6)
|
|
73
|
+
rack-cache (1.2)
|
|
74
|
+
rack (>= 0.4)
|
|
75
|
+
rack-mount (0.8.3)
|
|
76
|
+
rack (>= 1.0.0)
|
|
77
|
+
rack-ssl (1.3.2)
|
|
78
|
+
rack
|
|
79
|
+
rack-test (0.6.1)
|
|
80
|
+
rack (>= 1.0)
|
|
81
|
+
rails (3.1.4)
|
|
82
|
+
actionmailer (= 3.1.4)
|
|
83
|
+
actionpack (= 3.1.4)
|
|
84
|
+
activerecord (= 3.1.4)
|
|
85
|
+
activeresource (= 3.1.4)
|
|
86
|
+
activesupport (= 3.1.4)
|
|
87
|
+
bundler (~> 1.0)
|
|
88
|
+
railties (= 3.1.4)
|
|
89
|
+
railties (3.1.4)
|
|
90
|
+
actionpack (= 3.1.4)
|
|
91
|
+
activesupport (= 3.1.4)
|
|
92
|
+
rack-ssl (~> 1.3.2)
|
|
93
|
+
rake (>= 0.8.7)
|
|
94
|
+
rdoc (~> 3.4)
|
|
95
|
+
thor (~> 0.14.6)
|
|
96
|
+
rake (0.9.2.2)
|
|
97
|
+
rdoc (3.12)
|
|
98
|
+
json (~> 1.4)
|
|
99
|
+
rspec (2.10.0)
|
|
100
|
+
rspec-core (~> 2.10.0)
|
|
101
|
+
rspec-expectations (~> 2.10.0)
|
|
102
|
+
rspec-mocks (~> 2.10.0)
|
|
103
|
+
rspec-core (2.10.0)
|
|
104
|
+
rspec-expectations (2.10.0)
|
|
105
|
+
diff-lcs (~> 1.1.3)
|
|
106
|
+
rspec-mocks (2.10.1)
|
|
107
|
+
sprockets (2.0.4)
|
|
108
|
+
hike (~> 1.2)
|
|
109
|
+
rack (~> 1.0)
|
|
110
|
+
tilt (~> 1.1, != 1.3.0)
|
|
111
|
+
sqlite3 (1.3.6)
|
|
112
|
+
thor (0.14.6)
|
|
113
|
+
tilt (1.3.3)
|
|
114
|
+
treetop (1.4.10)
|
|
115
|
+
polyglot
|
|
116
|
+
polyglot (>= 0.3.1)
|
|
117
|
+
tzinfo (0.3.33)
|
|
118
|
+
uniform_notifier (1.0.2)
|
|
119
|
+
|
|
120
|
+
PLATFORMS
|
|
121
|
+
ruby
|
|
122
|
+
|
|
123
|
+
DEPENDENCIES
|
|
124
|
+
activerecord-import
|
|
125
|
+
bson_ext
|
|
126
|
+
bullet!
|
|
127
|
+
guard
|
|
128
|
+
guard-rspec
|
|
129
|
+
mongoid
|
|
130
|
+
mysql
|
|
131
|
+
perftools.rb
|
|
132
|
+
rails (= 3.1.4)
|
|
133
|
+
rspec
|
|
134
|
+
sqlite3
|
data/README.textile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
h1. Bullet
|
|
1
|
+
h1. Bullet !https://gemnasium.com/flyerhzm/bullet.png?travis(Dependency Status)!:https://gemnasium.com/flyerhzm/bullet
|
|
2
2
|
|
|
3
3
|
!https://secure.travis-ci.org/flyerhzm/bullet.png!:http://travis-ci.org/flyerhzm/bullet
|
|
4
4
|
|
|
5
|
-
The Bullet
|
|
5
|
+
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.
|
|
6
6
|
|
|
7
7
|
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.
|
|
8
8
|
|
|
9
|
-
The Bullet
|
|
9
|
+
The Bullet gem now supports **activerecord** 2.1, 2.2, 2.3, 3.0, 3.1, 3.2 and **mongoid** >= 2.4.1.
|
|
10
10
|
|
|
11
11
|
****************************************************************************
|
|
12
12
|
|
|
@@ -46,7 +46,7 @@ end
|
|
|
46
46
|
The notifier of bullet is a wrap of "uniform_notifier":https://github.com/flyerhzm/uniform_notifier
|
|
47
47
|
|
|
48
48
|
The code above will enable all six of the Bullet notification systems:
|
|
49
|
-
* <code>Bullet.enable</code>: enable Bullet
|
|
49
|
+
* <code>Bullet.enable</code>: enable Bullet gem, otherwise do nothing
|
|
50
50
|
* <code>Bullet.alert</code>: pop up a JavaScript alert in the browser
|
|
51
51
|
* <code>Bullet.bullet_logger</code>: log to the Bullet log file (Rails.root/log/bullet.log)
|
|
52
52
|
* <code>Bullet.rails_logger</code>: add warnings directly to the Rails log
|
|
@@ -127,7 +127,7 @@ If you find bullet does not work for you, *please disable your browser's cache*.
|
|
|
127
127
|
|
|
128
128
|
h2. Advance
|
|
129
129
|
|
|
130
|
-
The bullet
|
|
130
|
+
The bullet gem use rack middleware for http request. If you want to bullet for without http server, such as job server. You can do like this:
|
|
131
131
|
|
|
132
132
|
<pre><code>
|
|
133
133
|
Bullet.start_request if Bullet.enable?
|
|
@@ -233,7 +233,7 @@ And run
|
|
|
233
233
|
|
|
234
234
|
<pre><code>bundle install</code></pre>
|
|
235
235
|
|
|
236
|
-
6. enable the bullet
|
|
236
|
+
6. enable the bullet gem in development, add a line to <code>config/environments/development.rb</code>
|
|
237
237
|
|
|
238
238
|
<pre><code>
|
|
239
239
|
config.after_initialize do
|
|
@@ -73,6 +73,18 @@ module Bullet
|
|
|
73
73
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
74
74
|
origin_load_target
|
|
75
75
|
end
|
|
76
|
+
|
|
77
|
+
alias_method :origin_first, :first
|
|
78
|
+
def first(*args)
|
|
79
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
80
|
+
origin_first(*args)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
alias_method :origin_last, :last
|
|
84
|
+
def last(*args)
|
|
85
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
86
|
+
origin_last(*args)
|
|
87
|
+
end
|
|
76
88
|
end
|
|
77
89
|
|
|
78
90
|
::ActiveRecord::Associations::AssociationProxy.class_eval do
|
|
@@ -67,6 +67,18 @@ module Bullet
|
|
|
67
67
|
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
68
68
|
origin_load_target
|
|
69
69
|
end
|
|
70
|
+
|
|
71
|
+
alias_method :origin_first, :first
|
|
72
|
+
def first(*args)
|
|
73
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
74
|
+
origin_first(*args)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
alias_method :origin_last, :last
|
|
78
|
+
def last(*args)
|
|
79
|
+
Bullet::Detector::NPlusOneQuery.call_association(@owner, @reflection.name)
|
|
80
|
+
origin_last(*args)
|
|
81
|
+
end
|
|
70
82
|
end
|
|
71
83
|
|
|
72
84
|
::ActiveRecord::Associations::AssociationProxy.class_eval do
|
|
@@ -20,34 +20,33 @@ module Bullet
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def add_object_associations(object, associations)
|
|
23
|
-
object_associations.add(object.
|
|
23
|
+
object_associations.add(object.bullet_ar_key, associations) if object.id
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def add_call_object_associations(object, associations)
|
|
27
|
-
if object.id
|
|
28
|
-
call_object_associations.add(object.ar_key, associations)
|
|
29
|
-
end
|
|
27
|
+
call_object_associations.add(object.bullet_ar_key, associations) if object.id
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def add_possible_objects(object_or_objects)
|
|
31
|
+
return unless object_or_objects
|
|
33
32
|
if object_or_objects.is_a? Array
|
|
34
|
-
object_or_objects.each { |object| possible_objects.add object.
|
|
33
|
+
object_or_objects.each { |object| possible_objects.add object.bullet_ar_key }
|
|
35
34
|
else
|
|
36
|
-
possible_objects.add object_or_objects.
|
|
35
|
+
possible_objects.add object_or_objects.bullet_ar_key if object_or_objects.id
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
def add_impossible_object(object)
|
|
41
|
-
impossible_objects.add object.
|
|
40
|
+
impossible_objects.add object.bullet_ar_key if object.id
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def add_eager_loadings(objects, associations)
|
|
45
|
-
|
|
44
|
+
bullet_ar_keys = objects.map(&:bullet_ar_key)
|
|
46
45
|
|
|
47
46
|
to_add = nil
|
|
48
47
|
to_merge, to_delete = [], []
|
|
49
48
|
eager_loadings.each do |k, v|
|
|
50
|
-
key_objects_overlap = k &
|
|
49
|
+
key_objects_overlap = k & bullet_ar_keys
|
|
51
50
|
|
|
52
51
|
next if key_objects_overlap.empty?
|
|
53
52
|
|
|
@@ -57,10 +56,10 @@ module Bullet
|
|
|
57
56
|
else
|
|
58
57
|
to_merge << [key_objects_overlap, ( eager_loadings[k].dup << associations )]
|
|
59
58
|
|
|
60
|
-
keys_without_objects = k -
|
|
59
|
+
keys_without_objects = k - bullet_ar_keys
|
|
61
60
|
to_merge << [keys_without_objects, eager_loadings[k]]
|
|
62
61
|
to_delete << k
|
|
63
|
-
|
|
62
|
+
bullet_ar_keys = bullet_ar_keys - k
|
|
64
63
|
end
|
|
65
64
|
end
|
|
66
65
|
|
|
@@ -68,7 +67,7 @@ module Bullet
|
|
|
68
67
|
to_merge.each { |k,val| eager_loadings.merge k, val }
|
|
69
68
|
to_delete.each { |k| eager_loadings.delete k }
|
|
70
69
|
|
|
71
|
-
eager_loadings.add
|
|
70
|
+
eager_loadings.add bullet_ar_keys, associations unless bullet_ar_keys.empty?
|
|
72
71
|
end
|
|
73
72
|
|
|
74
73
|
private
|