active_interaction 0.10.0 → 0.10.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 +10 -4
- data/README.md +1 -1
- data/lib/active_interaction/filters/abstract_date_time_filter.rb +5 -1
- data/lib/active_interaction/filters/time_filter.rb +5 -5
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/base_spec.rb +7 -17
- data/spec/active_interaction/integration/array_interaction_spec.rb +0 -4
- data/spec/active_interaction/integration/hash_interaction_spec.rb +0 -4
- data/spec/active_interaction/integration/time_interaction_spec.rb +24 -13
- data/spec/support/interactions.rb +1 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1127329ea0197658f720d8fe6c1ae7d993f5f9dc
|
4
|
+
data.tar.gz: 4b58e248170a453276474a749b109782e12501c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b461f9b41d8dd0447c34b9c724b249ad62c29d4fe34c98f1a2e6965f99db9828a68b501d78b459d8dd1e24ccbf5ee03d3678d57b0a1182e7fdc0db3683f40bcb
|
7
|
+
data.tar.gz: 745be14ea173b524346a1e38f9f89631b0e828db3c47ea3e543b4864c4df8929ea7fd2fb5cb5a44cc829d1bf1c4b0339b43faa657b65443a3ae5b954cc6e0b50
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# [Master][]
|
2
2
|
|
3
|
+
# [0.10.1][] (2013-12-20)
|
4
|
+
|
5
|
+
- Fix bug that prevented parsing strings as times when ActiveSupport was
|
6
|
+
available.
|
7
|
+
|
3
8
|
# [0.10.0][] (2013-12-19)
|
4
9
|
|
5
10
|
- Support casting "true" and "false" as booleans.
|
@@ -97,10 +102,11 @@
|
|
97
102
|
|
98
103
|
- Initial release.
|
99
104
|
|
100
|
-
[master]: https://github.com/orgsync/active_interaction/compare/v0.10.
|
101
|
-
[0.10.
|
102
|
-
[0.
|
103
|
-
[0.9.
|
105
|
+
[master]: https://github.com/orgsync/active_interaction/compare/v0.10.1...master
|
106
|
+
[0.10.1]: https://github.com/orgsync/active_interaction/compare/v0.10.0...v0.10.1
|
107
|
+
[0.10.0]: https://github.com/orgsync/active_interaction/compare/v0.9.1...v0.10.0
|
108
|
+
[0.9.1]: https://github.com/orgsync/active_interaction/compare/v0.9.0...v0.9.1
|
109
|
+
[0.9.0]: https://github.com/orgsync/active_interaction/compare/v0.8.0...v0.9.0
|
104
110
|
[0.8.0]: https://github.com/orgsync/active_interaction/compare/v0.7.0...v0.8.0
|
105
111
|
[0.7.0]: https://github.com/orgsync/active_interaction/compare/v0.6.1...v0.7.0
|
106
112
|
[0.6.1]: https://github.com/orgsync/active_interaction/compare/v0.6.0...v0.6.1
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ module ActiveInteraction
|
|
5
5
|
class AbstractDateTimeFilter < Filter
|
6
6
|
def cast(value)
|
7
7
|
case value
|
8
|
-
when
|
8
|
+
when value_class
|
9
9
|
value
|
10
10
|
when String
|
11
11
|
begin
|
@@ -35,5 +35,9 @@ module ActiveInteraction
|
|
35
35
|
def klass
|
36
36
|
fail NotImplementedError
|
37
37
|
end
|
38
|
+
|
39
|
+
def value_class
|
40
|
+
klass
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
@@ -27,7 +27,7 @@ module ActiveInteraction
|
|
27
27
|
def cast(value)
|
28
28
|
case value
|
29
29
|
when Numeric
|
30
|
-
|
30
|
+
klass.at(value)
|
31
31
|
else
|
32
32
|
super
|
33
33
|
end
|
@@ -36,15 +36,15 @@ module ActiveInteraction
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def klass
|
39
|
-
time.at(0).class
|
40
|
-
end
|
41
|
-
|
42
|
-
def time
|
43
39
|
if Time.respond_to?(:zone) && !Time.zone.nil?
|
44
40
|
Time.zone
|
45
41
|
else
|
46
42
|
Time
|
47
43
|
end
|
48
44
|
end
|
45
|
+
|
46
|
+
def value_class
|
47
|
+
klass.at(0).class
|
48
|
+
end
|
49
49
|
end
|
50
50
|
end
|
@@ -4,13 +4,9 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
InteractionWithFilter = Class.new(TestInteraction) do
|
6
6
|
float :thing
|
7
|
-
|
8
|
-
def execute
|
9
|
-
thing
|
10
|
-
end
|
11
7
|
end
|
12
8
|
|
13
|
-
AddInteraction = Class.new(
|
9
|
+
AddInteraction = Class.new(TestInteraction) do
|
14
10
|
float :x, :y
|
15
11
|
|
16
12
|
def execute
|
@@ -18,7 +14,7 @@ AddInteraction = Class.new(ActiveInteraction::Base) do
|
|
18
14
|
end
|
19
15
|
end
|
20
16
|
|
21
|
-
InterruptInteraction = Class.new(
|
17
|
+
InterruptInteraction = Class.new(TestInteraction) do
|
22
18
|
model :x, :y,
|
23
19
|
class: Object,
|
24
20
|
default: nil
|
@@ -64,10 +60,6 @@ describe ActiveInteraction::Base do
|
|
64
60
|
attr_reader :thing
|
65
61
|
|
66
62
|
validates :thing, presence: true
|
67
|
-
|
68
|
-
def execute
|
69
|
-
thing
|
70
|
-
end
|
71
63
|
end
|
72
64
|
end
|
73
65
|
let(:thing) { SecureRandom.hex }
|
@@ -129,7 +121,7 @@ describe ActiveInteraction::Base do
|
|
129
121
|
describe '.method_missing(filter_type, *args, &block)' do
|
130
122
|
it 'raises an error for an invalid filter type' do
|
131
123
|
expect do
|
132
|
-
Class.new(
|
124
|
+
Class.new(TestInteraction) do
|
133
125
|
not_a_valid_filter_type :thing
|
134
126
|
end
|
135
127
|
end.to raise_error NoMethodError
|
@@ -137,7 +129,7 @@ describe ActiveInteraction::Base do
|
|
137
129
|
|
138
130
|
it do
|
139
131
|
expect do
|
140
|
-
Class.new(
|
132
|
+
Class.new(TestInteraction) do
|
141
133
|
float :_interaction_thing
|
142
134
|
end
|
143
135
|
end.to raise_error ActiveInteraction::InvalidFilterError
|
@@ -157,10 +149,8 @@ describe ActiveInteraction::Base do
|
|
157
149
|
|
158
150
|
context 'with multiple filters' do
|
159
151
|
let(:described_class) do
|
160
|
-
Class.new(
|
152
|
+
Class.new(TestInteraction) do
|
161
153
|
float :thing1, :thing2
|
162
|
-
|
163
|
-
def execute; end
|
164
154
|
end
|
165
155
|
end
|
166
156
|
|
@@ -253,7 +243,7 @@ describe ActiveInteraction::Base do
|
|
253
243
|
end
|
254
244
|
|
255
245
|
it 'sets the result' do
|
256
|
-
expect(result).to eq thing
|
246
|
+
expect(result[:thing]).to eq thing
|
257
247
|
end
|
258
248
|
|
259
249
|
it 'calls transaction' do
|
@@ -280,7 +270,7 @@ describe ActiveInteraction::Base do
|
|
280
270
|
before { inputs.merge!(thing: thing) }
|
281
271
|
|
282
272
|
it 'returns the result' do
|
283
|
-
expect(result).to eq thing
|
273
|
+
expect(result[:thing]).to eq thing
|
284
274
|
end
|
285
275
|
end
|
286
276
|
end
|
@@ -4,30 +4,28 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
TimeZone = Class.new do
|
6
6
|
def self.at(*args)
|
7
|
-
TimeWithZone.at(*args)
|
7
|
+
TimeWithZone.new(Time.at(*args))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.parse(*args)
|
11
|
+
TimeWithZone.new(Time.parse(*args))
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
TimeWithZone = Class.new do
|
12
|
-
|
13
|
-
new(Time.at(*args))
|
14
|
-
end
|
16
|
+
attr_reader :time
|
15
17
|
|
16
18
|
def initialize(time)
|
17
19
|
@time = time
|
18
20
|
end
|
19
21
|
|
20
22
|
def ==(other)
|
21
|
-
|
23
|
+
time == other.time
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
27
|
TimeInteraction = Class.new(TestInteraction) do
|
26
28
|
time :a
|
27
|
-
|
28
|
-
def execute
|
29
|
-
a
|
30
|
-
end
|
31
29
|
end
|
32
30
|
|
33
31
|
describe TimeInteraction do
|
@@ -35,15 +33,28 @@ describe TimeInteraction do
|
|
35
33
|
it_behaves_like 'an interaction', :time, -> { Time.now }
|
36
34
|
|
37
35
|
context 'with a time zone' do
|
38
|
-
let(:a) {
|
36
|
+
let(:a) { nil }
|
39
37
|
|
40
38
|
before do
|
41
|
-
allow(Time).to receive(:zone).and_return(TimeZone)
|
42
39
|
inputs.merge!(a: a)
|
40
|
+
|
41
|
+
allow(Time).to receive(:zone).and_return(TimeZone)
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with an integer' do
|
45
|
+
let(:a) { rand(1 << 16) }
|
46
|
+
|
47
|
+
it 'returns the correct value' do
|
48
|
+
expect(result[:a]).to eq TimeZone.at(a)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
|
-
|
46
|
-
|
52
|
+
context 'with a string' do
|
53
|
+
let(:a) { '2011-12-13T14:15:16Z' }
|
54
|
+
|
55
|
+
it 'returns the correct value' do
|
56
|
+
expect(result[:a]).to eq TimeZone.parse(a)
|
57
|
+
end
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
@@ -6,6 +6,7 @@ TestInteraction = Class.new(ActiveInteraction::Base) do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute
|
9
|
+
inputs
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -25,16 +26,6 @@ shared_examples_for 'an interaction' do |type, generator, filter_options = {}|
|
|
25
26
|
send(type, :default, filter_options.merge(default: generator.call))
|
26
27
|
send(type, :defaults_1, :defaults_2,
|
27
28
|
filter_options.merge(default: generator.call))
|
28
|
-
|
29
|
-
def execute
|
30
|
-
{
|
31
|
-
required: required,
|
32
|
-
optional: optional,
|
33
|
-
default: default,
|
34
|
-
defaults_1: defaults_1,
|
35
|
-
defaults_2: defaults_2
|
36
|
-
}
|
37
|
-
end
|
38
29
|
end
|
39
30
|
end
|
40
31
|
|
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: 0.10.
|
4
|
+
version: 0.10.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: 2013-12-
|
12
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|