mobility 1.3.0.rc3 → 1.3.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -9
- data/Gemfile.lock +51 -17
- data/README.md +1 -1
- data/lib/mobility/backends/active_record/container.rb +0 -19
- data/lib/mobility/plugins/active_record/dirty.rb +14 -18
- data/lib/mobility/plugins/active_record/query.rb +20 -22
- data/lib/mobility/plugins/arel/nodes/pg_ops.rb +0 -11
- data/lib/mobility/version.rb +1 -1
- data/lib/mobility.rb +2 -2
- data/lib/rails/generators/mobility/templates/initializer.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 488c8b1ec0f603d226b7a0dd54064a27ede153b1c8c3bd1ae078bcfec0dd74e2
|
|
4
|
+
data.tar.gz: ebce70b5815c7618b908459c59bc514647b55f2e792641bc3d400547fb5ae533
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d8dc37e4dd38ead1eb16b593ca153876179770a23b32a63b2c6850509326590c8c80596351328b48c6e40e25df48b99f106e6cbcddd0b940381eaf0c7e41fd6
|
|
7
|
+
data.tar.gz: b0afa4c0962c240658c0e5fe109c76e6db533b7f1ad1679b4ed38094c8dd48cb581fb15f8ac50d57078238d98cade3198b562ee64d2ed1ca9c9af3f3bda5e72c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## 1.3
|
|
4
4
|
|
|
5
|
+
### 1.3.0
|
|
6
|
+
|
|
7
|
+
- Only support ActiveRecord >= 7.0
|
|
8
|
+
- Allow `I18n.available_locales` to contain Strings
|
|
9
|
+
([#612](https://github.com/shioyama/mobility/pull/612))
|
|
10
|
+
- Update CI config, add support for Rails 8
|
|
11
|
+
([#653](https://github.com/shioyama/mobility/pull/653)), thanks
|
|
12
|
+
[d-rodriguez](https://github.com/n-rodriguez)!
|
|
13
|
+
- Fix broken count statements in Active Record 8.0
|
|
14
|
+
([#655](https://github.com/shioyama/mobility/pull/655)), thanks
|
|
15
|
+
[jukra](https://github.com/jukra)!
|
|
16
|
+
|
|
5
17
|
### 1.3.0.rc3
|
|
6
18
|
|
|
7
19
|
- Don't try to load generators if Rails is loaded but AR is not
|
data/Gemfile
CHANGED
|
@@ -10,7 +10,7 @@ group :development, :test do
|
|
|
10
10
|
when 'active_record'
|
|
11
11
|
orm_version ||= '7.0'
|
|
12
12
|
case orm_version
|
|
13
|
-
when '6.1', '7.0', '7.1'
|
|
13
|
+
when '6.1', '7.0', '7.1', '7.2', '8.0'
|
|
14
14
|
gem 'activerecord', "~> #{orm_version}.0"
|
|
15
15
|
when 'edge'
|
|
16
16
|
git 'https://github.com/rails/rails.git', branch: 'main' do
|
|
@@ -45,19 +45,15 @@ group :development, :test do
|
|
|
45
45
|
gem 'pry-byebug'
|
|
46
46
|
case ENV['DB']
|
|
47
47
|
when 'sqlite3'
|
|
48
|
-
if orm == 'active_record' && orm_version
|
|
49
|
-
gem 'sqlite3', '
|
|
48
|
+
if orm == 'active_record' && orm_version >= '8.0'
|
|
49
|
+
gem 'sqlite3', '>= 2.1.0'
|
|
50
50
|
else
|
|
51
|
-
gem 'sqlite3', '~> 1.
|
|
51
|
+
gem 'sqlite3', '~> 1.5.0'
|
|
52
52
|
end
|
|
53
53
|
when 'mysql'
|
|
54
54
|
gem 'mysql2'
|
|
55
55
|
when 'postgres'
|
|
56
|
-
|
|
57
|
-
gem 'pg', '< 1.0'
|
|
58
|
-
else
|
|
59
|
-
gem 'pg'
|
|
60
|
-
end
|
|
56
|
+
gem 'pg'
|
|
61
57
|
end
|
|
62
58
|
end
|
|
63
59
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
mobility (1.3.0.
|
|
4
|
+
mobility (1.3.0.rc3)
|
|
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
|
-
|
|
11
|
+
activemodel (7.1.5)
|
|
12
|
+
activesupport (= 7.1.5)
|
|
13
|
+
activerecord (7.1.5)
|
|
14
|
+
activemodel (= 7.1.5)
|
|
15
|
+
activesupport (= 7.1.5)
|
|
16
|
+
timeout (>= 0.4.0)
|
|
17
|
+
activesupport (7.1.5)
|
|
18
|
+
base64
|
|
19
|
+
benchmark (>= 0.3)
|
|
20
|
+
bigdecimal
|
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
22
|
+
connection_pool (>= 2.2.5)
|
|
23
|
+
drb
|
|
24
|
+
i18n (>= 1.6, < 2)
|
|
25
|
+
logger (>= 1.4.2)
|
|
26
|
+
minitest (>= 5.1)
|
|
27
|
+
mutex_m
|
|
28
|
+
securerandom (>= 0.3)
|
|
29
|
+
tzinfo (~> 2.0)
|
|
30
|
+
base64 (0.2.0)
|
|
31
|
+
benchmark (0.4.0)
|
|
32
|
+
benchmark-ips (2.14.0)
|
|
33
|
+
bigdecimal (3.1.8)
|
|
12
34
|
byebug (11.1.3)
|
|
13
35
|
coderay (1.1.3)
|
|
14
|
-
concurrent-ruby (1.
|
|
36
|
+
concurrent-ruby (1.3.4)
|
|
37
|
+
connection_pool (2.4.1)
|
|
15
38
|
database_cleaner (1.99.0)
|
|
16
39
|
diff-lcs (1.5.1)
|
|
17
|
-
|
|
40
|
+
drb (2.2.1)
|
|
41
|
+
ffi (1.17.0-x86_64-linux-gnu)
|
|
18
42
|
formatador (1.1.0)
|
|
19
|
-
guard (2.
|
|
43
|
+
guard (2.19.0)
|
|
20
44
|
formatador (>= 0.2.4)
|
|
21
45
|
listen (>= 2.7, < 4.0)
|
|
22
46
|
lumberjack (>= 1.0.12, < 2.0)
|
|
@@ -30,13 +54,17 @@ GEM
|
|
|
30
54
|
guard (~> 2.1)
|
|
31
55
|
guard-compat (~> 1.1)
|
|
32
56
|
rspec (>= 2.99.0, < 4.0)
|
|
33
|
-
i18n (1.14.
|
|
57
|
+
i18n (1.14.6)
|
|
34
58
|
concurrent-ruby (~> 1.0)
|
|
35
59
|
listen (3.9.0)
|
|
36
60
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
37
61
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
62
|
+
logger (1.6.1)
|
|
38
63
|
lumberjack (1.2.10)
|
|
39
|
-
method_source (1.
|
|
64
|
+
method_source (1.1.0)
|
|
65
|
+
mini_portile2 (2.8.8)
|
|
66
|
+
minitest (5.25.2)
|
|
67
|
+
mutex_m (0.3.0)
|
|
40
68
|
nenv (0.3.0)
|
|
41
69
|
notiffany (0.1.3)
|
|
42
70
|
nenv (~> 0.1)
|
|
@@ -47,35 +75,41 @@ GEM
|
|
|
47
75
|
pry-byebug (3.10.1)
|
|
48
76
|
byebug (~> 11.0)
|
|
49
77
|
pry (>= 0.13, < 0.15)
|
|
50
|
-
rack (3.
|
|
78
|
+
rack (3.1.8)
|
|
51
79
|
rake (12.3.3)
|
|
52
80
|
rb-fsevent (0.11.2)
|
|
53
|
-
rb-inotify (0.
|
|
81
|
+
rb-inotify (0.11.1)
|
|
54
82
|
ffi (~> 1.0)
|
|
55
|
-
request_store (1.
|
|
83
|
+
request_store (1.7.0)
|
|
56
84
|
rack (>= 1.4)
|
|
57
85
|
rspec (3.13.0)
|
|
58
86
|
rspec-core (~> 3.13.0)
|
|
59
87
|
rspec-expectations (~> 3.13.0)
|
|
60
88
|
rspec-mocks (~> 3.13.0)
|
|
61
|
-
rspec-core (3.13.
|
|
89
|
+
rspec-core (3.13.2)
|
|
62
90
|
rspec-support (~> 3.13.0)
|
|
63
|
-
rspec-expectations (3.13.
|
|
91
|
+
rspec-expectations (3.13.3)
|
|
64
92
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
93
|
rspec-support (~> 3.13.0)
|
|
66
|
-
rspec-mocks (3.13.
|
|
94
|
+
rspec-mocks (3.13.2)
|
|
67
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
68
96
|
rspec-support (~> 3.13.0)
|
|
69
97
|
rspec-support (3.13.1)
|
|
98
|
+
securerandom (0.3.2)
|
|
70
99
|
shellany (0.0.1)
|
|
71
|
-
sqlite3 (1.
|
|
72
|
-
|
|
73
|
-
|
|
100
|
+
sqlite3 (1.5.4)
|
|
101
|
+
mini_portile2 (~> 2.8.0)
|
|
102
|
+
thor (1.3.2)
|
|
103
|
+
timeout (0.4.2)
|
|
104
|
+
tzinfo (2.0.6)
|
|
105
|
+
concurrent-ruby (~> 1.0)
|
|
106
|
+
yard (0.9.37)
|
|
74
107
|
|
|
75
108
|
PLATFORMS
|
|
76
109
|
x86_64-linux
|
|
77
110
|
|
|
78
111
|
DEPENDENCIES
|
|
112
|
+
activerecord (~> 7.1.0)
|
|
79
113
|
benchmark-ips
|
|
80
114
|
database_cleaner (~> 1.5, >= 1.5.3)
|
|
81
115
|
guard-rspec
|
|
@@ -83,7 +117,7 @@ DEPENDENCIES
|
|
|
83
117
|
pry-byebug
|
|
84
118
|
rake (~> 12, >= 12.2.1)
|
|
85
119
|
rspec (~> 3.0)
|
|
86
|
-
sqlite3 (~> 1.
|
|
120
|
+
sqlite3 (~> 1.5.0)
|
|
87
121
|
yard (~> 0.9.0)
|
|
88
122
|
|
|
89
123
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -60,7 +60,7 @@ gem 'mobility', '~> 1.3.0.rc3'
|
|
|
60
60
|
### ActiveRecord (Rails)
|
|
61
61
|
|
|
62
62
|
Requirements:
|
|
63
|
-
- ActiveRecord >=
|
|
63
|
+
- ActiveRecord >= 7.0
|
|
64
64
|
|
|
65
65
|
To translate attributes on a model, extend `Mobility`, then call `translates`
|
|
66
66
|
passing in one or more attributes as well as a hash of options (see below).
|
|
@@ -86,25 +86,6 @@ Implements the {Mobility::Backends::Container} backend for ActiveRecord models.
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
setup do |_attributes, options|
|
|
90
|
-
# Fix for duping depth-2 jsonb column in AR < 5.0
|
|
91
|
-
if ::ActiveRecord::VERSION::STRING < '5.0'
|
|
92
|
-
column_name = options[:column_name]
|
|
93
|
-
module_name = "MobilityArContainer#{column_name.to_s.camelcase}"
|
|
94
|
-
unless const_defined?(module_name)
|
|
95
|
-
dupable = Module.new do
|
|
96
|
-
class_eval <<-EOM, __FILE__, __LINE__ + 1
|
|
97
|
-
def initialize_dup(source)
|
|
98
|
-
super
|
|
99
|
-
self.#{column_name} = source.#{column_name}.deep_dup
|
|
100
|
-
end
|
|
101
|
-
EOM
|
|
102
|
-
end
|
|
103
|
-
include const_set(module_name, dupable)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
89
|
private
|
|
109
90
|
|
|
110
91
|
def model_translations(locale)
|
|
@@ -79,28 +79,24 @@ locale suffix, so +title_en+, +title_pt_br+, etc.)
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
module InstanceMethods
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
end
|
|
82
|
+
def saved_changes
|
|
83
|
+
super.merge(mutations_from_mobility.previous_changes)
|
|
84
|
+
end
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
def changes_to_save
|
|
87
|
+
super.merge(mutations_from_mobility.changes)
|
|
88
|
+
end
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
def changed_attribute_names_to_save
|
|
91
|
+
super + mutations_from_mobility.changed
|
|
92
|
+
end
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
def attributes_in_database
|
|
95
|
+
super.merge(mutations_from_mobility.changed_attributes)
|
|
96
|
+
end
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
super || mutations_from_mobility.changed?
|
|
102
|
-
end
|
|
103
|
-
end
|
|
98
|
+
def has_changes_to_save?
|
|
99
|
+
super || mutations_from_mobility.changed?
|
|
104
100
|
end
|
|
105
101
|
|
|
106
102
|
def reload(*)
|
|
@@ -137,19 +137,19 @@ enabled for any one attribute on the model.
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def order(opts, *rest)
|
|
140
|
-
return super unless
|
|
140
|
+
return super unless klass.respond_to?(:mobility_attribute?)
|
|
141
141
|
|
|
142
142
|
case opts
|
|
143
143
|
when Symbol, String
|
|
144
|
-
|
|
144
|
+
klass.mobility_attribute?(opts) ? order({ opts => :asc }, *rest) : super
|
|
145
145
|
when ::Hash
|
|
146
|
-
i18n_keys, keys = opts.keys.partition(
|
|
146
|
+
i18n_keys, keys = opts.keys.partition(&klass.method(:mobility_attribute?))
|
|
147
147
|
return super if i18n_keys.empty?
|
|
148
148
|
|
|
149
149
|
base = keys.empty? ? self : super(opts.slice(keys))
|
|
150
150
|
|
|
151
151
|
i18n_keys.inject(base) do |query, key|
|
|
152
|
-
backend_class =
|
|
152
|
+
backend_class = klass.mobility_backend_class(key)
|
|
153
153
|
dir, node = opts[key], backend_node(key)
|
|
154
154
|
backend_class.apply_scope(query, node).order(node.send(dir.downcase))
|
|
155
155
|
end
|
|
@@ -158,29 +158,27 @@ enabled for any one attribute on the model.
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return super(*attrs, &block) if (method_name == 'select' && block.present?)
|
|
161
|
+
%w[pluck group select].each do |method_name|
|
|
162
|
+
define_method method_name do |*attrs, &block|
|
|
163
|
+
return super(*attrs, &block) if (method_name == 'select' && block.present?)
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
return super(*attrs, &block) unless klass.respond_to?(:mobility_attribute?)
|
|
167
166
|
|
|
168
|
-
|
|
167
|
+
return super(*attrs, &block) unless attrs.any?(&klass.method(:mobility_attribute?))
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
keys = attrs.dup
|
|
171
170
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
end
|
|
179
|
-
@klass.mobility_backend_class(key).apply_scope(query, backend_node(key))
|
|
171
|
+
base = keys.each_with_index.inject(self) do |query, (key, index)|
|
|
172
|
+
next query unless klass.mobility_attribute?(key)
|
|
173
|
+
keys[index] = backend_node(key)
|
|
174
|
+
if method_name == "select" && query.order_values.any?
|
|
175
|
+
keys[index] = keys[index]
|
|
176
|
+
.as(::Mobility::Plugins::ActiveRecord::Query.attribute_alias(key.to_s))
|
|
180
177
|
end
|
|
181
|
-
|
|
182
|
-
base.public_send(method_name, *keys, &block)
|
|
178
|
+
klass.mobility_backend_class(key).apply_scope(query, backend_node(key))
|
|
183
179
|
end
|
|
180
|
+
|
|
181
|
+
base.public_send(method_name, *keys, &block)
|
|
184
182
|
end
|
|
185
183
|
end
|
|
186
184
|
|
|
@@ -189,7 +187,7 @@ enabled for any one attribute on the model.
|
|
|
189
187
|
# @param [Symbol] locale Locale
|
|
190
188
|
# @return [Arel::Node] Arel node for this attribute in given locale
|
|
191
189
|
def backend_node(name, locale = Mobility.locale)
|
|
192
|
-
|
|
190
|
+
klass.mobility_backend_class(name)[name, locale]
|
|
193
191
|
end
|
|
194
192
|
|
|
195
193
|
class WhereChain < ::ActiveRecord::QueryMethods::WhereChain
|
|
@@ -26,17 +26,6 @@ module Mobility
|
|
|
26
26
|
end)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
# Needed for AR 4.2, can be removed when support is deprecated
|
|
30
|
-
if ::ActiveRecord::VERSION::STRING < '5.0'
|
|
31
|
-
[JsonbDashDoubleArrow, HstoreDashArrow].each do |klass|
|
|
32
|
-
klass.class_eval do
|
|
33
|
-
def quoted_node other
|
|
34
|
-
other && super
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
29
|
class Jsonb < JsonbDashDoubleArrow
|
|
41
30
|
def to_dash_arrow
|
|
42
31
|
JsonbDashArrow.new left, right
|
data/lib/mobility/version.rb
CHANGED
data/lib/mobility.rb
CHANGED
|
@@ -228,9 +228,9 @@ module Mobility
|
|
|
228
228
|
# methods (in LocaleAccessors) than is really necessary.
|
|
229
229
|
def available_locales
|
|
230
230
|
if defined?(Rails) && Rails.respond_to?(:application) && Rails.application
|
|
231
|
-
Rails.application.config.i18n.available_locales&.map(&:to_sym) || I18n.available_locales
|
|
231
|
+
Rails.application.config.i18n.available_locales&.map(&:to_sym) || I18n.available_locales.map(&:to_sym)
|
|
232
232
|
else
|
|
233
|
-
I18n.available_locales
|
|
233
|
+
I18n.available_locales.map(&:to_sym)
|
|
234
234
|
end
|
|
235
235
|
end
|
|
236
236
|
|
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.3.0
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Salzberg
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
|
|
36
36
|
tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date: 2024-
|
|
38
|
+
date: 2024-11-30 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: request_store
|
|
@@ -270,9 +270,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
270
270
|
version: '2.5'
|
|
271
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
requirements:
|
|
273
|
-
- - "
|
|
273
|
+
- - ">="
|
|
274
274
|
- !ruby/object:Gem::Version
|
|
275
|
-
version:
|
|
275
|
+
version: '0'
|
|
276
276
|
requirements: []
|
|
277
277
|
rubygems_version: 3.4.6
|
|
278
278
|
signing_key:
|
metadata.gz.sig
CHANGED
|
Binary file
|