incredible 0.0.1.pre → 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/incredible/form.rb +1 -1
- data/lib/incredible/step.rb +11 -3
- data/lib/incredible/version.rb +1 -1
- data/lib/incredible/wizard.rb +3 -5
- data/spec/dummy/app/rules/step1_rule.rb +8 -0
- data/spec/step_spec.rb +24 -15
- metadata +34 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2719e5df6c532eb211e72a2ca189e31a7ccf7b8e
|
4
|
+
data.tar.gz: 1dead0a9b1eeeb8683e42fc97a8c81bf73e1277f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49ea21f4e8fb664430e3431f88dd760fffef0d0e1a79cf9c04cfabfe78df2a38319e2eb8e37e4b6b80b6093ceccc202093b3083d3fcec22286827b5a38c1de16
|
7
|
+
data.tar.gz: f7e187f3cee82ee529b8af163b476728900127e1d378793c406368b338dd27023fc730e7d7aa33bbc9045c5a3a0cb1cde17a8736a8640b0f8b8790434d28b681
|
data/lib/incredible/form.rb
CHANGED
data/lib/incredible/step.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
module Incredible
|
2
2
|
class Step
|
3
|
-
|
4
|
-
def initialize(data)
|
3
|
+
|
4
|
+
def initialize(name, data)
|
5
|
+
@name = name.to_s
|
5
6
|
@data = data.symbolize_keys
|
6
7
|
|
7
|
-
%I[questions
|
8
|
+
%I[questions template].each do |k|
|
8
9
|
self.class.send :define_method, k.to_sym do
|
9
10
|
@data[k]
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
def rule
|
16
|
+
rule_class = "#{@name.classify}Rule"
|
17
|
+
rule_class.constantize
|
18
|
+
rescue NameError
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
14
22
|
end
|
15
23
|
end
|
data/lib/incredible/version.rb
CHANGED
data/lib/incredible/wizard.rb
CHANGED
@@ -21,11 +21,9 @@ module Incredible
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def process_rules
|
24
|
-
|
25
|
-
next_step =
|
26
|
-
|
27
|
-
end&.first
|
28
|
-
jump_to next_step if next_step
|
24
|
+
return unless step_data.rule
|
25
|
+
next_step = step_data.rule.send(:process, permitted_params)
|
26
|
+
jump_to next_step
|
29
27
|
end
|
30
28
|
|
31
29
|
module ClassMethods
|
data/spec/step_spec.rb
CHANGED
@@ -10,17 +10,11 @@ describe Incredible::Step do
|
|
10
10
|
widget: 'text'
|
11
11
|
}
|
12
12
|
],
|
13
|
-
rules: {
|
14
|
-
name: {
|
15
|
-
'Someone' => :next_step,
|
16
|
-
'Someone else' => :last_step
|
17
|
-
}
|
18
|
-
},
|
19
13
|
template: 'my_template'
|
20
14
|
}
|
21
15
|
end
|
22
16
|
|
23
|
-
let(:subject) { Incredible::Step.new(hash) }
|
17
|
+
let(:subject) { Incredible::Step.new('rule', hash) }
|
24
18
|
|
25
19
|
context '#questions' do
|
26
20
|
|
@@ -37,15 +31,30 @@ describe Incredible::Step do
|
|
37
31
|
|
38
32
|
end
|
39
33
|
|
40
|
-
context '#
|
34
|
+
context '#rule' do
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
context 'when a rule is not present' do
|
37
|
+
|
38
|
+
before do
|
39
|
+
Object.send(:remove_const, :RuleRule) if defined?(RuleRule)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'returns nil' do
|
43
|
+
expect(subject.rule).to eq(nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when a rule is present' do
|
49
|
+
|
50
|
+
before do
|
51
|
+
Object.const_set('RuleRule', Class.new)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns the rule' do
|
55
|
+
expect(subject.rule).to eq(RuleRule)
|
56
|
+
end
|
57
|
+
|
49
58
|
end
|
50
59
|
|
51
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incredible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pezholio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- spec/dummy/app/controllers/forms_controller.rb
|
161
161
|
- spec/dummy/app/models/application_record.rb
|
162
162
|
- spec/dummy/app/models/stub_model.rb
|
163
|
+
- spec/dummy/app/rules/step1_rule.rb
|
163
164
|
- spec/dummy/app/views/forms/bar.html.erb
|
164
165
|
- spec/dummy/app/views/forms/foo.html.erb
|
165
166
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -224,48 +225,49 @@ signing_key:
|
|
224
225
|
specification_version: 4
|
225
226
|
summary: Build multi-page forms like a General
|
226
227
|
test_files:
|
227
|
-
- spec/
|
228
|
+
- spec/spec_helper.rb
|
229
|
+
- spec/form_spec.rb
|
230
|
+
- spec/controllers/forms_controller_spec.rb
|
231
|
+
- spec/loader_spec.rb
|
228
232
|
- spec/dummy/Rakefile
|
229
|
-
- spec/dummy/config
|
233
|
+
- spec/dummy/config.ru
|
234
|
+
- spec/dummy/config/forms/bad-yaml.yml
|
235
|
+
- spec/dummy/config/forms/form.yml
|
230
236
|
- spec/dummy/config/application.rb
|
231
|
-
- spec/dummy/config/
|
232
|
-
- spec/dummy/config/boot.rb
|
237
|
+
- spec/dummy/config/environment.rb
|
233
238
|
- spec/dummy/config/puma.rb
|
239
|
+
- spec/dummy/config/cable.yml
|
240
|
+
- spec/dummy/config/spring.rb
|
234
241
|
- spec/dummy/config/environments/production.rb
|
235
242
|
- spec/dummy/config/environments/test.rb
|
236
243
|
- spec/dummy/config/environments/development.rb
|
237
|
-
- spec/dummy/config/
|
238
|
-
- spec/dummy/config/
|
244
|
+
- spec/dummy/config/boot.rb
|
245
|
+
- spec/dummy/config/locales/en.yml
|
246
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
239
247
|
- spec/dummy/config/initializers/mime_types.rb
|
240
|
-
- spec/dummy/config/initializers/
|
241
|
-
- spec/dummy/config/initializers/
|
248
|
+
- spec/dummy/config/initializers/inflections.rb
|
249
|
+
- spec/dummy/config/initializers/assets.rb
|
242
250
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
243
|
-
- spec/dummy/config/initializers/
|
251
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
252
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
244
253
|
- spec/dummy/config/initializers/application_controller_renderer.rb
|
245
|
-
- spec/dummy/config/cable.yml
|
246
|
-
- spec/dummy/config/environment.rb
|
247
254
|
- spec/dummy/config/secrets.yml
|
248
|
-
- spec/dummy/config/
|
249
|
-
- spec/dummy/
|
250
|
-
- spec/dummy/config/locales/en.yml
|
251
|
-
- spec/dummy/config.ru
|
252
|
-
- spec/dummy/app/models/application_record.rb
|
253
|
-
- spec/dummy/app/models/stub_model.rb
|
254
|
-
- spec/dummy/app/controllers/forms_controller.rb
|
255
|
-
- spec/dummy/app/controllers/application_controller.rb
|
256
|
-
- spec/dummy/app/views/layouts/mailer.html.erb
|
257
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
258
|
-
- spec/dummy/app/views/layouts/mailer.text.erb
|
259
|
-
- spec/dummy/app/views/forms/bar.html.erb
|
260
|
-
- spec/dummy/app/views/forms/foo.html.erb
|
255
|
+
- spec/dummy/config/routes.rb
|
256
|
+
- spec/dummy/bin/yarn
|
261
257
|
- spec/dummy/bin/rake
|
262
258
|
- spec/dummy/bin/bundle
|
263
259
|
- spec/dummy/bin/rails
|
264
|
-
- spec/dummy/bin/setup
|
265
|
-
- spec/dummy/bin/yarn
|
266
260
|
- spec/dummy/bin/update
|
267
|
-
- spec/
|
268
|
-
- spec/
|
269
|
-
- spec/
|
270
|
-
- spec/
|
261
|
+
- spec/dummy/bin/setup
|
262
|
+
- spec/dummy/app/rules/step1_rule.rb
|
263
|
+
- spec/dummy/app/views/forms/bar.html.erb
|
264
|
+
- spec/dummy/app/views/forms/foo.html.erb
|
265
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
266
|
+
- spec/dummy/app/views/layouts/mailer.html.erb
|
267
|
+
- spec/dummy/app/views/layouts/mailer.text.erb
|
268
|
+
- spec/dummy/app/models/application_record.rb
|
269
|
+
- spec/dummy/app/models/stub_model.rb
|
270
|
+
- spec/dummy/app/controllers/forms_controller.rb
|
271
|
+
- spec/dummy/app/controllers/application_controller.rb
|
272
|
+
- spec/dummy/package.json
|
271
273
|
- spec/step_spec.rb
|