mobility 1.2.6 → 1.2.9

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
  SHA256:
3
- metadata.gz: 9c7f067617904bfb7739ce49cd155ffc0ec0b6aeeb7ebdbbf13309afd0e7a106
4
- data.tar.gz: ced82292e8e99ee28bb7b3962e964147481200539db25d87bae0caa24fa783da
3
+ metadata.gz: 9a2836c1681d1832331e807e58fa61956426ddc3cc730c15e6b3d6ebac2fce40
4
+ data.tar.gz: 61c798b73769f7d73bb5a3a97b3a1a27ac8884a186df89aeb5ceef0ecb92b692
5
5
  SHA512:
6
- metadata.gz: 38494c35209217644cf9b408ce0d55c671b65db3b131118d0ce934b6065eccb0d64a032ede1dba0244cf28a3960973163f0c3ac31976fd8248eb514a750a0a49
7
- data.tar.gz: fe5d5ef7ea05f091eaed43330b9f8e1b23716176daf2595a61fdb01344fc25cfa92a2ba237822e5b9bcec101c60f9d22ab63ae2cd59c888ff4315ac08150d49b
6
+ metadata.gz: e8693fb2b5d997a1d7029413aee5c5f064eeafbef6f8a10ad2c947bd545fff72e238f6d57ebaae8761d5948e036446d310f7ce9da3c047a7577818919dfd7908
7
+ data.tar.gz: e980cc7d53a32c517c04994105540fd9635aae5899d35cecb1544a36ef052619adb0647b58ec666902402e8ad642c85aa576f0301d3708211e83b5f3d0e6d95b
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## 1.2
4
4
 
