active_interaction 5.1.0 → 5.2.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 +22 -0
- data/README.md +2 -2
- data/lib/active_interaction/filter.rb +9 -12
- data/lib/active_interaction/filters/array_filter.rb +1 -1
- data/lib/active_interaction/locale/es.yml +23 -0
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/filter_spec.rb +21 -0
- data/spec/active_interaction/filters/array_filter_spec.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b90b2dc28188b224ed0aa986afb739056dbd2407061da2dfee81b825c5674ca9
|
4
|
+
data.tar.gz: 755707a0f9554cee89a08567245f3d78d597a8b7ae7ec671c3eb572f4dd5a881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d24433ef35282b38531e2e18c1e426f69f9cc71692fdb2d96e21f3c420b56a6bb42c3f473b255890b457ab3d1764d6b132ec7f30260437d732ced70b083d217a
|
7
|
+
data.tar.gz: dd2ce32a0c59afa9f5fe1a8134aa82e98404b1e0d5a3a3801b8dd7a726f75f28d16de46c72687c3e5f807db0576936e0a34abe3b26201dd2c58c90c798df10d5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# [5.2.0][] (2022-10-22)
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- Added translation for Spanish. Thanks @matiasasis!
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
- [#545][] - Arrays passed in are no longer modified. Thanks @jonkgrimes!
|
10
|
+
|
11
|
+
## Added
|
12
|
+
|
13
|
+
# [5.1.1][] (2022-09-01)
|
14
|
+
|
15
|
+
## Fixed
|
16
|
+
|
17
|
+
- [#539][] - Fixed a caching error in default values.
|
18
|
+
|
1
19
|
# [5.1.0][] (2022-07-28)
|
2
20
|
|
3
21
|
## Added
|
@@ -1112,6 +1130,8 @@ Example.run
|
|
1112
1130
|
|
1113
1131
|
- Initial release.
|
1114
1132
|
|
1133
|
+
[5.2.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.1...v5.2.0
|
1134
|
+
[5.1.1]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.0...v5.1.1
|
1115
1135
|
[5.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.0.0...v5.1.0
|
1116
1136
|
[5.0.0]: https://github.com/AaronLasseigne/active_interaction/compare/v4.1.0...v5.0.0
|
1117
1137
|
[4.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.6...v4.1.0
|
@@ -1339,3 +1359,5 @@ Example.run
|
|
1339
1359
|
[#503]: https://github.com/AaronLasseigne/active_interaction/issues/503
|
1340
1360
|
[#536]: https://github.com/AaronLasseigne/active_interaction/issues/536
|
1341
1361
|
[#537]: https://github.com/AaronLasseigne/active_interaction/issues/537
|
1362
|
+
[#539]: https://github.com/AaronLasseigne/active_interaction/issues/539
|
1363
|
+
[#545]: https://github.com/AaronLasseigne/active_interaction/issues/545
|
data/README.md
CHANGED
@@ -65,13 +65,13 @@ handles your verbs.
|
|
65
65
|
Add it to your Gemfile:
|
66
66
|
|
67
67
|
``` rb
|
68
|
-
gem 'active_interaction', '~> 5.
|
68
|
+
gem 'active_interaction', '~> 5.2'
|
69
69
|
```
|
70
70
|
|
71
71
|
Or install it manually:
|
72
72
|
|
73
73
|
``` sh
|
74
|
-
$ gem install active_interaction --version '~> 5.
|
74
|
+
$ gem install active_interaction --version '~> 5.2'
|
75
75
|
```
|
76
76
|
|
77
77
|
This project uses [Semantic Versioning][]. Check out [GitHub releases][] for a
|
@@ -112,24 +112,21 @@ module ActiveInteraction
|
|
112
112
|
# @raise [NoDefaultError] If the default is missing.
|
113
113
|
# @raise [InvalidDefaultError] If the default is invalid.
|
114
114
|
def default(context = nil)
|
115
|
-
return @default if defined?(@default)
|
116
|
-
|
117
115
|
raise NoDefaultError, name unless default?
|
118
116
|
|
119
117
|
value = raw_default(context)
|
120
118
|
raise InvalidDefaultError, "#{name}: #{value.inspect}" if value.is_a?(GroupedInput)
|
121
119
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
raise InvalidDefaultError, "#{name}: #{value.inspect}"
|
129
|
-
end
|
130
|
-
|
131
|
-
default.value
|
120
|
+
if value.nil?
|
121
|
+
nil
|
122
|
+
else
|
123
|
+
default = process(value, context)
|
124
|
+
if default.errors.any? && default.errors.first.is_a?(Filter::Error)
|
125
|
+
raise InvalidDefaultError, "#{name}: #{value.inspect}"
|
132
126
|
end
|
127
|
+
|
128
|
+
default.value
|
129
|
+
end
|
133
130
|
end
|
134
131
|
|
135
132
|
# Get the description.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
es:
|
2
|
+
active_interaction:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
invalid: es inválido
|
6
|
+
invalid_type: no es un %{type} válido
|
7
|
+
missing: es requerido
|
8
|
+
types:
|
9
|
+
array: array
|
10
|
+
boolean: boolean
|
11
|
+
date: date
|
12
|
+
date_time: date time
|
13
|
+
decimal: decimal
|
14
|
+
file: file
|
15
|
+
float: float
|
16
|
+
hash: hash
|
17
|
+
integer: integer
|
18
|
+
interface: interface
|
19
|
+
object: object
|
20
|
+
record: record
|
21
|
+
string: string
|
22
|
+
symbol: symbol
|
23
|
+
time: time
|
@@ -36,4 +36,25 @@ describe ActiveInteraction::Filter, :filter do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe '#default' do
|
41
|
+
subject(:filter) { ActiveInteraction::IntegerFilter.new(:test, default: default) }
|
42
|
+
|
43
|
+
context 'when it is a value' do
|
44
|
+
let(:default) { 1 }
|
45
|
+
|
46
|
+
it 'returns the default' do
|
47
|
+
expect(filter.default).to be 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when it is a proc' do
|
52
|
+
let(:default) { -> { i + 1 } }
|
53
|
+
|
54
|
+
it 'returns the default' do
|
55
|
+
expect(filter.default(double(i: 0))).to be 1 # rubocop:disable RSpec/VerifiedDoubles
|
56
|
+
expect(filter.default(double(i: 1))).to be 2 # rubocop:disable RSpec/VerifiedDoubles
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
39
60
|
end
|
@@ -74,6 +74,11 @@ describe ActiveInteraction::ArrayFilter, :filter do
|
|
74
74
|
it 'returns the transformed value' do
|
75
75
|
expect(result.value).to eql [:test]
|
76
76
|
end
|
77
|
+
|
78
|
+
it 'does not modify the original value' do
|
79
|
+
expect(result.value.object_id).to_not eql value.object_id
|
80
|
+
expect(value).to eql ['test']
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
context 'with a nested filter' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -242,6 +242,7 @@ files:
|
|
242
242
|
- lib/active_interaction/input.rb
|
243
243
|
- lib/active_interaction/inputs.rb
|
244
244
|
- lib/active_interaction/locale/en.yml
|
245
|
+
- lib/active_interaction/locale/es.yml
|
245
246
|
- lib/active_interaction/locale/fr.yml
|
246
247
|
- lib/active_interaction/locale/it.yml
|
247
248
|
- lib/active_interaction/locale/ja.yml
|