mobility 1.3.0.rc1 → 1.3.0.rc3
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 +18 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -30
- data/README.md +3 -7
- data/lib/mobility/backends/active_record/serialized.rb +7 -1
- data/lib/mobility/backends/active_record/table.rb +7 -1
- data/lib/mobility/plugins/active_model/dirty.rb +13 -3
- data/lib/mobility/version.rb +1 -1
- data/lib/mobility.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +23 -23
- 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: fd0b53980f62d9538827053f6e08b8ffd287d44a7a4aa87602c5d85e87bf30fc
|
4
|
+
data.tar.gz: 540af4290175ec08b109a8cc0e783c1a634c66fe87bf97fd014d5c5a0f78b79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25fc7f6a40125020f7425691a3d183a290bfaa3381594d1ad218a924797a0329f76ca39494742f380a3310fbe9d3c879849e366de20bd695219b247c90161d17
|
7
|
+
data.tar.gz: 8b02e9620070979a64e71d2774495a1be0054e92180116e4e40790575d05faff38fb78001ab460581de2524598af3823f312734b67804d2debe1de428737801a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## 1.3
|
4
4
|
|
5
|
+
### 1.3.0.rc3
|
6
|
+
|
7
|
+
- Don't try to load generators if Rails is loaded but AR is not
|
8
|
+
([#627](https://github.com/shioyama/mobility/pull/627)), thanks
|
9
|
+
[flop](https://github.com/flop)!
|
10
|
+
- Allow compound foreign keys
|
11
|
+
([#632](https://github.com/shioyama/mobility/pull/632)), thanks
|
12
|
+
[mival](https://github.com/mival)!
|
13
|
+
- Fix active model `*_previously_changed?` and active record
|
14
|
+
`will_save_change_to_*?` and `saved_change_to_*?` dirty methods to accept
|
15
|
+
kwargs ([#639](https://github.com/shioyama/mobility/pull/639)) thanks
|
16
|
+
[doits](https://github.com/doits)!
|
17
|
+
|
18
|
+
### 1.3.0.rc2
|
19
|
+
|
20
|
+
- Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 7.1)
|
21
|
+
([#617](https://github.com/shioyama/mobility/pull/617))
|
22
|
+
|
5
23
|
### 1.3.0.rc1
|
6
24
|
|
7
25
|
This version includes potentially breaking chnages for jsonb and hstore
|
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 '
|
13
|
+
when '6.1', '7.0', '7.1'
|
14
14
|
gem 'activerecord', "~> #{orm_version}.0"
|
15
15
|
when 'edge'
|
16
16
|
git 'https://github.com/rails/rails.git', branch: 'main' do
|
data/Gemfile.lock
CHANGED
@@ -8,15 +8,15 @@ PATH
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
benchmark-ips (2.
|
11
|
+
benchmark-ips (2.13.0)
|
12
12
|
byebug (11.1.3)
|
13
13
|
coderay (1.1.3)
|
14
|
-
concurrent-ruby (1.2.
|
14
|
+
concurrent-ruby (1.2.3)
|
15
15
|
database_cleaner (1.99.0)
|
16
|
-
diff-lcs (1.5.
|
17
|
-
ffi (1.
|
16
|
+
diff-lcs (1.5.1)
|
17
|
+
ffi (1.16.3)
|
18
18
|
formatador (1.1.0)
|
19
|
-
guard (2.18.
|
19
|
+
guard (2.18.1)
|
20
20
|
formatador (>= 0.2.4)
|
21
21
|
listen (>= 2.7, < 4.0)
|
22
22
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -30,51 +30,50 @@ GEM
|
|
30
30
|
guard (~> 2.1)
|
31
31
|
guard-compat (~> 1.1)
|
32
32
|
rspec (>= 2.99.0, < 4.0)
|
33
|
-
i18n (1.
|
33
|
+
i18n (1.14.4)
|
34
34
|
concurrent-ruby (~> 1.0)
|
35
|
-
listen (3.
|
35
|
+
listen (3.9.0)
|
36
36
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
37
37
|
rb-inotify (~> 0.9, >= 0.9.10)
|
38
|
-
lumberjack (1.2.
|
38
|
+
lumberjack (1.2.10)
|
39
39
|
method_source (1.0.0)
|
40
40
|
nenv (0.3.0)
|
41
41
|
notiffany (0.1.3)
|
42
42
|
nenv (~> 0.1)
|
43
43
|
shellany (~> 0.0)
|
44
|
-
pry (0.
|
44
|
+
pry (0.14.2)
|
45
45
|
coderay (~> 1.1)
|
46
46
|
method_source (~> 1.0)
|
47
|
-
pry-byebug (3.
|
47
|
+
pry-byebug (3.10.1)
|
48
48
|
byebug (~> 11.0)
|
49
|
-
pry (
|
50
|
-
rack (3.0.
|
49
|
+
pry (>= 0.13, < 0.15)
|
50
|
+
rack (3.0.9.1)
|
51
51
|
rake (12.3.3)
|
52
|
-
rb-fsevent (0.11.
|
52
|
+
rb-fsevent (0.11.2)
|
53
53
|
rb-inotify (0.10.1)
|
54
54
|
ffi (~> 1.0)
|
55
|
-
request_store (1.
|
55
|
+
request_store (1.6.0)
|
56
56
|
rack (>= 1.4)
|
57
|
-
rspec (3.
|
58
|
-
rspec-core (~> 3.
|
59
|
-
rspec-expectations (~> 3.
|
60
|
-
rspec-mocks (~> 3.
|
61
|
-
rspec-core (3.
|
62
|
-
rspec-support (~> 3.
|
63
|
-
rspec-expectations (3.
|
57
|
+
rspec (3.13.0)
|
58
|
+
rspec-core (~> 3.13.0)
|
59
|
+
rspec-expectations (~> 3.13.0)
|
60
|
+
rspec-mocks (~> 3.13.0)
|
61
|
+
rspec-core (3.13.0)
|
62
|
+
rspec-support (~> 3.13.0)
|
63
|
+
rspec-expectations (3.13.0)
|
64
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-mocks (3.
|
65
|
+
rspec-support (~> 3.13.0)
|
66
|
+
rspec-mocks (3.13.0)
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-support (3.
|
68
|
+
rspec-support (~> 3.13.0)
|
69
|
+
rspec-support (3.13.1)
|
70
70
|
shellany (0.0.1)
|
71
|
-
|
72
|
-
|
73
|
-
yard (0.9.
|
74
|
-
webrick (~> 1.7.0)
|
71
|
+
sqlite3 (1.4.4)
|
72
|
+
thor (1.3.1)
|
73
|
+
yard (0.9.36)
|
75
74
|
|
76
75
|
PLATFORMS
|
77
|
-
|
76
|
+
x86_64-linux
|
78
77
|
|
79
78
|
DEPENDENCIES
|
80
79
|
benchmark-ips
|
@@ -84,6 +83,7 @@ DEPENDENCIES
|
|
84
83
|
pry-byebug
|
85
84
|
rake (~> 12, >= 12.2.1)
|
86
85
|
rspec (~> 3.0)
|
86
|
+
sqlite3 (~> 1.4.1)
|
87
87
|
yard (~> 0.9.0)
|
88
88
|
|
89
89
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -4,7 +4,6 @@ Mobility
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/mobility.svg)][gem]
|
5
5
|
[![Build Status](https://github.com/shioyama/mobility/workflows/CI/badge.svg)][actions]
|
6
6
|
[![Code Climate](https://api.codeclimate.com/v1/badges/72200f2b00c339ec4537/maintainability.svg)][codeclimate]
|
7
|
-
[![Gitter Chat](https://badges.gitter.im/mobility-ruby/mobility.svg)](https://gitter.im/mobility-ruby/mobility)
|
8
7
|
|
9
8
|
[gem]: https://rubygems.org/gems/mobility
|
10
9
|
[actions]: https://github.com/shioyama/mobility/actions
|
@@ -55,17 +54,13 @@ Installation
|
|
55
54
|
Add this line to your application's Gemfile:
|
56
55
|
|
57
56
|
```ruby
|
58
|
-
gem 'mobility', '~> 1.3.0.
|
57
|
+
gem 'mobility', '~> 1.3.0.rc3'
|
59
58
|
```
|
60
59
|
|
61
60
|
### ActiveRecord (Rails)
|
62
61
|
|
63
62
|
Requirements:
|
64
|
-
- ActiveRecord >=
|
65
|
-
|
66
|
-
(Support for most backends and features is also supported with
|
67
|
-
ActiveRecord/Rails 4.2, but there are some tests still failing. To see exactly
|
68
|
-
what might not work, check pending specs in Rails 4.2 builds.)
|
63
|
+
- ActiveRecord >= 6.1
|
69
64
|
|
70
65
|
To translate attributes on a model, extend `Mobility`, then call `translates`
|
71
66
|
passing in one or more attributes as well as a hash of options (see below).
|
@@ -1027,6 +1022,7 @@ Integrations
|
|
1027
1022
|
* [mobility-actiontext](https://github.com/sedubois/mobility-actiontext): Translate
|
1028
1023
|
Rails [Action Text](https://guides.rubyonrails.org/action_text_overview.html) rich text
|
1029
1024
|
with Mobility.
|
1025
|
+
* [mobility_typed](https://github.com/GeorgeGorbanev/mobility_typed): Add type checking to Rails models accessors.
|
1030
1026
|
|
1031
1027
|
Tutorials
|
1032
1028
|
---------
|
@@ -51,7 +51,13 @@ Implements {Mobility::Backends::Serialized} backend for ActiveRecord models.
|
|
51
51
|
|
52
52
|
setup do |attributes, options|
|
53
53
|
coder = { yaml: YAMLCoder, json: JSONCoder }[options[:format]]
|
54
|
-
attributes.each
|
54
|
+
attributes.each do |attribute|
|
55
|
+
if (::ActiveRecord::VERSION::STRING >= "7.1")
|
56
|
+
serialize (options[:column_affix] % attribute), coder: coder
|
57
|
+
else
|
58
|
+
serialize (options[:column_affix] % attribute), coder
|
59
|
+
end
|
60
|
+
end
|
55
61
|
end
|
56
62
|
|
57
63
|
# @!group Cache Methods
|
@@ -109,7 +109,13 @@ columns to that table.
|
|
109
109
|
options[:association_name] = :translations
|
110
110
|
options[:subclass_name] ||= :Translation
|
111
111
|
end
|
112
|
-
%i[foreign_key association_name subclass_name table_name].each { |key|
|
112
|
+
%i[foreign_key association_name subclass_name table_name].each { |key|
|
113
|
+
if options[key].is_a?(Enumerable)
|
114
|
+
options[key] = options[key].map!(&:to_sym)
|
115
|
+
else
|
116
|
+
options[key] = options[key].to_sym
|
117
|
+
end
|
118
|
+
}
|
113
119
|
end
|
114
120
|
# @!endgroup
|
115
121
|
|
@@ -119,6 +119,14 @@ the ActiveRecord dirty plugin for more information.
|
|
119
119
|
class HandlerMethodsBuilder < Module
|
120
120
|
attr_reader :klass
|
121
121
|
|
122
|
+
PATTERNS_WITH_KWARGS =
|
123
|
+
%w[
|
124
|
+
%s_changed?
|
125
|
+
%s_previously_changed?
|
126
|
+
will_save_change_to_%s?
|
127
|
+
saved_change_to_%s?
|
128
|
+
].freeze
|
129
|
+
|
122
130
|
# @param [Class] klass Dirty class to mimic
|
123
131
|
def initialize(klass)
|
124
132
|
@klass = klass
|
@@ -135,7 +143,7 @@ the ActiveRecord dirty plugin for more information.
|
|
135
143
|
public_patterns.each do |pattern|
|
136
144
|
method_name = pattern % 'attribute'
|
137
145
|
|
138
|
-
kwargs = pattern
|
146
|
+
kwargs = PATTERNS_WITH_KWARGS.include?(pattern) ? ', **kwargs' : ''
|
139
147
|
module_eval <<-EOM, __FILE__, __LINE__ + 1
|
140
148
|
def #{method_name}(attr_name, *rest#{kwargs})
|
141
149
|
if (mutations_from_mobility.attribute_changed?(attr_name) ||
|
@@ -298,8 +306,10 @@ the ActiveRecord dirty plugin for more information.
|
|
298
306
|
(OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
|
299
307
|
end
|
300
308
|
|
301
|
-
def attribute_previously_changed?(attr_name)
|
302
|
-
previous_changes.include?(attr_name)
|
309
|
+
def attribute_previously_changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
|
310
|
+
previous_changes.include?(attr_name) &&
|
311
|
+
(OPTION_NOT_GIVEN == from || attribute_previous_change(attr_name).first == from) &&
|
312
|
+
(OPTION_NOT_GIVEN == to || attribute_previous_change(attr_name).second == to)
|
303
313
|
end
|
304
314
|
|
305
315
|
def attribute_was(attr_name)
|
data/lib/mobility/version.rb
CHANGED
data/lib/mobility.rb
CHANGED
@@ -90,7 +90,7 @@ module Mobility
|
|
90
90
|
CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
|
91
91
|
private_constant :CALL_COMPILABLE_REGEXP
|
92
92
|
|
93
|
-
require "rails/generators/mobility/generators" if defined?(Rails)
|
93
|
+
require "rails/generators/mobility/generators" if defined?(Rails) && defined?(ActiveRecord)
|
94
94
|
|
95
95
|
class << self
|
96
96
|
def extended(model_class)
|
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.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -12,30 +12,30 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
|
14
14
|
czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTI0MDMzMTA4NTQyOFoXDTI1MDMzMTA4NTQyOFowPzEOMAwGA1UEAwwFY2hy
|
16
16
|
aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
/
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBANdI2sGYV1Dg+eFvs/t8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ep6XaQZSRleVqgIEKZwlG0cX8UwG482Xt
|
33
|
+
WJSXNylIIbzRndVjbVdGVhhcyjnswfu1qJpl+0YlbAdHJVsd8Ux8TOXEPFMv5wz9
|
34
|
+
wXhTYFvkOuleWf/45E5f8BtT1iqsH2w3P2Cfy+yOo2aReAVSeR12YDCuV0q6RjTD
|
35
|
+
3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
|
36
|
+
tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2024-03-31 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: request_store
|
metadata.gz.sig
CHANGED
Binary file
|