5
+ ### 1.2.9
6
+ - Fix missing method `mobility_attribute?` on Rails 7
7
+ ([#582](https://github.com/shioyama/mobility/pull/582) and
8
+ [#584](https://github.com/shioyama/mobility/pull/584))
9
+
10
+ ### 1.2.8
11
+ - Fix issues with subclassing, such as when using AR STI,
12
+ fixes [#566](https://github.com/shioyama/mobility/issues/566)
13
+ ([#568](https://github.com/shioyama/mobility/pull/568))
14
+ - Handle attribute_method_matchers rename (part of #560)
15
+
16
+ ### 1.2.7
17
+ - Do not query same attribute more than once, fixes
18
+ [#564](https://github.com/shioyama/mobility/pull/578)
19
+ ([#577](https://github.com/shioyama/mobility/pull/577))
20
+
5
21
  ### 1.2.6
6
22
  - Require mfa on rubygems
7
23
  ([#545](https://github.com/shioyama/mobility/pull/545))
data/Gemfile.lock CHANGED
@@ -1,21 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (1.3.0.alpha)
4
+ mobility (1.2.8)
5
5
  i18n (>= 0.6.10, < 2)
6
6
  request_store (~> 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- benchmark-ips (2.9.1)
11
+ activemodel (7.0.3)
12
+ activesupport (= 7.0.3)
13
+ activerecord (7.0.3)
14
+ activemodel (= 7.0.3)
15
+ activesupport (= 7.0.3)
16
+ activesupport (7.0.3)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ benchmark-ips (2.10.0)
12
22
  byebug (11.1.3)
13
23
  coderay (1.1.3)
14
- concurrent-ruby (1.1.9)
24
+ concurrent-ruby (1.1.10)
15
25
  database_cleaner (1.99.0)
16
- diff-lcs (1.4.4)
17
- ffi (1.15.4)
18
- formatador (0.3.0)
26
+ diff-lcs (1.5.0)
27
+ ffi (1.15.5)
28
+ formatador (1.1.0)
19
29
  guard (2.18.0)
20
30
  formatador (>= 0.2.4)
21
31
  listen (>= 2.7, < 4.0)
@@ -30,55 +40,63 @@ GEM
30
40
  guard (~> 2.1)
31
41
  guard-compat (~> 1.1)
32
42
  rspec (>= 2.99.0, < 4.0)
33
- i18n (1.8.10)
43
+ i18n (1.10.0)
34
44
  concurrent-ruby (~> 1.0)
35
- listen (3.7.0)
45
+ listen (3.7.1)
36
46
  rb-fsevent (~> 0.10, >= 0.10.3)
37
47
  rb-inotify (~> 0.9, >= 0.9.10)
38
48
  lumberjack (1.2.8)
39
49
  method_source (1.0.0)
50
+ minitest (5.16.1)
40
51
  nenv (0.3.0)
41
52
  notiffany (0.1.3)
42
53
  nenv (~> 0.1)
43
54
  shellany (~> 0.0)
55
+ pg (1.3.5)
44
56
  pry (0.13.1)
45
57
  coderay (~> 1.1)
46
58
  method_source (~> 1.0)
47
59
  pry-byebug (3.9.0)
48
60
  byebug (~> 11.0)
49
61
  pry (~> 0.13.0)
50
- rack (2.2.3)
62
+ rack (2.2.3.1)
51
63
  rake (12.3.3)
52
- rb-fsevent (0.11.0)
64
+ rb-fsevent (0.11.1)
53
65
  rb-inotify (0.10.1)
54
66
  ffi (~> 1.0)
55
- request_store (1.5.0)
67
+ request_store (1.5.1)
56
68
  rack (>= 1.4)
57
- rspec (3.10.0)
58
- rspec-core (~> 3.10.0)
59
- rspec-expectations (~> 3.10.0)
60
- rspec-mocks (~> 3.10.0)
61
- rspec-core (3.10.1)
62
- rspec-support (~> 3.10.0)
63
- rspec-expectations (3.10.1)
69
+ rspec (3.11.0)
70
+ rspec-core (~> 3.11.0)
71
+ rspec-expectations (~> 3.11.0)
72
+ rspec-mocks (~> 3.11.0)
73
+ rspec-core (3.11.0)
74
+ rspec-support (~> 3.11.0)
75
+ rspec-expectations (3.11.0)
64
76
  diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.10.0)
66
- rspec-mocks (3.10.2)
77
+ rspec-support (~> 3.11.0)
78
+ rspec-mocks (3.11.1)
67
79
  diff-lcs (>= 1.2.0, < 2.0)
68
- rspec-support (~> 3.10.0)
69
- rspec-support (3.10.2)
80
+ rspec-support (~> 3.11.0)
81
+ rspec-support (3.11.0)
70
82
  shellany (0.0.1)
71
- thor (1.1.0)
72
- yard (0.9.26)
83
+ thor (1.2.1)
84
+ tzinfo (2.0.4)
85
+ concurrent-ruby (~> 1.0)
86
+ webrick (1.7.0)
87
+ yard (0.9.28)
88
+ webrick (~> 1.7.0)
73
89
 
74
90
  PLATFORMS
75
91
  ruby
76
92
 
77
93
  DEPENDENCIES
94
+ activerecord (~> 7.0.0)
78
95
  benchmark-ips
79
96
  database_cleaner (~> 1.5, >= 1.5.3)
80
97
  guard-rspec
81
98
  mobility!
99
+ pg
82
100
  pry-byebug
83
101
  rake (~> 12, >= 12.2.1)
84
102
  rspec (~> 3.0)
data/README.md CHANGED
@@ -55,7 +55,7 @@ Installation
55
55
  Add this line to your application's Gemfile:
56
56
 
57
57
  ```ruby
58
- gem 'mobility', '~> 1.2.6'
58
+ gem 'mobility', '~> 1.2.9'
59
59
  ```
60
60
 
61
61
  ### ActiveRecord (Rails)
@@ -153,7 +153,13 @@ the ActiveRecord dirty plugin for more information.
153
153
  # suffixes is simplest given they change from Rails version to version.
154
154
  def patterns
155
155
  @patterns ||=
156
- (klass.attribute_method_matchers.map { |p| "#{p.prefix}%s#{p.suffix}" } - excluded_patterns)
156
+ begin
157
+ # Method name changes in Rails 7.1
158
+ attribute_method_patterns = klass.respond_to?(:attribute_method_patterns) ?
159
+ klass.attribute_method_patterns :
160
+ klass.attribute_method_matchers
161
+ attribute_method_patterns.map { |p| "#{p.prefix}%s#{p.suffix}" } - excluded_patterns
162
+ end
157
163
  end
158
164
 
159
165
  private
@@ -163,9 +163,8 @@ enabled for any one attribute on the model.
163
163
  define_method method_name do |*attrs, &block|
164
164
  return super(*attrs, &block) if (method_name == 'select' && block.present?)
165
165
 
166
- if ::ActiveRecord::VERSION::STRING < '7.0'
167
- return super(*attrs, &block) unless @klass.respond_to?(:mobility_attribute?)
168
- end
166
+ return super(*attrs, &block) unless @klass.respond_to?(:mobility_attribute?)
167
+
169
168
  return super(*attrs, &block) unless attrs.any?(&@klass.method(:mobility_attribute?))
170
169
 
171
170
  keys = attrs.dup
@@ -223,10 +222,13 @@ enabled for any one attribute on the model.
223
222
 
224
223
  keys, predicates = opts.keys.map(&:to_s), []
225
224
 
225
+ used_keys = []
226
+
226
227
  query_map = mods.inject(IDENTITY) do |qm, mod|
227
- i18n_keys = mod.names & keys
228
+ i18n_keys = mod.names & keys - used_keys
228
229
  next qm if i18n_keys.empty?
229
230
 
231
+ used_keys += i18n_keys
230
232
  mod_predicates = i18n_keys.map do |key|
231
233
  build_predicate(scope.backend_node(key.to_sym, locale), opts.delete(key))
232
234
  end
@@ -159,16 +159,22 @@ Defines:
159
159
  raise KeyError, "No backend for: #{name}"
160
160
  end
161
161
 
162
- def inherited(klass)
163
- parent_classes = mobility_backend_classes.freeze # ensure backend classes are not modified after being inherited
164
- klass.class_eval { @mobility_backend_classes = parent_classes.dup }
165
- super
166
- end
167
-
168
162
  protected
169
163
 
170
164
  def mobility_backend_classes
171
- @mobility_backend_classes ||= {}
165
+ if @mobility_backend_classes
166
+ @mobility_backend_classes
167
+ else
168
+ @mobility_backend_classes = {}
169
+ parent_class = self.superclass
170
+ while parent_class&.respond_to?(:mobility_backend_classes, true)
171
+ # ensure backend classes are not modified after being inherited
172
+ parent_class_classes = parent_class.mobility_backend_classes.freeze
173
+ @mobility_backend_classes.merge!(parent_class_classes)
174
+ parent_class = parent_class.superclass
175
+ end
176
+ @mobility_backend_classes
177
+ end
172
178
  end
173
179
  end
174
180
 
@@ -135,10 +135,13 @@ ActiveRecord query plugin.
135
135
  keys, predicates = cond.keys, []
136
136
  model = dataset.model
137
137
 
138
+ used_keys = []
139
+
138
140
  query_map = attribute_modules(model).inject(IDENTITY) do |qm, mod|
139
- i18n_keys = mod.names.map(&:to_sym) & keys
141
+ i18n_keys = mod.names.map(&:to_sym) & keys - used_keys
140
142
  next qm if i18n_keys.empty?
141
143
 
144
+ used_keys += i18n_keys
142
145
  mod_predicates = i18n_keys.map do |key|
143
146
  build_predicate(dataset.backend_op(key, locale), cond.delete(key))
144
147
  end
@@ -8,7 +8,7 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 2
11
- TINY = 6
11
+ TINY = 9
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -34,7 +34,7 @@ cert_chain:
34
34
  QHgocnSksU5GOM+G2UhjVycbTamd+bCxjWAZTEDZNafFt5CmnfK1D1UTIblR/ci9
35
35
  fUDdW+GhxhobB8N1mtDRlhELoxLLjx7mSvJ3Wg==
36
36
  -----END CERTIFICATE-----
37
- date: 2022-03-02 00:00:00.000000000 Z
37
+ date: 2022-06-24 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: request_store
metadata.gz.sig CHANGED
Binary file