decouplio 1.0.0alpha2 → 1.0.0alpha5
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/.circleci/config.yml +11 -1
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -1
- data/README.md +2 -17
- data/benchmarks/multi_step_benchmark.rb +11 -10
- data/benchmarks/single_step_benchmark.rb +1 -1
- data/decouplio.gemspec +4 -4
- data/lib/decouplio/action.rb +12 -0
- data/lib/decouplio/composer.rb +47 -24
- data/lib/decouplio/const/doby_aide_options.rb +16 -0
- data/lib/decouplio/const/error_messages.rb +9 -0
- data/lib/decouplio/const/types.rb +14 -6
- data/lib/decouplio/const/validations/aide.rb +38 -0
- data/lib/decouplio/const/validations/doby.rb +36 -0
- data/lib/decouplio/const/validations/fail.rb +4 -0
- data/lib/decouplio/const/validations/octo.rb +2 -1
- data/lib/decouplio/errors/{deny_can_not_be_first_step_error.rb → aide_can_not_be_first_step_error.rb} +3 -3
- data/lib/decouplio/errors/aide_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/aide_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/doby_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/doby_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/execution_error.rb +20 -0
- data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
- data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
- data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
- data/lib/decouplio/logic_dsl.rb +23 -8
- data/lib/decouplio/options_validator.rb +157 -13
- data/lib/decouplio/steps/aide.rb +37 -0
- data/lib/decouplio/steps/base_resq.rb +13 -3
- data/lib/decouplio/steps/doby.rb +9 -8
- data/lib/decouplio/steps/octo.rb +7 -2
- data/lib/decouplio/validators/condition.rb +10 -0
- data/lib/decouplio/version.rb +1 -1
- metadata +24 -42
- data/docs/_config.yml +0 -1
- data/docs/benchmarks.md +0 -1
- data/docs/context.md +0 -74
- data/docs/context.rb +0 -62
- data/docs/deny.rb +0 -59
- data/docs/doby.rb +0 -38
- data/docs/doby_deny.md +0 -171
- data/docs/error_store.md +0 -347
- data/docs/error_store.rb +0 -202
- data/docs/fail.md +0 -1159
- data/docs/fail.rb +0 -859
- data/docs/index.md +0 -25
- data/docs/inner_action.md +0 -63
- data/docs/inner_action.rb +0 -43
- data/docs/logic_block.md +0 -25
- data/docs/octo.md +0 -269
- data/docs/octo.rb +0 -164
- data/docs/pass.md +0 -309
- data/docs/pass.rb +0 -213
- data/docs/quick_start.md +0 -71
- data/docs/quick_start.rb +0 -38
- data/docs/resq.md +0 -263
- data/docs/resq.rb +0 -176
- data/docs/step.md +0 -885
- data/docs/step.rb +0 -627
- data/docs/step_as_a_service.md +0 -123
- data/docs/step_as_a_service.rb +0 -77
- data/docs/wrap.md +0 -240
- data/docs/wrap.rb +0 -137
- data/lib/decouplio/const/validations/deny.rb +0 -11
- data/lib/decouplio/steps/deny.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45afd6ffb3ffcbab53858cf4ae18b2fede66cd562d2fc5edcb8604cd8f72edef
|
4
|
+
data.tar.gz: 3ab25617f0ae816e115771b6d3f9fcb85509a8dd1ec16d2fefc5710848403829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399d4953dbacebccab67a4d3bb6de4d6cf2a85cdbd12ac9510e84520a58bfdc5211b8dc589d59cf0996877d49c876466a53d60156c7293451de84702d27af631
|
7
|
+
data.tar.gz: 911b51846754fee6ff178dc430e030cb46102edf669d1707011b0d3a2cba50af2c0584b4739b17fd5935ea53b25a1cf467d0a3d8c1e45d0387c25f42bf476fe7
|
data/.circleci/config.yml
CHANGED
@@ -3,7 +3,7 @@ version: 2.1
|
|
3
3
|
executors:
|
4
4
|
test_executor:
|
5
5
|
docker:
|
6
|
-
- image:
|
6
|
+
- image: cimg/ruby:${RUBY_VERSION}
|
7
7
|
working_directory: ~/decouplio
|
8
8
|
|
9
9
|
jobs:
|
@@ -51,3 +51,13 @@ workflows:
|
|
51
51
|
name: 'ruby 3.0.3'
|
52
52
|
ruby_version: 3.0.3
|
53
53
|
bundler_version: 2.2.32
|
54
|
+
# TODO: Currently rspec-mocks has some issue, or maybe decouplio has an issue
|
55
|
+
# needs to be investigated
|
56
|
+
# 3 specs are failing
|
57
|
+
# rspec ./spec/resq_spec.rb:174
|
58
|
+
# rspec ./spec/resq_spec.rb:286
|
59
|
+
# rspec ./spec/resq_spec.rb:398
|
60
|
+
# - build:
|
61
|
+
# name: 'ruby 3.1.2'
|
62
|
+
# ruby_version: 3.1.2
|
63
|
+
# bundler_version: 2.2.32
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.6
|
data/README.md
CHANGED
@@ -25,26 +25,11 @@ Or install it by yourself:
|
|
25
25
|
- 2.7
|
26
26
|
- 3.0
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
- [Quick start](https://github.com/differencialx/decouplio/blob/master/docs/quick_start.md)
|
31
|
-
- [Logic block](https://github.com/differencialx/decouplio/blob/master/docs/logic_block.md)
|
32
|
-
- [Context](https://github.com/differencialx/decouplio/blob/master/docs/context.md)
|
33
|
-
- [Step](https://github.com/differencialx/decouplio/blob/master/docs/step.md)
|
34
|
-
- [Fail](https://github.com/differencialx/decouplio/blob/master/docs/fail.md)
|
35
|
-
- [Pass](https://github.com/differencialx/decouplio/blob/master/docs/pass.md)
|
36
|
-
- [Octo](https://github.com/differencialx/decouplio/blob/master/docs/octo.md)
|
37
|
-
- [Wrap](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)
|
38
|
-
- [Resq](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)
|
39
|
-
- [Inner action](https://github.com/differencialx/decouplio/blob/master/docs/inner_action.md)
|
40
|
-
- [Doby/Deny](https://github.com/differencialx/decouplio/blob/master/docs/doby_deny.md)
|
41
|
-
- [Step as a service](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)
|
42
|
-
- [Error store](https://github.com/differencialx/decouplio/blob/master/docs/error_store.md)
|
43
|
-
- [Benchmarks](https://github.com/differencialx/decouplio/blob/master/docs/benchmarks.md)
|
28
|
+
### [Documentation is HERE](https://differencialx.github.io/decouplio.github.io/)
|
44
29
|
|
45
30
|
## Contributing
|
46
31
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/differencialx/decouplio.
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/differencialx/decouplio/issues.
|
48
33
|
|
49
34
|
More detailed description for contribution process will be added later.
|
50
35
|
|
@@ -29,6 +29,7 @@ class RegularServiceTest
|
|
29
29
|
step_seven
|
30
30
|
step_eight
|
31
31
|
step_nine
|
32
|
+
self
|
32
33
|
end
|
33
34
|
|
34
35
|
def step_one
|
@@ -253,55 +254,55 @@ class TrailblazerTestSeveralSteps < Trailblazer::Activity::Railway
|
|
253
254
|
end
|
254
255
|
|
255
256
|
class DecouplioStepOne
|
256
|
-
def self.call(ctx
|
257
|
+
def self.call(ctx:, **)
|
257
258
|
ctx[:step_one] = ctx[:param1]
|
258
259
|
end
|
259
260
|
end
|
260
261
|
|
261
262
|
class DecouplioStepTwo
|
262
|
-
def self.call(ctx
|
263
|
+
def self.call(ctx:, **)
|
263
264
|
ctx[:step_two] = ctx[:step_one]
|
264
265
|
end
|
265
266
|
end
|
266
267
|
|
267
268
|
class DecouplioStepThree
|
268
|
-
def self.call(ctx
|
269
|
+
def self.call(ctx:, **)
|
269
270
|
ctx[:step_three] = ctx[:step_two]
|
270
271
|
end
|
271
272
|
end
|
272
273
|
|
273
274
|
class DecouplioStepFour
|
274
|
-
def self.call(ctx
|
275
|
+
def self.call(ctx:, **)
|
275
276
|
ctx[:step_four] = ctx[:step_three]
|
276
277
|
end
|
277
278
|
end
|
278
279
|
|
279
280
|
class DecouplioStepFive
|
280
|
-
def self.call(ctx
|
281
|
+
def self.call(ctx:, **)
|
281
282
|
ctx[:step_five] = ctx[:step_four]
|
282
283
|
end
|
283
284
|
end
|
284
285
|
|
285
286
|
class DecouplioStepSix
|
286
|
-
def self.call(ctx
|
287
|
+
def self.call(ctx:, **)
|
287
288
|
ctx[:step_six] = ctx[:step_five]
|
288
289
|
end
|
289
290
|
end
|
290
291
|
|
291
292
|
class DecouplioStepSeven
|
292
|
-
def self.call(ctx
|
293
|
+
def self.call(ctx:, **)
|
293
294
|
ctx[:step_seven] = ctx[:step_six]
|
294
295
|
end
|
295
296
|
end
|
296
297
|
|
297
298
|
class DecouplioStepEight
|
298
|
-
def self.call(ctx
|
299
|
+
def self.call(ctx:, **)
|
299
300
|
ctx[:step_eight] = ctx[:step_seven]
|
300
301
|
end
|
301
302
|
end
|
302
303
|
|
303
304
|
class DecouplioStepNine
|
304
|
-
def self.call(ctx
|
305
|
+
def self.call(ctx:, **)
|
305
306
|
ctx[:step_nine] = ctx[:step_eight]
|
306
307
|
end
|
307
308
|
end
|
@@ -320,7 +321,7 @@ class DecouplioServiceStepsTest < Decouplio::Action
|
|
320
321
|
end
|
321
322
|
end
|
322
323
|
|
323
|
-
iteration_count =
|
324
|
+
iteration_count = 100_00
|
324
325
|
|
325
326
|
Benchmark.ips do |x|
|
326
327
|
x.report('RegularService') { iteration_count.times { RegularServiceTest.call(param1: 'param1') } }
|
@@ -123,7 +123,7 @@ class TrailblazerTestOneStep < Trailblazer::Activity::Railway
|
|
123
123
|
end
|
124
124
|
|
125
125
|
class ServiceAsStep
|
126
|
-
def self.call(ctx
|
126
|
+
def self.call(ctx:, **)
|
127
127
|
ctx[:step_one] = ctx[:param1]
|
128
128
|
ctx[:step_two] = ctx[:step_one]
|
129
129
|
ctx[:step_three] = ctx[:step_two]
|
data/decouplio.gemspec
CHANGED
@@ -12,13 +12,13 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'Gem for business logic encapsulation'
|
14
14
|
spec.description = "Decouplio is a zero dependency, thread safe and framework agnostic gem designed to encapsulate application business logic. It's reverse engineered through TDD and inspired by such frameworks and gems like Trailblazer, Interactor."
|
15
|
-
spec.homepage = 'https://github.com/differencialx/decouplio'
|
15
|
+
spec.homepage = 'https://github.com/differencialx/decouplio/blob/master/docs'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
if spec.respond_to?(:metadata)
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
-
spec.metadata['source_code_uri'] = 'https://github.com/differencialx/decouplio'
|
21
|
-
spec.metadata['changelog_uri'] = 'https://github.com/differencialx/decouplio/CHANGELOG.md'
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/differencialx/decouplio/blob/master/docs'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/differencialx/decouplio/blob/master/docs/CHANGELOG.md'
|
22
22
|
else
|
23
23
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
24
|
'public gem pushes.'
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'bundler', '~> 2'
|
35
35
|
spec.add_development_dependency 'pry-byebug'
|
36
36
|
spec.add_development_dependency 'rake', '>= 12.3.2'
|
37
|
-
spec.add_development_dependency 'rspec', '
|
37
|
+
spec.add_development_dependency 'rspec', '3.10'
|
38
38
|
spec.add_development_dependency 'rubocop'
|
39
39
|
spec.add_development_dependency 'rubocop-rspec'
|
40
40
|
end
|
data/lib/decouplio/action.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative 'default_error_handler'
|
|
7
7
|
require_relative 'errors/logic_redefinition_error'
|
8
8
|
require_relative 'errors/logic_is_not_defined_error'
|
9
9
|
require_relative 'errors/error_store_error'
|
10
|
+
require_relative 'errors/execution_error'
|
10
11
|
require_relative 'const/results'
|
11
12
|
|
12
13
|
module Decouplio
|
@@ -99,6 +100,17 @@ module Decouplio
|
|
99
100
|
instance
|
100
101
|
end
|
101
102
|
|
103
|
+
def call!(**params)
|
104
|
+
instance = call(**params)
|
105
|
+
if instance.failure?
|
106
|
+
raise Decouplio::Errors::ExecutionError.new(
|
107
|
+
action: instance
|
108
|
+
)
|
109
|
+
else
|
110
|
+
instance
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
102
114
|
private
|
103
115
|
|
104
116
|
def inherited(child_class)
|
data/lib/decouplio/composer.rb
CHANGED
@@ -21,7 +21,7 @@ require_relative 'steps/service_step'
|
|
21
21
|
require_relative 'steps/service_fail'
|
22
22
|
require_relative 'steps/service_pass'
|
23
23
|
require_relative 'steps/doby'
|
24
|
-
require_relative 'steps/
|
24
|
+
require_relative 'steps/aide'
|
25
25
|
require_relative 'options_validator'
|
26
26
|
require_relative 'validators/condition'
|
27
27
|
|
@@ -130,9 +130,9 @@ module Decouplio
|
|
130
130
|
when Decouplio::Const::Types::SERVICE_TYPE_PASS
|
131
131
|
create_inner_service_pass(stp, flow)
|
132
132
|
when Decouplio::Const::Types::DOBY_TYPE
|
133
|
-
create_doby(stp)
|
134
|
-
when Decouplio::Const::Types::
|
135
|
-
|
133
|
+
create_doby(stp, flow)
|
134
|
+
when Decouplio::Const::Types::AIDE_TYPE
|
135
|
+
create_aide(stp, flow)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -186,7 +186,8 @@ module Decouplio
|
|
186
186
|
def create_octo(stp)
|
187
187
|
Decouplio::Steps::Octo.new(
|
188
188
|
name: stp[:name],
|
189
|
-
ctx_key: stp[:ctx_key]
|
189
|
+
ctx_key: stp[:ctx_key],
|
190
|
+
method: stp[:method]
|
190
191
|
)
|
191
192
|
end
|
192
193
|
|
@@ -204,14 +205,16 @@ module Decouplio
|
|
204
205
|
def create_resq_pass(stp, flow)
|
205
206
|
Decouplio::Steps::ResqPass.new(
|
206
207
|
handler_hash: stp[:handler_hash],
|
207
|
-
step_to_resq: create_step_instance(stp[:step_to_resq], flow)
|
208
|
+
step_to_resq: create_step_instance(stp[:step_to_resq], flow),
|
209
|
+
on_error_type: error_type(flow, stp)
|
208
210
|
)
|
209
211
|
end
|
210
212
|
|
211
213
|
def create_resq_fail(stp, flow)
|
212
214
|
Decouplio::Steps::ResqFail.new(
|
213
215
|
handler_hash: stp[:handler_hash],
|
214
|
-
step_to_resq: create_step_instance(stp[:step_to_resq], flow)
|
216
|
+
step_to_resq: create_step_instance(stp[:step_to_resq], flow),
|
217
|
+
on_error_type: error_type(flow, stp)
|
215
218
|
)
|
216
219
|
end
|
217
220
|
|
@@ -269,19 +272,23 @@ module Decouplio
|
|
269
272
|
)
|
270
273
|
end
|
271
274
|
|
272
|
-
def create_doby(stp)
|
275
|
+
def create_doby(stp, flow)
|
273
276
|
Decouplio::Steps::Doby.new(
|
274
277
|
name: stp[:name],
|
275
278
|
doby_class: stp[:doby_class],
|
276
|
-
doby_options: stp[:doby_options]
|
279
|
+
doby_options: stp[:doby_options],
|
280
|
+
on_success_type: success_type(flow, stp),
|
281
|
+
on_failure_type: failure_type(flow, stp)
|
277
282
|
)
|
278
283
|
end
|
279
284
|
|
280
|
-
def
|
281
|
-
Decouplio::Steps::
|
285
|
+
def create_aide(stp, flow)
|
286
|
+
Decouplio::Steps::Aide.new(
|
282
287
|
name: stp[:name],
|
283
|
-
|
284
|
-
|
288
|
+
aide_class: stp[:aide_class],
|
289
|
+
aide_options: stp[:aide_options],
|
290
|
+
on_success_type: success_type(flow, stp),
|
291
|
+
on_failure_type: failure_type(flow, stp)
|
285
292
|
)
|
286
293
|
end
|
287
294
|
|
@@ -305,8 +312,8 @@ module Decouplio
|
|
305
312
|
compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
306
313
|
when Decouplio::Const::Types::DOBY_TYPE
|
307
314
|
compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
308
|
-
when Decouplio::Const::Types::
|
309
|
-
|
315
|
+
when Decouplio::Const::Types::AIDE_TYPE
|
316
|
+
compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
310
317
|
when Decouplio::Const::Types::IF_TYPE_PASS, Decouplio::Const::Types::UNLESS_TYPE_PASS
|
311
318
|
compose_pass_condition_flow(stp, flow, idx, flow_hash)
|
312
319
|
when Decouplio::Const::Types::IF_TYPE_FAIL, Decouplio::Const::Types::UNLESS_TYPE_FAIL
|
@@ -340,22 +347,22 @@ module Decouplio
|
|
340
347
|
stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
|
341
348
|
end
|
342
349
|
|
343
|
-
def compose_doby_flow(stp,
|
350
|
+
def compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
344
351
|
flow_values = flow.values + (next_steps&.values || [])
|
345
352
|
stp[:flow][Decouplio::Const::Results::PASS] = next_success_step(
|
346
353
|
flow_values,
|
347
354
|
idx,
|
348
|
-
|
355
|
+
flow[step_id][:on_success]
|
349
356
|
)
|
350
357
|
stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
|
351
358
|
flow_values,
|
352
359
|
idx,
|
353
|
-
|
360
|
+
flow[step_id][:on_failure]
|
354
361
|
)
|
355
362
|
stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
|
356
363
|
flow_values,
|
357
364
|
idx,
|
358
|
-
|
365
|
+
flow[step_id][:on_error]
|
359
366
|
)
|
360
367
|
stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::PASS]
|
361
368
|
stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
@@ -363,22 +370,22 @@ module Decouplio
|
|
363
370
|
stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
|
364
371
|
end
|
365
372
|
|
366
|
-
def
|
373
|
+
def compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
367
374
|
flow_values = flow.values + (next_steps&.values || [])
|
368
375
|
stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
|
369
376
|
flow_values,
|
370
377
|
idx,
|
371
|
-
|
378
|
+
flow[step_id][:on_success]
|
372
379
|
)
|
373
380
|
stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
|
374
381
|
flow_values,
|
375
382
|
idx,
|
376
|
-
|
383
|
+
flow[step_id][:on_failure]
|
377
384
|
)
|
378
385
|
stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
|
379
386
|
flow_values,
|
380
387
|
idx,
|
381
|
-
|
388
|
+
flow[step_id][:on_error]
|
382
389
|
)
|
383
390
|
stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
384
391
|
stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
@@ -462,7 +469,22 @@ module Decouplio
|
|
462
469
|
step_id = stp.dig(:flow, Decouplio::Const::Results::FAIL)
|
463
470
|
if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_failure]
|
464
471
|
Decouplio::Const::Results::STEP_PASS
|
465
|
-
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:
|
472
|
+
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_failure]
|
473
|
+
Decouplio::Const::Results::STEP_FAIL
|
474
|
+
else
|
475
|
+
Decouplio::Const::Types::FAIL_FLOW.include?(
|
476
|
+
flow[step_id]&.[](:type)
|
477
|
+
)
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def error_type(flow, stp)
|
482
|
+
return :finish_him if [:on_error].include?(finish_him(stp))
|
483
|
+
|
484
|
+
step_id = stp.dig(:flow, Decouplio::Const::Results::ERROR)
|
485
|
+
if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_error]
|
486
|
+
Decouplio::Const::Results::STEP_PASS
|
487
|
+
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_error]
|
466
488
|
Decouplio::Const::Results::STEP_FAIL
|
467
489
|
else
|
468
490
|
Decouplio::Const::Types::FAIL_FLOW.include?(
|
@@ -571,6 +593,7 @@ module Decouplio
|
|
571
593
|
options_for_resq = stp[:step_to_resq].slice(
|
572
594
|
:on_success,
|
573
595
|
:on_failure,
|
596
|
+
:on_error,
|
574
597
|
:finish_him,
|
575
598
|
:if,
|
576
599
|
:unless
|
@@ -14,7 +14,7 @@ module Decouplio
|
|
14
14
|
UNLESS_TYPE_FAIL = :unless_fail
|
15
15
|
OCTO_TYPE = :octo
|
16
16
|
DOBY_TYPE = :doby
|
17
|
-
|
17
|
+
AIDE_TYPE = :aide
|
18
18
|
ACTION_TYPE_STEP = :action_step
|
19
19
|
ACTION_TYPE_FAIL = :action_fail
|
20
20
|
ACTION_TYPE_PASS = :action_pass
|
@@ -82,6 +82,14 @@ module Decouplio
|
|
82
82
|
SERVICE_TYPE_PASS => {
|
83
83
|
IF_TYPE => IF_TYPE_PASS,
|
84
84
|
UNLESS_TYPE => UNLESS_TYPE_PASS
|
85
|
+
},
|
86
|
+
DOBY_TYPE => {
|
87
|
+
IF_TYPE => IF_TYPE_PASS,
|
88
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
89
|
+
},
|
90
|
+
AIDE_TYPE => {
|
91
|
+
IF_TYPE => IF_TYPE_FAIL,
|
92
|
+
UNLESS_TYPE => UNLESS_TYPE_FAIL
|
85
93
|
}
|
86
94
|
}.freeze
|
87
95
|
STEP_TYPE_TO_RESQ_TYPE = {
|
@@ -95,7 +103,7 @@ module Decouplio
|
|
95
103
|
IF_TYPE_FAIL => RESQ_TYPE_FAIL,
|
96
104
|
UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL,
|
97
105
|
DOBY_TYPE => RESQ_TYPE_STEP,
|
98
|
-
|
106
|
+
AIDE_TYPE => RESQ_TYPE_FAIL
|
99
107
|
}.freeze
|
100
108
|
STEP_TYPE_TO_INNER_TYPE = {
|
101
109
|
STEP_TYPE => ACTION_TYPE_STEP,
|
@@ -118,7 +126,7 @@ module Decouplio
|
|
118
126
|
WRAP_TYPE,
|
119
127
|
RESQ_TYPE,
|
120
128
|
DOBY_TYPE,
|
121
|
-
|
129
|
+
AIDE_TYPE
|
122
130
|
].freeze
|
123
131
|
PASS_FLOW = [
|
124
132
|
STEP_TYPE,
|
@@ -139,7 +147,7 @@ module Decouplio
|
|
139
147
|
UNLESS_TYPE_FAIL,
|
140
148
|
ACTION_TYPE_FAIL,
|
141
149
|
SERVICE_TYPE_FAIL,
|
142
|
-
|
150
|
+
AIDE_TYPE
|
143
151
|
].freeze
|
144
152
|
|
145
153
|
MAIN_FLOW_TYPES = [
|
@@ -148,7 +156,7 @@ module Decouplio
|
|
148
156
|
PASS_TYPE,
|
149
157
|
WRAP_TYPE,
|
150
158
|
DOBY_TYPE,
|
151
|
-
|
159
|
+
AIDE_TYPE
|
152
160
|
].freeze
|
153
161
|
SUCCESS_TRACK_STEP_TYPES = [
|
154
162
|
STEP_TYPE,
|
@@ -172,7 +180,7 @@ module Decouplio
|
|
172
180
|
RESQ_TYPE_FAIL,
|
173
181
|
ACTION_TYPE_FAIL,
|
174
182
|
SERVICE_TYPE_FAIL,
|
175
|
-
|
183
|
+
AIDE_TYPE
|
176
184
|
].freeze
|
177
185
|
end
|
178
186
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Aide
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "aide":
|
9
|
+
%s
|
10
|
+
|
11
|
+
Details:
|
12
|
+
%s
|
13
|
+
|
14
|
+
Allowed options are:
|
15
|
+
%s
|
16
|
+
|
17
|
+
Please read the manual about allowed options here:
|
18
|
+
%s
|
19
|
+
ERROR_MESSAGE
|
20
|
+
|
21
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
22
|
+
on_success: <step name OR :finish_him>
|
23
|
+
on_failure: <step name OR :finish_him>
|
24
|
+
finish_him: :on_success
|
25
|
+
finish_him: :on_failure
|
26
|
+
finish_him: true
|
27
|
+
if: <instance method symbol>
|
28
|
+
unless: <instance method symbol>
|
29
|
+
ALLOWED_OPTIONS
|
30
|
+
MANUAL_URL = 'https://stub.aide.manual.url'
|
31
|
+
OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "aide"'
|
32
|
+
METHOD_NOT_DEFINED = 'aide :%s'
|
33
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
34
|
+
FIRST_STEP = '"aide" can not be the first step'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Doby
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "doby":
|
9
|
+
%s
|
10
|
+
|
11
|
+
Details:
|
12
|
+
%s
|
13
|
+
|
14
|
+
Allowed options are:
|
15
|
+
%s
|
16
|
+
|
17
|
+
Please read the manual about allowed options here:
|
18
|
+
%s
|
19
|
+
ERROR_MESSAGE
|
20
|
+
|
21
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
22
|
+
on_success: <step name OR :finish_him>
|
23
|
+
on_failure: <step name OR :finish_him>
|
24
|
+
finish_him: :on_success
|
25
|
+
finish_him: :on_failure
|
26
|
+
if: <instance method symbol>
|
27
|
+
unless: <instance method symbol>
|
28
|
+
ALLOWED_OPTIONS
|
29
|
+
MANUAL_URL = 'https://stub.doby.manual.url'
|
30
|
+
OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "doby"'
|
31
|
+
METHOD_NOT_DEFINED = 'doby :%s'
|
32
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -19,6 +19,10 @@ module Decouplio
|
|
19
19
|
ERROR_MESSAGE
|
20
20
|
|
21
21
|
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
22
|
+
on_success: <step name OR :finish_him>
|
23
|
+
on_failure: <step name OR :finish_him>
|
24
|
+
finish_him: :on_success
|
25
|
+
finish_him: :on_failure
|
22
26
|
finish_him: true
|
23
27
|
if: <instance method symbol>
|
24
28
|
unless: <instance method symbol>
|
@@ -28,7 +28,8 @@ module Decouplio
|
|
28
28
|
%s
|
29
29
|
ERROR_MESSAGE
|
30
30
|
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
31
|
-
ctx_key: <ctx key with strategy name to be used for strategy mapping> - required
|
31
|
+
ctx_key: <ctx key with strategy name to be used for strategy mapping> - required if "method" option is not present
|
32
|
+
method: <method which will return strategy name to be used for strategy mapping> - required if "ctx_key" option is not present
|
32
33
|
if: <instance method symbol>
|
33
34
|
unless: <instance method symbol>
|
34
35
|
ALLOWED_OPTIONS
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'base_error'
|
4
|
-
require_relative '../const/validations/
|
4
|
+
require_relative '../const/validations/aide'
|
5
5
|
|
6
6
|
module Decouplio
|
7
7
|
module Errors
|
8
|
-
class
|
8
|
+
class AideCanNotBeFirstStepError < Decouplio::Errors::BaseError
|
9
9
|
def template
|
10
|
-
Decouplio::Const::Validations::
|
10
|
+
Decouplio::Const::Validations::Aide::FIRST_STEP
|
11
11
|
end
|
12
12
|
|
13
13
|
def interpolation_values
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/aide'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class AideControversialKeysError < Decouplio::Errors::BaseError
|
9
|
+
def template
|
10
|
+
Decouplio::Const::Validations::Aide::VALIDATION_ERROR_MESSAGE
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpolation_values
|
14
|
+
[
|
15
|
+
@errored_option,
|
16
|
+
format(
|
17
|
+
Decouplio::Const::Validations::Aide::CONTROVERSIAL_KEYS,
|
18
|
+
*@details
|
19
|
+
),
|
20
|
+
Decouplio::Const::Validations::Aide::ALLOWED_OPTIONS_MESSAGE,
|
21
|
+
Decouplio::Const::Validations::Aide::MANUAL_URL
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/aide'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class AideFinishHimError < Decouplio::Errors::BaseError
|
9
|
+
def template
|
10
|
+
Decouplio::Const::Validations::Aide::VALIDATION_ERROR_MESSAGE
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpolation_values
|
14
|
+
[
|
15
|
+
@errored_option,
|
16
|
+
format(
|
17
|
+
Decouplio::Const::Validations::Common::WRONG_FINISH_HIM_VALUE,
|
18
|
+
@details
|
19
|
+
),
|
20
|
+
Decouplio::Const::Validations::Aide::ALLOWED_OPTIONS_MESSAGE,
|
21
|
+
Decouplio::Const::Validations::Aide::MANUAL_URL
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|