active_interaction 4.0.0 → 4.0.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
- data/CHANGELOG.md +7 -0
- data/lib/active_interaction/filters/time_filter.rb +9 -1
- data/lib/active_interaction/inputs.rb +8 -2
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/concerns/hashable_spec.rb +1 -1
- data/spec/active_interaction/integration/time_interaction_spec.rb +4 -4
- metadata +2 -3
- data/lib/active_interaction/modules/input_processor.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65047712d1df9c67700202a27f83054c30fccbdf3d7bf7e0478c01e5bea07fc8
|
4
|
+
data.tar.gz: b39bb6c7d8784cf842eb266e3955fdbc1082c5a4f96c30bdcbdd10074294ea6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca04e342b3b82a29724e113600ca12bebdc303de3c66c51299fc490cd8686e3a062c77498ccd53e33f02a9dc0e05dc5a44ee26be911af6e59bfcca1b2d41d65
|
7
|
+
data.tar.gz: a09744ecbd57a5c69ee845235942c2f2063bfb70f509a9bd6384f45690a35218e6c48c632b2388701f910746614b43b040803329e5310e24ea291267eddd3234
|
data/CHANGELOG.md
CHANGED
@@ -39,9 +39,17 @@ module ActiveInteraction
|
|
39
39
|
Time.respond_to?(:zone) && !Time.zone.nil?
|
40
40
|
end
|
41
41
|
|
42
|
+
def klass
|
43
|
+
if time_with_zone?
|
44
|
+
Time.zone
|
45
|
+
else
|
46
|
+
super
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
def klasses
|
43
51
|
if time_with_zone?
|
44
|
-
|
52
|
+
[Time.zone.at(0).class, Time]
|
45
53
|
else
|
46
54
|
super
|
47
55
|
end
|
@@ -18,8 +18,14 @@ module ActiveInteraction
|
|
18
18
|
def reserved?(name)
|
19
19
|
name.to_s.start_with?('_interaction_') ||
|
20
20
|
name == :syscall ||
|
21
|
-
|
22
|
-
|
21
|
+
(
|
22
|
+
Base.method_defined?(name) &&
|
23
|
+
!Object.method_defined?(name)
|
24
|
+
) ||
|
25
|
+
(
|
26
|
+
Base.private_method_defined?(name) &&
|
27
|
+
!Object.private_method_defined?(name)
|
28
|
+
)
|
23
29
|
end
|
24
30
|
|
25
31
|
def process(inputs)
|
@@ -12,11 +12,11 @@ TimeWithZone = Class.new do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def at(*args)
|
15
|
-
Time.at(*args)
|
15
|
+
TimeWithZone.new(Time.at(*args) + 1)
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse(*args)
|
19
|
-
Time.parse(*args)
|
19
|
+
TimeWithZone.new(Time.parse(*args) + 1)
|
20
20
|
rescue ArgumentError
|
21
21
|
nil
|
22
22
|
end
|
@@ -43,7 +43,7 @@ describe TimeInteraction do
|
|
43
43
|
let(:a) { rand(1 << 16) }
|
44
44
|
|
45
45
|
it 'returns the correct value' do
|
46
|
-
expect(result[:a]).to eq
|
46
|
+
expect(result[:a]).to eq TimeWithZone.new(0).at(a)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -51,7 +51,7 @@ describe TimeInteraction do
|
|
51
51
|
let(:a) { '2011-12-13T14:15:16Z' }
|
52
52
|
|
53
53
|
it 'returns the correct value' do
|
54
|
-
expect(result[:a]).to eq
|
54
|
+
expect(result[:a]).to eq TimeWithZone.new(0).parse(a)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
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: 4.0.
|
4
|
+
version: 4.0.1
|
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: 2021-
|
12
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -247,7 +247,6 @@ files:
|
|
247
247
|
- lib/active_interaction/locale/it.yml
|
248
248
|
- lib/active_interaction/locale/ja.yml
|
249
249
|
- lib/active_interaction/locale/pt-BR.yml
|
250
|
-
- lib/active_interaction/modules/input_processor.rb
|
251
250
|
- lib/active_interaction/modules/validation.rb
|
252
251
|
- lib/active_interaction/version.rb
|
253
252
|
- spec/active_interaction/base_spec.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveInteraction
|
4
|
-
# Groups inputs ending in "(*N*i)" into {GroupedInput}.
|
5
|
-
#
|
6
|
-
# @private
|
7
|
-
module InputProcessor
|
8
|
-
class << self
|
9
|
-
GROUPED_INPUT_PATTERN = /\A(.+)\((\d+)i\)\z/.freeze
|
10
|
-
private_constant :GROUPED_INPUT_PATTERN
|
11
|
-
|
12
|
-
# Checking `syscall` is the result of what appears to be a bug in Ruby.
|
13
|
-
# https://bugs.ruby-lang.org/issues/15597
|
14
|
-
def reserved?(name)
|
15
|
-
name.to_s.start_with?('_interaction_') ||
|
16
|
-
name == :syscall ||
|
17
|
-
(
|
18
|
-
Base.method_defined?(name) &&
|
19
|
-
!Object.method_defined?(name)
|
20
|
-
) ||
|
21
|
-
(
|
22
|
-
Base.private_method_defined?(name) &&
|
23
|
-
!Object.private_method_defined?(name)
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def process(inputs)
|
28
|
-
inputs.stringify_keys.sort.each_with_object({}) do |(k, v), h|
|
29
|
-
next if reserved?(k)
|
30
|
-
|
31
|
-
if (match = GROUPED_INPUT_PATTERN.match(k))
|
32
|
-
assign_to_group!(h, *match.captures, v)
|
33
|
-
else
|
34
|
-
h[k.to_sym] = v
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def assign_to_group!(inputs, key, index, value)
|
42
|
-
key = key.to_sym
|
43
|
-
|
44
|
-
inputs[key] = GroupedInput.new unless inputs[key].is_a?(GroupedInput)
|
45
|
-
inputs[key][index] = value
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|