mobility 1.2.1 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +21 -5
- data/Gemfile.lock +9 -9
- data/README.md +1 -1
- data/lib/mobility/backend.rb +6 -0
- data/lib/mobility/backends/sequel/container.rb +1 -1
- data/lib/mobility/plugins/backend.rb +22 -4
- data/lib/mobility/plugins/fallbacks.rb +23 -29
- data/lib/mobility/version.rb +1 -1
- data/lib/rails/generators/mobility/backend_generators/base.rb +3 -1
- data.tar.gz.sig +3 -2
- metadata +2 -2
- 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: ad89c4b8f858e06961d867d4d6fef4ae2b7fa05228c29beb1262d6bdfbd60eff
|
4
|
+
data.tar.gz: 8e626e914ffc5533cd1d7932f66bf7c14acaeae2b0b1bd9cba17539a23389fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d1d31e256f1f2cd9c04ed2f83d73dcef576248bbc0dfc28550da9d2d7e9c66aef0df73ab955324b0669dfdd13ad2bf790049125e16bd9a263d8c3df10713c84
|
7
|
+
data.tar.gz: 00a3d9bd1b1fd47fd0e9c732d9ee40709761490029269b629500c876b5d4acdb847e8c512a8de9329a213578202430120b956adb322c7921300895f9dabd8931
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,26 @@
|
|
1
1
|
# Mobility Changelog
|
2
2
|
|
3
|
-
##
|
4
|
-
- Assign blank values in pg hash backends
|
5
|
-
([#516](https://github.com/shioyama/mobility/pull/516))
|
3
|
+
## 1.2
|
6
4
|
|
7
|
-
|
5
|
+
### 1.2.5
|
6
|
+
- Avoid referencing ActiveRecord::Base
|
7
|
+
([#550](https://github.com/shioyama/mobility/pull/550))
|
8
8
|
|
9
|
-
|
9
|
+
### 1.2.4
|
10
|
+
- Fix fallbacks performance regression
|
11
|
+
([#548](https://github.com/shioyama/mobility/pull/548))
|
12
|
+
|
13
|
+
### 1.2.3
|
14
|
+
- Fix passing wrong options to super in fallbacks plugin
|
15
|
+
([#539](https://github.com/shioyama/mobility/pull/539))
|
16
|
+
|
17
|
+
### 1.2.2
|
18
|
+
- Make models work with `Marshal.dump`
|
19
|
+
([#532](https://github.com/shioyama/mobility/pull/532))
|
20
|
+
- Fix Sequel container op in Sequel
|
21
|
+
([#533](https://github.com/shioyama/mobility/pull/533))
|
22
|
+
- Simplify Fallbacks plugin
|
23
|
+
([#531](https://github.com/shioyama/mobility/pull/531))
|
10
24
|
|
11
25
|
### 1.2.1
|
12
26
|
- Refactor ColumnFallback plugin
|
@@ -22,6 +36,8 @@
|
|
22
36
|
- Clearly distinguish backend classes from their configured subclasses
|
23
37
|
([#527](https://github.com/shioyama/mobility/pull/527))
|
24
38
|
|
39
|
+
## 1.1
|
40
|
+
|
25
41
|
### 1.1.3
|
26
42
|
- Do not swallow keyword args on ruby 3 in fallthrough accessors
|
27
43
|
([#520](https://github.com/shioyama/mobility/pull/520)) thanks
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/rails/rails.git
|
3
|
-
revision:
|
3
|
+
revision: 5647a9c1ced68d20338552d47a3b755e10a271c4
|
4
4
|
branch: main
|
5
5
|
specs:
|
6
6
|
activemodel (7.0.0.alpha2)
|
@@ -17,28 +17,28 @@ GIT
|
|
17
17
|
PATH
|
18
18
|
remote: .
|
19
19
|
specs:
|
20
|
-
mobility (1.
|
20
|
+
mobility (1.3.0.alpha)
|
21
21
|
i18n (>= 0.6.10, < 2)
|
22
22
|
request_store (~> 1.0)
|
23
23
|
|
24
24
|
GEM
|
25
25
|
remote: https://rubygems.org/
|
26
26
|
specs:
|
27
|
-
benchmark-ips (2.
|
27
|
+
benchmark-ips (2.9.1)
|
28
28
|
byebug (11.1.3)
|
29
29
|
coderay (1.1.3)
|
30
30
|
concurrent-ruby (1.1.9)
|
31
31
|
database_cleaner (1.99.0)
|
32
32
|
diff-lcs (1.4.4)
|
33
|
-
ffi (1.15.
|
34
|
-
formatador (0.
|
35
|
-
guard (2.
|
33
|
+
ffi (1.15.4)
|
34
|
+
formatador (0.3.0)
|
35
|
+
guard (2.18.0)
|
36
36
|
formatador (>= 0.2.4)
|
37
37
|
listen (>= 2.7, < 4.0)
|
38
38
|
lumberjack (>= 1.0.12, < 2.0)
|
39
39
|
nenv (~> 0.1)
|
40
40
|
notiffany (~> 0.0)
|
41
|
-
pry (>= 0.
|
41
|
+
pry (>= 0.13.0)
|
42
42
|
shellany (~> 0.0)
|
43
43
|
thor (>= 0.18.1)
|
44
44
|
guard-compat (1.2.1)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
rspec (>= 2.99.0, < 4.0)
|
49
49
|
i18n (1.8.10)
|
50
50
|
concurrent-ruby (~> 1.0)
|
51
|
-
listen (3.
|
51
|
+
listen (3.7.0)
|
52
52
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
53
53
|
rb-inotify (~> 0.9, >= 0.9.10)
|
54
54
|
lumberjack (1.2.8)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
pry (~> 0.13.0)
|
68
68
|
rack (2.2.3)
|
69
69
|
rake (12.3.3)
|
70
|
-
rb-fsevent (0.
|
70
|
+
rb-fsevent (0.11.0)
|
71
71
|
rb-inotify (0.10.1)
|
72
72
|
ffi (~> 1.0)
|
73
73
|
request_store (1.5.0)
|
data/README.md
CHANGED
data/lib/mobility/backend.rb
CHANGED
@@ -77,6 +77,12 @@ On top of this, a backend will normally:
|
|
77
77
|
@attribute = args[1]
|
78
78
|
end
|
79
79
|
|
80
|
+
def ==(backend)
|
81
|
+
backend.class == self.class &&
|
82
|
+
backend.attribute == attribute &&
|
83
|
+
backend.model == model
|
84
|
+
end
|
85
|
+
|
80
86
|
# @!macro [new] backend_reader
|
81
87
|
# Gets the translated value for provided locale from configured backend.
|
82
88
|
# @param [Symbol] locale Locale to read
|
@@ -100,7 +100,7 @@ Implements the {Mobility::Backends::Container} backend for Sequel models.
|
|
100
100
|
# @return [Mobility::Backends::Sequel::Container::JSONOp,Mobility::Backends::Sequel::Container::JSONBOp]
|
101
101
|
def self.build_op(attr, locale)
|
102
102
|
klass = const_get("#{options[:column_type].upcase}Op")
|
103
|
-
klass.new(klass.new(column_name.to_sym)
|
103
|
+
klass.new(klass.new(column_name.to_sym).get(locale.to_s)).get_text(attr)
|
104
104
|
end
|
105
105
|
|
106
106
|
class JSONOp < ::Sequel::Postgres::JSONOp; end
|
@@ -114,15 +114,33 @@ Defines:
|
|
114
114
|
defaults[key] = [backend, backend_options] if backend
|
115
115
|
end
|
116
116
|
|
117
|
+
class MobilityBackends < Hash
|
118
|
+
def initialize(model)
|
119
|
+
@model = model
|
120
|
+
super()
|
121
|
+
end
|
122
|
+
|
123
|
+
def [](name)
|
124
|
+
return fetch(name) if has_key?(name)
|
125
|
+
return self[name.to_sym] if String === name
|
126
|
+
self[name] = @model.class.mobility_backend_class(name).new(@model, name.to_s)
|
127
|
+
end
|
128
|
+
|
129
|
+
def marshal_dump
|
130
|
+
@model
|
131
|
+
end
|
132
|
+
|
133
|
+
def marshal_load(model)
|
134
|
+
@model = model
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
117
138
|
module InstanceMethods
|
118
139
|
# Return a new backend for an attribute name.
|
119
140
|
# @return [Hash] Hash of attribute names and backend instances
|
120
141
|
# @api private
|
121
142
|
def mobility_backends
|
122
|
-
@mobility_backends ||=
|
123
|
-
next hash[name.to_sym] if String === name
|
124
|
-
hash[name] = self.class.mobility_backend_class(name).new(self, name.to_s)
|
125
|
-
end
|
143
|
+
@mobility_backends ||= MobilityBackends.new(self)
|
126
144
|
end
|
127
145
|
|
128
146
|
def initialize_dup(other)
|
@@ -117,8 +117,21 @@ the current locale was +nil+.
|
|
117
117
|
# Applies fallbacks plugin to attributes. Completely disables fallbacks
|
118
118
|
# on model if option is +false+.
|
119
119
|
included_hook do |_, backend_class|
|
120
|
-
|
121
|
-
|
120
|
+
unless options[:fallbacks] == false
|
121
|
+
backend_class.include(BackendInstanceMethods)
|
122
|
+
|
123
|
+
fallbacks =
|
124
|
+
if options[:fallbacks].is_a?(Hash)
|
125
|
+
generate_fallbacks(options[:fallbacks])
|
126
|
+
elsif options[:fallbacks] == true
|
127
|
+
generate_fallbacks({})
|
128
|
+
else
|
129
|
+
::Hash.new { [] }
|
130
|
+
end
|
131
|
+
|
132
|
+
backend_class.singleton_class.attr_reader :fallbacks
|
133
|
+
backend_class.instance_variable_set(:@fallbacks, fallbacks)
|
134
|
+
end
|
122
135
|
end
|
123
136
|
|
124
137
|
private
|
@@ -134,36 +147,17 @@ the current locale was +nil+.
|
|
134
147
|
end
|
135
148
|
end
|
136
149
|
|
137
|
-
|
138
|
-
def
|
139
|
-
|
140
|
-
define_read(convert_option_to_fallbacks(fallbacks_option))
|
141
|
-
end
|
142
|
-
|
143
|
-
private
|
150
|
+
module BackendInstanceMethods
|
151
|
+
def read(locale, fallback: true, **kwargs)
|
152
|
+
return super(locale, **kwargs) if !fallback || kwargs[:locale]
|
144
153
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
locales = fallback == true ? fallbacks[locale] : [locale, *fallback]
|
150
|
-
locales.each do |fallback_locale|
|
151
|
-
value = super(fallback_locale, **options)
|
152
|
-
return value if Util.present?(value)
|
153
|
-
end
|
154
|
-
|
155
|
-
super(locale, **options)
|
154
|
+
locales = fallback == true ? self.class.fallbacks[locale] : [locale, *fallback]
|
155
|
+
locales.each do |fallback_locale|
|
156
|
+
value = super(fallback_locale, **kwargs)
|
157
|
+
return value if Util.present?(value)
|
156
158
|
end
|
157
|
-
end
|
158
159
|
|
159
|
-
|
160
|
-
if option.is_a?(::Hash)
|
161
|
-
@fallbacks_generator[option]
|
162
|
-
elsif option == true
|
163
|
-
@fallbacks_generator[{}]
|
164
|
-
else
|
165
|
-
::Hash.new { [] }
|
166
|
-
end
|
160
|
+
super(locale, **kwargs)
|
167
161
|
end
|
168
162
|
end
|
169
163
|
end
|
data/lib/mobility/version.rb
CHANGED
@@ -46,7 +46,9 @@ module Mobility
|
|
46
46
|
connection.data_source_exists?(table_name)
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
def connection
|
50
|
+
::ActiveRecord::Base.connection
|
51
|
+
end
|
50
52
|
|
51
53
|
def truncate_index_name(index_name)
|
52
54
|
if index_name.size < connection.index_name_length
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
��
|
2
|
-
|
1
|
+
$�����ј���I!4-��fX���y;P��X���w8�}� ^�R�bV�eWɁ���>�E�?�ҖЖU~G^�q0�N��$M��깖+����.Sh�i�\06ʩ2NG�����1�۲���*70����<
|
2
|
+
�w����*�4��)c`a[�s߸HVj�
|
3
|
+
E����O�A�xܿ���@9rW�I�o��:.;ɛ����K]yu\ ��8�����[�:�y�^$���m:�H���b ��"k8�)і¤�@f
|
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.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
eBMcZq0d1tbtv1M1UXND9mOfhLZ31YvoSTPkrJiRpljUNgD0+ugelnr1/5X/9k8y
|
35
35
|
J9QOd3C5jpSShf/HMvpJnFuSYFm19cH9GrHjvw==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2021-
|
37
|
+
date: 2021-12-04 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
|