mobility 0.1.17 → 0.1.18
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
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +24 -24
- data/README.md +1 -4
- data/lib/mobility.rb +1 -1
- data/lib/mobility/active_model.rb +0 -1
- data/lib/mobility/active_record.rb +1 -14
- data/lib/mobility/{active_model → active_record}/attribute_methods.rb +2 -2
- data/lib/mobility/backend/active_record.rb +1 -0
- data/lib/mobility/backend/active_record/dirty.rb +45 -0
- data/lib/mobility/backend/dirty.rb +2 -1
- data/lib/mobility/version.rb +1 -1
- data/lib/mobility/wrapper.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 608d78d453d3a4a8c70d081851ad41b7469ea359
|
|
4
|
+
data.tar.gz: 25a56ec92b1f17a64b0f7ff2305709ac461a0b21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ee3ca1d2c69def85e662c064809c611cd1f93f4ec512ba85fdd011b4349de739175421cd6a1658060691e8ff8122c808056c254c24bfba2c7bfc803fd1fad7e
|
|
7
|
+
data.tar.gz: 4d32541308d245ea15bc1a2867876448e5fc637c30a794127807c5f63789c21f0f221160a54264777866a07416c7e09ff6d1d5df4e223ad3de74459fd54d788b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
mobility (0.1.
|
|
4
|
+
mobility (0.1.17)
|
|
5
5
|
i18n (>= 0.6.10, < 0.9)
|
|
6
6
|
request_store (~> 1.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionpack (5.
|
|
12
|
-
actionview (= 5.
|
|
13
|
-
activesupport (= 5.
|
|
11
|
+
actionpack (5.1.1)
|
|
12
|
+
actionview (= 5.1.1)
|
|
13
|
+
activesupport (= 5.1.1)
|
|
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.
|
|
19
|
-
activesupport (= 5.
|
|
18
|
+
actionview (5.1.1)
|
|
19
|
+
activesupport (= 5.1.1)
|
|
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.
|
|
25
|
-
activesupport (= 5.
|
|
26
|
-
activerecord (5.
|
|
27
|
-
activemodel (= 5.
|
|
28
|
-
activesupport (= 5.
|
|
29
|
-
arel (~>
|
|
30
|
-
activesupport (5.
|
|
24
|
+
activemodel (5.1.1)
|
|
25
|
+
activesupport (= 5.1.1)
|
|
26
|
+
activerecord (5.1.1)
|
|
27
|
+
activemodel (= 5.1.1)
|
|
28
|
+
activesupport (= 5.1.1)
|
|
29
|
+
arel (~> 8.0)
|
|
30
|
+
activesupport (5.1.1)
|
|
31
31
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
32
32
|
i18n (~> 0.7)
|
|
33
33
|
minitest (~> 5.1)
|
|
34
34
|
tzinfo (~> 1.1)
|
|
35
|
-
arel (
|
|
35
|
+
arel (8.0.0)
|
|
36
36
|
builder (3.2.3)
|
|
37
37
|
byebug (9.0.6)
|
|
38
38
|
coderay (1.1.1)
|
|
39
39
|
concurrent-ruby (1.0.5)
|
|
40
40
|
database_cleaner (1.6.1)
|
|
41
41
|
diff-lcs (1.3)
|
|
42
|
-
|
|
42
|
+
erubi (1.6.0)
|
|
43
43
|
ffi (1.9.18)
|
|
44
44
|
formatador (0.2.5)
|
|
45
45
|
generator_spec (0.9.4)
|
|
@@ -59,7 +59,7 @@ GEM
|
|
|
59
59
|
guard (~> 2.1)
|
|
60
60
|
guard-compat (~> 1.1)
|
|
61
61
|
rspec (>= 2.99.0, < 4.0)
|
|
62
|
-
i18n (0.8.
|
|
62
|
+
i18n (0.8.4)
|
|
63
63
|
listen (3.1.5)
|
|
64
64
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
65
65
|
rb-inotify (~> 0.9, >= 0.9.7)
|
|
@@ -77,7 +77,7 @@ GEM
|
|
|
77
77
|
notiffany (0.1.1)
|
|
78
78
|
nenv (~> 0.1)
|
|
79
79
|
shellany (~> 0.0)
|
|
80
|
-
pg (0.
|
|
80
|
+
pg (0.21.0)
|
|
81
81
|
pry (0.10.4)
|
|
82
82
|
coderay (~> 1.1.0)
|
|
83
83
|
method_source (~> 0.8.1)
|
|
@@ -93,16 +93,16 @@ GEM
|
|
|
93
93
|
nokogiri (>= 1.6)
|
|
94
94
|
rails-html-sanitizer (1.0.3)
|
|
95
95
|
loofah (~> 2.0)
|
|
96
|
-
railties (5.
|
|
97
|
-
actionpack (= 5.
|
|
98
|
-
activesupport (= 5.
|
|
96
|
+
railties (5.1.1)
|
|
97
|
+
actionpack (= 5.1.1)
|
|
98
|
+
activesupport (= 5.1.1)
|
|
99
99
|
method_source
|
|
100
100
|
rake (>= 0.8.7)
|
|
101
101
|
thor (>= 0.18.1, < 2.0)
|
|
102
102
|
rake (10.5.0)
|
|
103
103
|
rb-fsevent (0.9.8)
|
|
104
|
-
rb-inotify (0.9.
|
|
105
|
-
ffi (>= 0.5.0)
|
|
104
|
+
rb-inotify (0.9.10)
|
|
105
|
+
ffi (>= 0.5.0, < 2)
|
|
106
106
|
request_store (1.3.2)
|
|
107
107
|
rspec (3.6.0)
|
|
108
108
|
rspec-core (~> 3.6.0)
|
|
@@ -131,7 +131,7 @@ PLATFORMS
|
|
|
131
131
|
ruby
|
|
132
132
|
|
|
133
133
|
DEPENDENCIES
|
|
134
|
-
activerecord (>= 5.
|
|
134
|
+
activerecord (>= 5.1, < 5.2)
|
|
135
135
|
bundler (~> 1.12)
|
|
136
136
|
database_cleaner (~> 1.5, >= 1.5.3)
|
|
137
137
|
generator_spec (~> 0.9.4)
|
data/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Installation
|
|
|
47
47
|
Add this line to your application's Gemfile:
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
|
-
gem 'mobility', '~> 0.1.
|
|
50
|
+
gem 'mobility', '~> 0.1.18'
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
To translate attributes on a model, include (or extend) `Mobility`, then call
|
|
@@ -58,9 +58,6 @@ To translate attributes on a model, include (or extend) `Mobility`, then call
|
|
|
58
58
|
Requirements:
|
|
59
59
|
- ActiveRecord >= 5.0
|
|
60
60
|
|
|
61
|
-
Using Mobility with Rails 5.1 will currently result in some deprecation
|
|
62
|
-
warnings. This will be fixed soon.
|
|
63
|
-
|
|
64
61
|
(Support for some backends is also supported with ActiveRecord/Rails 4.2, see
|
|
65
62
|
the [active_record-4.2
|
|
66
63
|
branch](https://github.com/shioyama/mobility/tree/active_record_4.2).)
|
data/lib/mobility.rb
CHANGED
|
@@ -102,7 +102,7 @@ module Mobility
|
|
|
102
102
|
|
|
103
103
|
if Loaded::ActiveRecord
|
|
104
104
|
model_class.include(ActiveRecord) if model_class < ::ActiveRecord::Base
|
|
105
|
-
model_class.include(
|
|
105
|
+
model_class.include(ActiveRecord::AttributeMethods) if model_class.ancestors.include?(::ActiveRecord::AttributeMethods)
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
if Loaded::Sequel
|
|
@@ -5,6 +5,7 @@ Module loading ActiveRecord-specific classes for Mobility models.
|
|
|
5
5
|
|
|
6
6
|
=end
|
|
7
7
|
module ActiveRecord
|
|
8
|
+
autoload :AttributeMethods, "mobility/active_record/attribute_methods"
|
|
8
9
|
autoload :BackendResetter, "mobility/active_record/backend_resetter"
|
|
9
10
|
autoload :ModelTranslation, "mobility/active_record/model_translation"
|
|
10
11
|
autoload :StringTranslation, "mobility/active_record/string_translation"
|
|
@@ -12,20 +13,6 @@ Module loading ActiveRecord-specific classes for Mobility models.
|
|
|
12
13
|
autoload :Translation, "mobility/active_record/translation"
|
|
13
14
|
autoload :UniquenessValidator, "mobility/active_record/uniqueness_validator"
|
|
14
15
|
|
|
15
|
-
def changes_applied
|
|
16
|
-
@previously_changed = changes
|
|
17
|
-
super
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def clear_changes_information
|
|
21
|
-
@previously_changed = ActiveSupport::HashWithIndifferentAccess.new
|
|
22
|
-
super
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def previous_changes
|
|
26
|
-
super.merge(@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
16
|
def self.included(model_class)
|
|
30
17
|
model_class.extend(ClassMethods)
|
|
31
18
|
model_class.const_set(:UniquenessValidator,
|
|
@@ -2,6 +2,7 @@ module Mobility
|
|
|
2
2
|
module Backend
|
|
3
3
|
module ActiveRecord
|
|
4
4
|
autoload :Column, 'mobility/backend/active_record/column'
|
|
5
|
+
autoload :Dirty, 'mobility/backend/active_record/dirty'
|
|
5
6
|
autoload :Hstore, 'mobility/backend/active_record/hstore'
|
|
6
7
|
autoload :Jsonb, 'mobility/backend/active_record/jsonb'
|
|
7
8
|
autoload :KeyValue, 'mobility/backend/active_record/key_value'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Mobility
|
|
2
|
+
module Backend
|
|
3
|
+
module ActiveRecord::Dirty
|
|
4
|
+
include ActiveModel::Dirty
|
|
5
|
+
|
|
6
|
+
# @param [Class] backend_class Class of backend
|
|
7
|
+
def self.included(backend_class)
|
|
8
|
+
backend_class.extend(ActiveModel::Dirty::ClassMethods)
|
|
9
|
+
backend_class.extend(ClassMethods)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module ClassMethods
|
|
13
|
+
def setup_model(model_class, attributes, **options)
|
|
14
|
+
super
|
|
15
|
+
|
|
16
|
+
method_name_regex = /\A(#{attributes.join('|'.freeze)})_([a-z]{2}(_[a-z]{2})?)(=?|\??)\z/.freeze
|
|
17
|
+
mod = Module.new do
|
|
18
|
+
define_method :has_attribute? do |attr_name|
|
|
19
|
+
super(attr_name) || !!method_name_regex.match(attr_name)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
model_class.class_eval do
|
|
24
|
+
extend mod
|
|
25
|
+
|
|
26
|
+
method_name = ::ActiveRecord::VERSION::STRING < '5.1' ? :changes_applied : :changes_internally_applied
|
|
27
|
+
define_method method_name do
|
|
28
|
+
@previously_changed = changes
|
|
29
|
+
super()
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def clear_changes_information
|
|
33
|
+
@previously_changed = ActiveSupport::HashWithIndifferentAccess.new
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def previous_changes
|
|
38
|
+
(@previously_changed ||= ActiveSupport::HashWithIndifferentAccess.new).merge(super)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -25,7 +25,8 @@ details.
|
|
|
25
25
|
def self.for(model_class)
|
|
26
26
|
model_class ||= Object
|
|
27
27
|
if Loaded::ActiveRecord && model_class.ancestors.include?(::ActiveModel::Dirty)
|
|
28
|
-
|
|
28
|
+
(model_class < ::ActiveRecord::Base) ?
|
|
29
|
+
Backend::ActiveRecord::Dirty : Backend::ActiveModel::Dirty
|
|
29
30
|
elsif Loaded::Sequel && model_class < ::Sequel::Model
|
|
30
31
|
Backend::Sequel::Dirty
|
|
31
32
|
else
|
data/lib/mobility/version.rb
CHANGED
data/lib/mobility/wrapper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mobility
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Salzberg
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-06-
|
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: request_store
|
|
@@ -149,9 +149,9 @@ files:
|
|
|
149
149
|
- lib/generators/rails/mobility/translations_generator.rb
|
|
150
150
|
- lib/mobility.rb
|
|
151
151
|
- lib/mobility/active_model.rb
|
|
152
|
-
- lib/mobility/active_model/attribute_methods.rb
|
|
153
152
|
- lib/mobility/active_model/backend_resetter.rb
|
|
154
153
|
- lib/mobility/active_record.rb
|
|
154
|
+
- lib/mobility/active_record/attribute_methods.rb
|
|
155
155
|
- lib/mobility/active_record/backend_resetter.rb
|
|
156
156
|
- lib/mobility/active_record/model_translation.rb
|
|
157
157
|
- lib/mobility/active_record/string_translation.rb
|
|
@@ -165,6 +165,7 @@ files:
|
|
|
165
165
|
- lib/mobility/backend/active_record.rb
|
|
166
166
|
- lib/mobility/backend/active_record/column.rb
|
|
167
167
|
- lib/mobility/backend/active_record/column/query_methods.rb
|
|
168
|
+
- lib/mobility/backend/active_record/dirty.rb
|
|
168
169
|
- lib/mobility/backend/active_record/hash_valued.rb
|
|
169
170
|
- lib/mobility/backend/active_record/hstore.rb
|
|
170
171
|
- lib/mobility/backend/active_record/hstore/query_methods.rb
|