i18n_alchemy 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/lib/i18n_alchemy/attributes_parsing.rb +12 -5
- data/lib/i18n_alchemy/proxy.rb +10 -3
- data/lib/i18n_alchemy/version.rb +1 -1
- data/test/i18n_alchemy/proxy/attributes_parsing_test.rb +16 -14
- data/test/i18n_alchemy/proxy_test.rb +1 -1
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b448e3b19d00c30389b8fafe839c2840ba90b264022108c8f9e356e9441f2e3
|
4
|
+
data.tar.gz: 170fd843fe6f65d8a411c0362121e52ade33ca549a11ec028fb89026bc4216b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3fa185c470cd2ce647f6c22d6e1f296681a940691181b8dda3f47dfdce93a7aaf7a7c9e0d2d7a62c47c38528bfb3b802d15e0dabed1d9d4c9dd8b081537df18
|
7
|
+
data.tar.gz: 494b9cb4974f6bc8a171c389498e21506be614200a751b097a4a5cf8e2e30d9f14f7b81b4c0931d50596bc3d5ccb750608bc5fb986024a48819c793f0a5f2e0b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v0.4.0 - 2020-03-30
|
2
|
+
|
3
|
+
* Ruby 3.0 support
|
4
|
+
* Rails 6.1 support
|
5
|
+
* `update_attributes` and `update_attributes!` are not available through the localized proxy in Rails 6.1, following their removal from Rails.
|
6
|
+
|
1
7
|
## v0.3.1 - 2020-02-11
|
2
8
|
|
3
9
|
* Ruby 2.6 & 2.7 support (no changes required)
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
## I18nAlchemy
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/i18n_alchemy.
|
4
|
-
[![Build Status](https://api.travis-ci.org/carlosantoniodasilva/i18n_alchemy.
|
5
|
-
[![Code Climate](https://codeclimate.com/github/carlosantoniodasilva/i18n_alchemy.
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/i18n_alchemy.svg)](http://badge.fury.io/rb/i18n_alchemy)
|
4
|
+
[![Build Status](https://api.travis-ci.org/carlosantoniodasilva/i18n_alchemy.svg?branch=master)](http://travis-ci.org/carlosantoniodasilva/i18n_alchemy)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/carlosantoniodasilva/i18n_alchemy.svg)](https://codeclimate.com/github/carlosantoniodasilva/i18n_alchemy)
|
6
6
|
|
7
7
|
I18n date/number parsing/localization
|
8
8
|
|
@@ -1,5 +1,10 @@
|
|
1
1
|
module I18n
|
2
2
|
module Alchemy
|
3
|
+
def self.support_update_attributes?
|
4
|
+
# `update_attributes` and `update_attributes!` were removed in Rails 6.1.
|
5
|
+
ActiveSupport.version < Gem::Version.new("6.1")
|
6
|
+
end
|
7
|
+
|
3
8
|
module AttributesParsing
|
4
9
|
def attributes=(attributes)
|
5
10
|
@target.attributes = parse_attributes(attributes)
|
@@ -9,12 +14,14 @@ module I18n
|
|
9
14
|
@target.assign_attributes(parse_attributes(attributes))
|
10
15
|
end
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
if I18n::Alchemy.support_update_attributes?
|
18
|
+
def update_attributes(attributes)
|
19
|
+
@target.update_attributes(parse_attributes(attributes))
|
20
|
+
end
|
15
21
|
|
16
|
-
|
17
|
-
|
22
|
+
def update_attributes!(attributes)
|
23
|
+
@target.update_attributes!(parse_attributes(attributes))
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def update(attributes)
|
data/lib/i18n_alchemy/proxy.rb
CHANGED
@@ -57,8 +57,15 @@ module I18n
|
|
57
57
|
# Delegate all method calls that are not translated to the target object.
|
58
58
|
# As the proxy does not have any other method, there is no need to
|
59
59
|
# override :respond_to, just delegate it to the target as well.
|
60
|
-
|
61
|
-
|
60
|
+
if ::RUBY_VERSION >= "2.7"
|
61
|
+
def method_missing(*args, **kwargs, &block)
|
62
|
+
@target.send(*args, **kwargs, &block)
|
63
|
+
end
|
64
|
+
ruby2_keywords :method_missing
|
65
|
+
else
|
66
|
+
def method_missing(*args, &block)
|
67
|
+
@target.send(*args, &block)
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
71
|
private
|
@@ -146,7 +153,7 @@ module I18n
|
|
146
153
|
|
147
154
|
def skip_column?(column_name)
|
148
155
|
column_name == @target_class.primary_key ||
|
149
|
-
column_name.
|
156
|
+
column_name.end_with?("_id") ||
|
150
157
|
@localized_attributes.key?(column_name)
|
151
158
|
end
|
152
159
|
end
|
data/lib/i18n_alchemy/version.rb
CHANGED
@@ -53,14 +53,6 @@ class ProxyAttributesParsingTest < I18n::Alchemy::ProxyTestCase
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def test_update_attributes
|
57
|
-
silence_deprecations {
|
58
|
-
@localized.update_attributes(price: '2,88')
|
59
|
-
}
|
60
|
-
assert_equal '2,88', @localized.price
|
61
|
-
assert_equal 2.88, @product.reload.price
|
62
|
-
end
|
63
|
-
|
64
56
|
def test_update!
|
65
57
|
@localized.update!(price: '2,88')
|
66
58
|
assert_equal '2,88', @localized.price
|
@@ -73,12 +65,22 @@ class ProxyAttributesParsingTest < I18n::Alchemy::ProxyTestCase
|
|
73
65
|
end
|
74
66
|
end
|
75
67
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
68
|
+
if I18n::Alchemy.support_update_attributes?
|
69
|
+
def test_update_attributes
|
70
|
+
silence_deprecations {
|
71
|
+
@localized.update_attributes(price: '2,88')
|
72
|
+
}
|
73
|
+
assert_equal '2,88', @localized.price
|
74
|
+
assert_equal 2.88, @product.reload.price
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_update_attributes!
|
78
|
+
silence_deprecations {
|
79
|
+
@localized.update_attributes!(price: '2,88')
|
80
|
+
}
|
81
|
+
assert_equal '2,88', @localized.price
|
82
|
+
assert_equal 2.88, @product.reload.price
|
83
|
+
end
|
82
84
|
end
|
83
85
|
|
84
86
|
def test_update_attribute
|
@@ -3,7 +3,7 @@ require "test_helper"
|
|
3
3
|
class ProxyTest < I18n::Alchemy::ProxyTestCase
|
4
4
|
def test_delegates_orm_methods_to_target_object
|
5
5
|
assert @product.new_record?
|
6
|
-
assert @localized.save!(
|
6
|
+
assert @localized.save!(validate: false)
|
7
7
|
assert !@product.new_record?
|
8
8
|
end
|
9
9
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_alchemy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Antonio da Silva
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 4.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 4.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: i18n
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
version: 4.0.0
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '7.0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -63,7 +63,7 @@ dependencies:
|
|
63
63
|
version: 4.0.0
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '7.0'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: activerecord
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
version: 4.0.0
|
74
74
|
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '7.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -83,7 +83,7 @@ dependencies:
|
|
83
83
|
version: 4.0.0
|
84
84
|
- - "<"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
86
|
+
version: '7.0'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: minitest
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ files:
|
|
152
152
|
homepage: ''
|
153
153
|
licenses: []
|
154
154
|
metadata: {}
|
155
|
-
post_install_message:
|
155
|
+
post_install_message:
|
156
156
|
rdoc_options: []
|
157
157
|
require_paths:
|
158
158
|
- lib
|
@@ -167,26 +167,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
171
|
-
signing_key:
|
170
|
+
rubygems_version: 3.2.3
|
171
|
+
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: I18n date/number parsing/localization
|
174
174
|
test_files:
|
175
|
+
- test/action_view_test.rb
|
175
176
|
- test/custom_parsers/my_custom_date_parser.rb
|
176
|
-
- test/
|
177
|
-
- test/
|
178
|
-
- test/
|
177
|
+
- test/db/test_schema.rb
|
178
|
+
- test/i18n_alchemy/date_parser_test.rb
|
179
|
+
- test/i18n_alchemy/numeric_parser_test.rb
|
179
180
|
- test/i18n_alchemy/proxy/attributes_parsing_test.rb
|
180
181
|
- test/i18n_alchemy/proxy/methods_test.rb
|
181
|
-
- test/i18n_alchemy/time_parser_test.rb
|
182
|
-
- test/i18n_alchemy/numeric_parser_test.rb
|
183
182
|
- test/i18n_alchemy/proxy_test.rb
|
184
|
-
- test/i18n_alchemy/
|
183
|
+
- test/i18n_alchemy/time_parser_test.rb
|
184
|
+
- test/locale/en.yml
|
185
|
+
- test/locale/jp.yml
|
186
|
+
- test/locale/pt.yml
|
185
187
|
- test/models/account.rb
|
186
|
-
- test/models/supplier.rb
|
187
188
|
- test/models/product.rb
|
189
|
+
- test/models/supplier.rb
|
188
190
|
- test/models/user.rb
|
189
|
-
- test/db/test_schema.rb
|
190
|
-
- test/test_helper.rb
|
191
|
-
- test/action_view_test.rb
|
192
191
|
- test/models_test.rb
|
192
|
+
- test/test_helper.rb
|