mobility 0.5.0 → 0.5.1
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 +2 -3
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -4
- data/Gemfile.lock +20 -20
- data/README.md +2 -2
- data/lib/mobility/backends/active_record/key_value.rb +6 -8
- data/lib/mobility/backends/active_record/key_value/query_methods.rb +1 -1
- data/lib/mobility/backends/active_record/pg_query_methods.rb +5 -2
- data/lib/mobility/backends/active_record/table/query_methods.rb +1 -1
- data/lib/mobility/backends/sequel/key_value.rb +13 -17
- data/lib/mobility/backends/sequel/pg_query_methods.rb +2 -2
- data/lib/mobility/plugins/active_record/dirty.rb +18 -0
- data/lib/mobility/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0b92c27c73b5d4052c752d8d63a5b6790696f89
|
|
4
|
+
data.tar.gz: b58166a5c8ef6acdb721b5d4976be04834b65031
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 497358cffc62727e4197b38cca78eb7b7fec7b591921fc814ee84c915be6925f3082d7820f07541212ad42704e6dd55a89503b59ce56b14c56aaa8823108b7d8
|
|
7
|
+
data.tar.gz: 82b9f2c2de83f49ba2b2bc2f716d3aacc61631cb430e29977c6d7281b87f85b871b73aa6b71f5dce9b2e54f15f4bbf0659c48c3ec462753f5012aa602eb9d9c6
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
iEI����[=��0
|
|
1
|
+
$��y�;i�����I�mLJ�(������xeܧ��U��R�ˀ�"<�ժb]a����N�B��s�.p���:^6��n�f���?^��=��z�҇q��';��.�����A�_P0F%�b�-U�b��V��fqW*#&��#�M:W �-���'��I%����
|
|
2
|
+
���o�A��v��uh���gH�����ȠtSڽ�Y�<P-ba�,�X�S�B�� G�4�v�E$�ź�B��,J
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## 0.4
|
|
4
4
|
|
|
5
|
+
### 0.5.1 (March 21, 2018)
|
|
6
|
+
* Fix issues with Dirty plugin in ActiveRecord 5.2.0.rc2
|
|
7
|
+
([#166](https://github.com/shioyama/mobility/pull/166))
|
|
8
|
+
|
|
5
9
|
### 0.5.0 (March 16, 2018)
|
|
6
10
|
* Support PostgreSQL json column format as Json backend and dynamically in
|
|
7
11
|
Container backend ([#182](https://github.com/shioyama/mobility/pull/182) and
|
data/Gemfile
CHANGED
|
@@ -12,10 +12,8 @@ group :development, :test do
|
|
|
12
12
|
elsif ENV['RAILS_VERSION'] == '5.1'
|
|
13
13
|
gem 'activerecord', '>= 5.1', '< 5.2'
|
|
14
14
|
else
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
gem 'activerecord', '5.2.0.beta2'
|
|
18
|
-
gem 'railties', '5.2.0.beta2'
|
|
15
|
+
gem 'activerecord', '>= 5.2.0.rc2', '< 5.3'
|
|
16
|
+
gem 'railties', '>= 5.2.0.rc2', '< 5.3'
|
|
19
17
|
end
|
|
20
18
|
gem "generator_spec", '~> 0.9.4'
|
|
21
19
|
elsif ENV['ORM'] == 'sequel'
|
data/Gemfile.lock
CHANGED
|
@@ -8,28 +8,28 @@ PATH
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionpack (5.2.0.
|
|
12
|
-
actionview (= 5.2.0.
|
|
13
|
-
activesupport (= 5.2.0.
|
|
11
|
+
actionpack (5.2.0.rc2)
|
|
12
|
+
actionview (= 5.2.0.rc2)
|
|
13
|
+
activesupport (= 5.2.0.rc2)
|
|
14
14
|
rack (~> 2.0)
|
|
15
15
|
rack-test (>= 0.6.3)
|
|
16
16
|
rails-dom-testing (~> 2.0)
|
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
18
|
-
actionview (5.2.0.
|
|
19
|
-
activesupport (= 5.2.0.
|
|
18
|
+
actionview (5.2.0.rc2)
|
|
19
|
+
activesupport (= 5.2.0.rc2)
|
|
20
20
|
builder (~> 3.1)
|
|
21
21
|
erubi (~> 1.4)
|
|
22
22
|
rails-dom-testing (~> 2.0)
|
|
23
23
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
24
|
-
activemodel (5.2.0.
|
|
25
|
-
activesupport (= 5.2.0.
|
|
26
|
-
activerecord (5.2.0.
|
|
27
|
-
activemodel (= 5.2.0.
|
|
28
|
-
activesupport (= 5.2.0.
|
|
24
|
+
activemodel (5.2.0.rc2)
|
|
25
|
+
activesupport (= 5.2.0.rc2)
|
|
26
|
+
activerecord (5.2.0.rc2)
|
|
27
|
+
activemodel (= 5.2.0.rc2)
|
|
28
|
+
activesupport (= 5.2.0.rc2)
|
|
29
29
|
arel (>= 9.0)
|
|
30
|
-
activesupport (5.2.0.
|
|
30
|
+
activesupport (5.2.0.rc2)
|
|
31
31
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
32
|
-
i18n (
|
|
32
|
+
i18n (>= 0.7, < 2)
|
|
33
33
|
minitest (~> 5.1)
|
|
34
34
|
tzinfo (~> 1.1)
|
|
35
35
|
arel (9.0.0)
|
|
@@ -61,13 +61,13 @@ GEM
|
|
|
61
61
|
guard (~> 2.1)
|
|
62
62
|
guard-compat (~> 1.1)
|
|
63
63
|
rspec (>= 2.99.0, < 4.0)
|
|
64
|
-
i18n (0.
|
|
64
|
+
i18n (1.0.0)
|
|
65
65
|
concurrent-ruby (~> 1.0)
|
|
66
66
|
listen (3.1.5)
|
|
67
67
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
68
68
|
rb-inotify (~> 0.9, >= 0.9.7)
|
|
69
69
|
ruby_dep (~> 1.2)
|
|
70
|
-
loofah (2.2.
|
|
70
|
+
loofah (2.2.1)
|
|
71
71
|
crass (~> 1.0.2)
|
|
72
72
|
nokogiri (>= 1.5.9)
|
|
73
73
|
lumberjack (1.0.12)
|
|
@@ -96,9 +96,9 @@ GEM
|
|
|
96
96
|
nokogiri (>= 1.6)
|
|
97
97
|
rails-html-sanitizer (1.0.3)
|
|
98
98
|
loofah (~> 2.0)
|
|
99
|
-
railties (5.2.0.
|
|
100
|
-
actionpack (= 5.2.0.
|
|
101
|
-
activesupport (= 5.2.0.
|
|
99
|
+
railties (5.2.0.rc2)
|
|
100
|
+
actionpack (= 5.2.0.rc2)
|
|
101
|
+
activesupport (= 5.2.0.rc2)
|
|
102
102
|
method_source
|
|
103
103
|
rake (>= 0.8.7)
|
|
104
104
|
thor (>= 0.18.1, < 2.0)
|
|
@@ -106,7 +106,7 @@ GEM
|
|
|
106
106
|
rb-fsevent (0.10.3)
|
|
107
107
|
rb-inotify (0.9.10)
|
|
108
108
|
ffi (>= 0.5.0, < 2)
|
|
109
|
-
request_store (1.4.
|
|
109
|
+
request_store (1.4.1)
|
|
110
110
|
rack (>= 1.4)
|
|
111
111
|
rspec (3.7.0)
|
|
112
112
|
rspec-core (~> 3.7.0)
|
|
@@ -134,7 +134,7 @@ PLATFORMS
|
|
|
134
134
|
ruby
|
|
135
135
|
|
|
136
136
|
DEPENDENCIES
|
|
137
|
-
activerecord (
|
|
137
|
+
activerecord (>= 5.2.0.rc2, < 5.3)
|
|
138
138
|
benchmark-ips
|
|
139
139
|
bundler (~> 1.12)
|
|
140
140
|
database_cleaner (~> 1.5, >= 1.5.3)
|
|
@@ -144,7 +144,7 @@ DEPENDENCIES
|
|
|
144
144
|
mysql2 (~> 0.4.9)
|
|
145
145
|
pg (< 1.0)
|
|
146
146
|
pry-byebug
|
|
147
|
-
railties (
|
|
147
|
+
railties (>= 5.2.0.rc2, < 5.3)
|
|
148
148
|
rake (~> 12, >= 12.2.1)
|
|
149
149
|
rspec (~> 3.0)
|
|
150
150
|
sqlite3
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@ different languages. For examples of what Mobility can do, see the
|
|
|
22
22
|
<a href="#companies-using-mobility">Companies using Mobility</a> section below.
|
|
23
23
|
|
|
24
24
|
Storage of translations is handled by customizable "backends" which encapsulate
|
|
25
|
-
different storage strategies. The default
|
|
25
|
+
different storage strategies. The default way to store translations
|
|
26
26
|
is to put them all in a set of two shared tables, but many alternatives are
|
|
27
27
|
also supported, including [translatable
|
|
28
28
|
columns](http://dejimata.com/2017/3/3/translating-with-mobility#strategy-1) and
|
|
@@ -54,7 +54,7 @@ Installation
|
|
|
54
54
|
Add this line to your application's Gemfile:
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
57
|
-
gem 'mobility', '~> 0.5.
|
|
57
|
+
gem 'mobility', '~> 0.5.1'
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Mobility is cryptographically signed. To be sure the gem you install hasn't
|
|
@@ -68,7 +68,6 @@ Implements the {Mobility::Backends::KeyValue} backend for ActiveRecord models.
|
|
|
68
68
|
send(association_name).destroy(translation)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
after_destroy :mobility_destroy_key_value_translations
|
|
72
71
|
|
|
73
72
|
module_name = "MobilityArKeyValue#{association_name.to_s.camelcase}"
|
|
74
73
|
unless const_defined?(module_name)
|
|
@@ -98,13 +97,12 @@ Implements the {Mobility::Backends::KeyValue} backend for ActiveRecord models.
|
|
|
98
97
|
end
|
|
99
98
|
|
|
100
99
|
module DestroyKeyValueTranslations
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
where(translatable: self).destroy_all
|
|
100
|
+
def self.included(model_class)
|
|
101
|
+
model_class.after_destroy do
|
|
102
|
+
[:string, :text].each do |type|
|
|
103
|
+
Mobility::ActiveRecord.const_get("#{type.capitalize}Translation").
|
|
104
|
+
where(translatable: self).destroy_all
|
|
105
|
+
end
|
|
108
106
|
end
|
|
109
107
|
end
|
|
110
108
|
end
|
|
@@ -54,7 +54,7 @@ module Mobility
|
|
|
54
54
|
define_method :where! do |opts, *rest|
|
|
55
55
|
if i18n_keys = q.extract_attributes(opts)
|
|
56
56
|
opts = opts.with_indifferent_access
|
|
57
|
-
i18n_nulls = i18n_keys.reject { |key| opts[key] && Array
|
|
57
|
+
i18n_nulls = i18n_keys.reject { |key| opts[key] && Array(opts[key]).all? }
|
|
58
58
|
i18n_keys.each { |attr| opts["#{attr}_#{association_name}"] = { value: opts.delete(attr) }}
|
|
59
59
|
super(opts, *rest).
|
|
60
60
|
send("join_#{association_name}", *(i18n_keys - i18n_nulls)).
|
|
@@ -7,11 +7,14 @@ Defines query methods for Postgres backends. Including class must define a
|
|
|
7
7
|
single method, +matches+, which accepts a column, value and locale to
|
|
8
8
|
match, and returns an Arel node.
|
|
9
9
|
|
|
10
|
-
This module avoids
|
|
11
|
-
code.
|
|
10
|
+
This module avoids a lot of duplication between hstore/json/jsonb/container
|
|
11
|
+
backend querying code.
|
|
12
12
|
|
|
13
|
+
@see Mobility::Backends::ActiveRecord::Json::QueryMethods
|
|
13
14
|
@see Mobility::Backends::ActiveRecord::Jsonb::QueryMethods
|
|
14
15
|
@see Mobility::Backends::ActiveRecord::Hstore::QueryMethods
|
|
16
|
+
@see Mobility::Backends::ActiveRecord::Container::JsonQueryMethods
|
|
17
|
+
@see Mobility::Backends::ActiveRecord::Container::JsonbQueryMethods
|
|
15
18
|
|
|
16
19
|
=end
|
|
17
20
|
module PgQueryMethods
|
|
@@ -92,7 +92,7 @@ module Mobility
|
|
|
92
92
|
options = {
|
|
93
93
|
# We only need an OUTER JOIN if every value is either nil, or an
|
|
94
94
|
# array with at least one nil value.
|
|
95
|
-
outer_join: opts.values_at(*i18n_keys).compact.all? { |v| !Array
|
|
95
|
+
outer_join: opts.values_at(*i18n_keys).compact.all? { |v| !Array(v).all? }
|
|
96
96
|
}
|
|
97
97
|
i18n_keys.each { |attr| opts["#{translation_class.table_name}.#{attr}"] = opts.delete(attr) }
|
|
98
98
|
super(opts, *rest).send("join_#{association_name}", options)
|
|
@@ -33,7 +33,7 @@ Implements the {Mobility::Backends::KeyValue} backend for Sequel models.
|
|
|
33
33
|
# @option options [Class] class_name Translation model class
|
|
34
34
|
def initialize(model, attribute, options = {})
|
|
35
35
|
super
|
|
36
|
-
@class_name
|
|
36
|
+
@class_name = options[:class_name]
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# @!group Backend Configuration
|
|
@@ -83,23 +83,8 @@ Implements the {Mobility::Backends::KeyValue} backend for Sequel models.
|
|
|
83
83
|
end
|
|
84
84
|
include callback_methods
|
|
85
85
|
|
|
86
|
+
include DestroyKeyValueTranslations
|
|
86
87
|
include Mobility::Sequel::ColumnChanges.new(*attributes)
|
|
87
|
-
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
# Clean up *all* leftover translations of this model, only once.
|
|
91
|
-
def self.mobility_key_value_callbacks_module
|
|
92
|
-
@mobility_key_value_destroy_callbacks_module ||= Module.new do
|
|
93
|
-
def after_destroy
|
|
94
|
-
super
|
|
95
|
-
[:string, :text].freeze.each do |type|
|
|
96
|
-
Mobility::Sequel.const_get("#{type.capitalize}Translation").
|
|
97
|
-
where(translatable_id: id, translatable_type: self.class.name).destroy
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end unless respond_to?(:mobility_key_value_callbacks_module, true)
|
|
102
|
-
include mobility_key_value_callbacks_module
|
|
103
88
|
end
|
|
104
89
|
|
|
105
90
|
setup_query_methods(QueryMethods)
|
|
@@ -121,6 +106,17 @@ Implements the {Mobility::Backends::KeyValue} backend for Sequel models.
|
|
|
121
106
|
end
|
|
122
107
|
end
|
|
123
108
|
|
|
109
|
+
# Clean up *all* leftover translations of this model, only once.
|
|
110
|
+
module DestroyKeyValueTranslations
|
|
111
|
+
def after_destroy
|
|
112
|
+
super
|
|
113
|
+
[:string, :text].freeze.each do |type|
|
|
114
|
+
Mobility::Sequel.const_get("#{type.capitalize}Translation").
|
|
115
|
+
where(translatable_id: id, translatable_type: self.class.name).destroy
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
124
120
|
class CacheRequired < ::StandardError; end
|
|
125
121
|
|
|
126
122
|
module Cache
|
|
@@ -13,8 +13,8 @@ private methods:
|
|
|
13
13
|
returns an SQL expression which checks that the column has a value in the
|
|
14
14
|
locale
|
|
15
15
|
|
|
16
|
-
(The +matches+
|
|
17
|
-
jsonb
|
|
16
|
+
(The +matches+ and +has_locale+ methods are implemented slightly differently
|
|
17
|
+
for hstore/json/jsonb/container backends.)
|
|
18
18
|
|
|
19
19
|
=end
|
|
20
20
|
module PgQueryMethods
|
|
@@ -122,6 +122,24 @@ AR::Dirty plugin adds support for the following persistence-specific methods
|
|
|
122
122
|
mobility_changed_attributes.include?(attr) ? __send__(attr) : super
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
|
+
|
|
126
|
+
# @note This is necessary due to a performance fix in e12607
|
|
127
|
+
# which skips setting @previously_changed if @attributes is
|
|
128
|
+
# defined. For Mobility models using the Dirty plugin, there will
|
|
129
|
+
# be cases where @attributes has been set, but there are *other*
|
|
130
|
+
# changes on virtual translated attributes which need to also be
|
|
131
|
+
# assigned. In this case, we use the presence of such changed
|
|
132
|
+
# virtual attributes as an alternative trigger to set this variable.
|
|
133
|
+
#
|
|
134
|
+
# See:
|
|
135
|
+
# - https://github.com/rails/rails/commit/e126078a0e013acfe0a397a8dad33b2c9de78732
|
|
136
|
+
# - https://github.com/shioyama/mobility/pull/166
|
|
137
|
+
def changes_applied
|
|
138
|
+
if defined?(@attributes) && mobility_changed_attributes.any?
|
|
139
|
+
@previously_changed = changes
|
|
140
|
+
end
|
|
141
|
+
super
|
|
142
|
+
end
|
|
125
143
|
end
|
|
126
144
|
end
|
|
127
145
|
end
|
data/lib/mobility/version.rb
CHANGED
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: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Salzberg
|
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
|
30
30
|
eGDROPZoL5RXwiOnRbexxa7dcAxMrDfGB/hpiunIPWPsi4n5P7K/6OO/sGVMl9xv
|
|
31
31
|
SZBPXjzrHdyOFLBYXB+PG7s3F/4=
|
|
32
32
|
-----END CERTIFICATE-----
|
|
33
|
-
date: 2018-03-
|
|
33
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
|
34
34
|
dependencies:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
36
|
name: request_store
|
metadata.gz.sig
CHANGED
|
Binary file
|