bullet 5.7.3 → 5.7.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74a6d3a3671ea862309e08ecd7cb438ff1a0b1fb
4
- data.tar.gz: 4796ef4d3dc79f88cab4b3ea1800a368935c3e5b
3
+ metadata.gz: 8dc58f03ac00764a73d88e5687a32895d94abcac
4
+ data.tar.gz: bd8d3b6215063a5536489aeaab2ffbdc72cb85e3
5
5
  SHA512:
6
- metadata.gz: 1590f51058fa2b58b2adf9f0df431c542bac23e2ed33d42a8733a80419d756c253740bf3c2dc47c89a2945018674164efbe5ee4912880c1b49a366d608859a6e
7
- data.tar.gz: 45ba5a4438cc5003b6b5e05e598a9e71ad3b3145996e19d7cc248bc0c6e5c7d03546d1aaf94158a1eb631957bf0fdeae44ef0701917957f1a60eb35f85c3aa1d
6
+ metadata.gz: c19ffb78e51f2307ce792759149e67a8f354db648b1aa0a0a746c5153c2337596ca067bbec8ed12df536bb455502438df50fc23dce1c05c1595e31b488ff1c33
7
+ data.tar.gz: 784d901307fbd9ba2286d6281e25229ea11e580a81b2dd7d5514a20b713faa72902d2c79ab6804d0ed93c61859cd1bb36955374b16e4101353329b318a8fa8d3
@@ -1,5 +1,10 @@
1
1
  ## Next Release
2
2
 
3
+ ## 5.7.4 (10/03/2018)
4
+
5
+ * Avoid Bullet from making extra queries in mongoid6
6
+ * Use caller for ruby 1.9 while caller_locations for 2.0+
7
+
3
8
  ## 5.7.3 (17/02/2018)
4
9
 
5
10
  * Exclude configured bundler path in addition to '/vendor'
@@ -21,13 +21,15 @@ module Bullet
21
21
  end
22
22
 
23
23
  def each(&block)
24
- records = view.map { |doc| ::Mongoid::Factory.from_db(klass, doc) }
24
+ return to_enum unless block_given?
25
+ records = []
26
+ origin_each { |record| records << record }
25
27
  if records.length > 1
26
28
  Bullet::Detector::NPlusOneQuery.add_possible_objects(records)
27
29
  elsif records.size == 1
28
30
  Bullet::Detector::NPlusOneQuery.add_impossible_object(records.first)
29
31
  end
30
- origin_each(&block)
32
+ records.each(&block)
31
33
  end
32
34
 
33
35
  def eager_load(docs)
@@ -6,8 +6,7 @@ module Bullet
6
6
  app_root = rails? ? Rails.root.to_s : Dir.pwd
7
7
  vendor_root = app_root + VENDOR_PATH
8
8
  bundler_path = Bundler.bundle_path.to_s
9
- caller_locations.select do |location|
10
- caller_path = location.absolute_path.to_s
9
+ select_caller_locations do |caller_path|
11
10
  caller_path.include?(app_root) && !caller_path.include?(vendor_root) && !caller_path.include?(bundler_path) ||
12
11
  Bullet.stacktrace_includes.any? do |include_pattern|
13
12
  case include_pattern
@@ -33,5 +32,20 @@ module Bullet
33
32
  end
34
33
  end
35
34
  end
35
+
36
+ private
37
+
38
+ def select_caller_locations
39
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
40
+ caller.select do |caller_path|
41
+ yield caller_path
42
+ end
43
+ else
44
+ caller_locations.select do |location|
45
+ caller_path = location.absolute_path.to_s
46
+ yield caller_path
47
+ end
48
+ end
49
+ end
36
50
  end
37
51
  end
@@ -1,3 +1,3 @@
1
1
  module Bullet
2
- VERSION = '5.7.3'.freeze
2
+ VERSION = '5.7.4'.freeze
3
3
  end
@@ -65,6 +65,6 @@ module Support
65
65
  Mongoid::IdentityMap.clear if Mongoid.const_defined?(:IdentityMap)
66
66
  end
67
67
 
68
- extend self
68
+ module_function
69
69
  end
70
70
  end
@@ -232,6 +232,6 @@ module Support
232
232
  end
233
233
  end
234
234
 
235
- extend self
235
+ module_function
236
236
  end
237
237
  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: 5.7.3
4
+ version: 5.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-17 00:00:00.000000000 Z
11
+ date: 2018-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport