active_interaction 0.5.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -3
- data/README.md +8 -6
- data/lib/active_interaction.rb +5 -3
- data/lib/active_interaction/active_model.rb +29 -0
- data/lib/active_interaction/base.rb +82 -116
- data/lib/active_interaction/errors.rb +79 -5
- data/lib/active_interaction/filter.rb +195 -21
- data/lib/active_interaction/filters.rb +26 -0
- data/lib/active_interaction/filters/array_filter.rb +22 -25
- data/lib/active_interaction/filters/boolean_filter.rb +12 -12
- data/lib/active_interaction/filters/date_filter.rb +32 -5
- data/lib/active_interaction/filters/date_time_filter.rb +34 -7
- data/lib/active_interaction/filters/file_filter.rb +12 -9
- data/lib/active_interaction/filters/float_filter.rb +13 -11
- data/lib/active_interaction/filters/hash_filter.rb +36 -17
- data/lib/active_interaction/filters/integer_filter.rb +13 -11
- data/lib/active_interaction/filters/model_filter.rb +15 -15
- data/lib/active_interaction/filters/string_filter.rb +19 -8
- data/lib/active_interaction/filters/symbol_filter.rb +29 -0
- data/lib/active_interaction/filters/time_filter.rb +38 -16
- data/lib/active_interaction/method_missing.rb +18 -0
- data/lib/active_interaction/overload_hash.rb +1 -0
- data/lib/active_interaction/validation.rb +19 -0
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/active_model_spec.rb +33 -0
- data/spec/active_interaction/base_spec.rb +54 -48
- data/spec/active_interaction/errors_spec.rb +99 -0
- data/spec/active_interaction/filter_spec.rb +12 -20
- data/spec/active_interaction/filters/array_filter_spec.rb +50 -28
- data/spec/active_interaction/filters/boolean_filter_spec.rb +15 -15
- data/spec/active_interaction/filters/date_filter_spec.rb +30 -18
- data/spec/active_interaction/filters/date_time_filter_spec.rb +31 -19
- data/spec/active_interaction/filters/file_filter_spec.rb +7 -7
- data/spec/active_interaction/filters/float_filter_spec.rb +13 -11
- data/spec/active_interaction/filters/hash_filter_spec.rb +38 -29
- data/spec/active_interaction/filters/integer_filter_spec.rb +18 -8
- data/spec/active_interaction/filters/model_filter_spec.rb +24 -20
- data/spec/active_interaction/filters/string_filter_spec.rb +14 -8
- data/spec/active_interaction/filters/symbol_filter_spec.rb +24 -0
- data/spec/active_interaction/filters/time_filter_spec.rb +33 -69
- data/spec/active_interaction/filters_spec.rb +21 -0
- data/spec/active_interaction/i18n_spec.rb +0 -15
- data/spec/active_interaction/integration/array_interaction_spec.rb +2 -22
- data/spec/active_interaction/integration/hash_interaction_spec.rb +5 -25
- data/spec/active_interaction/integration/symbol_interaction_spec.rb +5 -0
- data/spec/active_interaction/method_missing_spec.rb +69 -0
- data/spec/active_interaction/validation_spec.rb +55 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/filters.rb +168 -14
- data/spec/support/interactions.rb +11 -13
- metadata +31 -13
- data/lib/active_interaction/filter_method.rb +0 -13
- data/lib/active_interaction/filter_methods.rb +0 -26
- data/lib/active_interaction/filters/abstract_date_time_filter.rb +0 -25
- data/spec/active_interaction/filter_method_spec.rb +0 -43
- data/spec/active_interaction/filter_methods_spec.rb +0 -30
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.
|
4
|
+
version: 0.6.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
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 3
|
20
|
+
version: '3'
|
21
|
+
- - <
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '5'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - '>='
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: 3
|
30
|
+
version: '3'
|
31
|
+
- - <
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: bundler
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,12 +151,10 @@ executables: []
|
|
145
151
|
extensions: []
|
146
152
|
extra_rdoc_files: []
|
147
153
|
files:
|
154
|
+
- lib/active_interaction/active_model.rb
|
148
155
|
- lib/active_interaction/base.rb
|
149
156
|
- lib/active_interaction/errors.rb
|
150
157
|
- lib/active_interaction/filter.rb
|
151
|
-
- lib/active_interaction/filter_method.rb
|
152
|
-
- lib/active_interaction/filter_methods.rb
|
153
|
-
- lib/active_interaction/filters/abstract_date_time_filter.rb
|
154
158
|
- lib/active_interaction/filters/array_filter.rb
|
155
159
|
- lib/active_interaction/filters/boolean_filter.rb
|
156
160
|
- lib/active_interaction/filters/date_filter.rb
|
@@ -161,13 +165,17 @@ files:
|
|
161
165
|
- lib/active_interaction/filters/integer_filter.rb
|
162
166
|
- lib/active_interaction/filters/model_filter.rb
|
163
167
|
- lib/active_interaction/filters/string_filter.rb
|
168
|
+
- lib/active_interaction/filters/symbol_filter.rb
|
164
169
|
- lib/active_interaction/filters/time_filter.rb
|
170
|
+
- lib/active_interaction/filters.rb
|
171
|
+
- lib/active_interaction/method_missing.rb
|
165
172
|
- lib/active_interaction/overload_hash.rb
|
173
|
+
- lib/active_interaction/validation.rb
|
166
174
|
- lib/active_interaction/version.rb
|
167
175
|
- lib/active_interaction.rb
|
176
|
+
- spec/active_interaction/active_model_spec.rb
|
168
177
|
- spec/active_interaction/base_spec.rb
|
169
|
-
- spec/active_interaction/
|
170
|
-
- spec/active_interaction/filter_methods_spec.rb
|
178
|
+
- spec/active_interaction/errors_spec.rb
|
171
179
|
- spec/active_interaction/filter_spec.rb
|
172
180
|
- spec/active_interaction/filters/array_filter_spec.rb
|
173
181
|
- spec/active_interaction/filters/boolean_filter_spec.rb
|
@@ -179,7 +187,9 @@ files:
|
|
179
187
|
- spec/active_interaction/filters/integer_filter_spec.rb
|
180
188
|
- spec/active_interaction/filters/model_filter_spec.rb
|
181
189
|
- spec/active_interaction/filters/string_filter_spec.rb
|
190
|
+
- spec/active_interaction/filters/symbol_filter_spec.rb
|
182
191
|
- spec/active_interaction/filters/time_filter_spec.rb
|
192
|
+
- spec/active_interaction/filters_spec.rb
|
183
193
|
- spec/active_interaction/i18n_spec.rb
|
184
194
|
- spec/active_interaction/integration/array_interaction_spec.rb
|
185
195
|
- spec/active_interaction/integration/boolean_interaction_spec.rb
|
@@ -191,15 +201,18 @@ files:
|
|
191
201
|
- spec/active_interaction/integration/integer_interaction_spec.rb
|
192
202
|
- spec/active_interaction/integration/model_interaction_spec.rb
|
193
203
|
- spec/active_interaction/integration/string_interaction_spec.rb
|
204
|
+
- spec/active_interaction/integration/symbol_interaction_spec.rb
|
194
205
|
- spec/active_interaction/integration/time_interaction_spec.rb
|
206
|
+
- spec/active_interaction/method_missing_spec.rb
|
195
207
|
- spec/active_interaction/overload_hash_spec.rb
|
208
|
+
- spec/active_interaction/validation_spec.rb
|
196
209
|
- spec/spec_helper.rb
|
197
210
|
- spec/support/filters.rb
|
198
211
|
- spec/support/interactions.rb
|
199
212
|
- CHANGELOG.md
|
200
213
|
- LICENSE.txt
|
201
214
|
- README.md
|
202
|
-
homepage:
|
215
|
+
homepage: http://orgsync.github.io/active_interaction/
|
203
216
|
licenses:
|
204
217
|
- MIT
|
205
218
|
metadata: {}
|
@@ -219,14 +232,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
232
|
version: '0'
|
220
233
|
requirements: []
|
221
234
|
rubyforge_project:
|
222
|
-
rubygems_version: 2.1.
|
235
|
+
rubygems_version: 2.1.10
|
223
236
|
signing_key:
|
224
237
|
specification_version: 4
|
225
238
|
summary: Manage application specific business logic.
|
226
239
|
test_files:
|
240
|
+
- spec/active_interaction/active_model_spec.rb
|
227
241
|
- spec/active_interaction/base_spec.rb
|
228
|
-
- spec/active_interaction/
|
229
|
-
- spec/active_interaction/filter_methods_spec.rb
|
242
|
+
- spec/active_interaction/errors_spec.rb
|
230
243
|
- spec/active_interaction/filter_spec.rb
|
231
244
|
- spec/active_interaction/filters/array_filter_spec.rb
|
232
245
|
- spec/active_interaction/filters/boolean_filter_spec.rb
|
@@ -238,7 +251,9 @@ test_files:
|
|
238
251
|
- spec/active_interaction/filters/integer_filter_spec.rb
|
239
252
|
- spec/active_interaction/filters/model_filter_spec.rb
|
240
253
|
- spec/active_interaction/filters/string_filter_spec.rb
|
254
|
+
- spec/active_interaction/filters/symbol_filter_spec.rb
|
241
255
|
- spec/active_interaction/filters/time_filter_spec.rb
|
256
|
+
- spec/active_interaction/filters_spec.rb
|
242
257
|
- spec/active_interaction/i18n_spec.rb
|
243
258
|
- spec/active_interaction/integration/array_interaction_spec.rb
|
244
259
|
- spec/active_interaction/integration/boolean_interaction_spec.rb
|
@@ -250,8 +265,11 @@ test_files:
|
|
250
265
|
- spec/active_interaction/integration/integer_interaction_spec.rb
|
251
266
|
- spec/active_interaction/integration/model_interaction_spec.rb
|
252
267
|
- spec/active_interaction/integration/string_interaction_spec.rb
|
268
|
+
- spec/active_interaction/integration/symbol_interaction_spec.rb
|
253
269
|
- spec/active_interaction/integration/time_interaction_spec.rb
|
270
|
+
- spec/active_interaction/method_missing_spec.rb
|
254
271
|
- spec/active_interaction/overload_hash_spec.rb
|
272
|
+
- spec/active_interaction/validation_spec.rb
|
255
273
|
- spec/spec_helper.rb
|
256
274
|
- spec/support/filters.rb
|
257
275
|
- spec/support/interactions.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ActiveInteraction
|
2
|
-
# @private
|
3
|
-
class FilterMethod
|
4
|
-
attr_reader :method_name, :attribute, :options, :block
|
5
|
-
|
6
|
-
def initialize(method_name, *args, &block)
|
7
|
-
@method_name, @block = method_name, block
|
8
|
-
|
9
|
-
@attribute = args.shift if args.first.is_a?(Symbol)
|
10
|
-
@options = (args.first || {}).dup
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module ActiveInteraction
|
2
|
-
# @private
|
3
|
-
class FilterMethods
|
4
|
-
include Enumerable
|
5
|
-
include OverloadHash
|
6
|
-
|
7
|
-
def self.evaluate(&block)
|
8
|
-
me = new
|
9
|
-
me.instance_eval(&block)
|
10
|
-
me
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@filter_methods = []
|
15
|
-
end
|
16
|
-
|
17
|
-
def each(&block)
|
18
|
-
@filter_methods.each(&block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def method_missing(filter_type, *args, &block)
|
22
|
-
@filter_methods.push(FilterMethod.new(filter_type, *args, &block))
|
23
|
-
end
|
24
|
-
private :method_missing
|
25
|
-
end
|
26
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module ActiveInteraction
|
2
|
-
# @private
|
3
|
-
class AbstractDateTimeFilter < Filter
|
4
|
-
def self.prepare(key, value, options = {}, &block)
|
5
|
-
klass = options.delete(:class)
|
6
|
-
|
7
|
-
case value
|
8
|
-
when klass
|
9
|
-
value
|
10
|
-
when String
|
11
|
-
begin
|
12
|
-
if options.has_key?(:format)
|
13
|
-
klass.strptime(value, options[:format])
|
14
|
-
else
|
15
|
-
klass.parse(value)
|
16
|
-
end
|
17
|
-
rescue ArgumentError
|
18
|
-
super
|
19
|
-
end
|
20
|
-
else
|
21
|
-
super
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveInteraction::FilterMethod do
|
4
|
-
describe '.new(method_name, *args, &block)' do
|
5
|
-
let(:method_name) { SecureRandom.hex }
|
6
|
-
let(:attribute) { nil }
|
7
|
-
let(:options) { {} }
|
8
|
-
let(:args) { [] }
|
9
|
-
let(:block) { nil }
|
10
|
-
subject(:filter_method) { described_class.new(method_name, *args, &block) }
|
11
|
-
|
12
|
-
shared_examples 'instance variable assignment' do
|
13
|
-
its(:method_name) { should equal method_name }
|
14
|
-
its(:attribute) { should equal attribute }
|
15
|
-
its(:options) { should eq options }
|
16
|
-
its(:block) { should equal block }
|
17
|
-
end
|
18
|
-
|
19
|
-
include_examples 'instance variable assignment'
|
20
|
-
|
21
|
-
context 'with an attribute' do
|
22
|
-
let(:attribute) { SecureRandom.hex.to_sym }
|
23
|
-
|
24
|
-
before { args << attribute }
|
25
|
-
|
26
|
-
include_examples 'instance variable assignment'
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with options' do
|
30
|
-
let(:options) { { nil => nil } }
|
31
|
-
|
32
|
-
before { args << options }
|
33
|
-
|
34
|
-
include_examples 'instance variable assignment'
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with a block' do
|
38
|
-
let(:block) { Proc.new {} }
|
39
|
-
|
40
|
-
include_examples 'instance variable assignment'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveInteraction::FilterMethods do
|
4
|
-
let(:block) { Proc.new {} }
|
5
|
-
subject(:filter_methods) { described_class.evaluate(&block) }
|
6
|
-
|
7
|
-
describe '.evaluate(&block)' do
|
8
|
-
it "returns an instance of #{described_class}" do
|
9
|
-
expect(filter_methods).to be_a described_class
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'does not add any filter methods' do
|
13
|
-
expect(filter_methods.count).to eq 0
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with a filter method' do
|
17
|
-
let(:block) { Proc.new { boolean } }
|
18
|
-
|
19
|
-
it 'adds a filter method' do
|
20
|
-
expect(filter_methods.count).to eq 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#each' do
|
26
|
-
it 'returns an Enumerator' do
|
27
|
-
expect(filter_methods.each).to be_an Enumerator
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|