decouplio 1.0.0alpha2 → 1.0.0alpha3

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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/benchmarks/multi_step_benchmark.rb +11 -10
  4. data/benchmarks/single_step_benchmark.rb +1 -1
  5. data/docs/{deny.rb → aide.rb} +3 -3
  6. data/docs/{doby_deny.md → doby_aide.md} +49 -12
  7. data/docs/index.md +1 -1
  8. data/docs/logic_block.md +4 -0
  9. data/docs/octo.md +59 -2
  10. data/docs/quick_start.md +1 -1
  11. data/lib/decouplio/composer.rb +26 -21
  12. data/lib/decouplio/const/doby_aide_options.rb +15 -0
  13. data/lib/decouplio/const/types.rb +14 -6
  14. data/lib/decouplio/const/validations/aide.rb +38 -0
  15. data/lib/decouplio/const/validations/doby.rb +36 -0
  16. data/lib/decouplio/const/validations/fail.rb +4 -0
  17. data/lib/decouplio/const/validations/octo.rb +2 -1
  18. data/lib/decouplio/errors/{deny_can_not_be_first_step_error.rb → aide_can_not_be_first_step_error.rb} +3 -3
  19. data/lib/decouplio/errors/aide_controversial_keys_error.rb +26 -0
  20. data/lib/decouplio/errors/aide_finish_him_error.rb +26 -0
  21. data/lib/decouplio/errors/doby_controversial_keys_error.rb +26 -0
  22. data/lib/decouplio/errors/doby_finish_him_error.rb +26 -0
  23. data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
  24. data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
  25. data/lib/decouplio/logic_dsl.rb +23 -8
  26. data/lib/decouplio/options_validator.rb +114 -5
  27. data/lib/decouplio/steps/aide.rb +37 -0
  28. data/lib/decouplio/steps/doby.rb +9 -8
  29. data/lib/decouplio/steps/octo.rb +7 -2
  30. data/lib/decouplio/validators/condition.rb +10 -0
  31. data/lib/decouplio/version.rb +1 -1
  32. metadata +15 -7
  33. data/lib/decouplio/const/validations/deny.rb +0 -11
  34. data/lib/decouplio/steps/deny.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b94378c5ef6384c1e88ea9c71ef987b7a607da12cae8ed05f1ffdcc5c575c3b
4
- data.tar.gz: 7954e4f1bd9fad05c07be76cbd3b8343477d9f5610751c59840e0b01907b079d
3
+ metadata.gz: b52142f648d5043e84d6daa6b36026f33d01a6bd9197d5e6f65ac0fb51abac81
4
+ data.tar.gz: 7825cc21ae535df0c950c7b5eaf34264d37f6fe13f346282bc3a15e88e4e8b8e
5
5
  SHA512:
6
- metadata.gz: 762378c8f56ca4833f79255396a0a09b449767d04be8dbc07f87b66924f90334f6780b63eeca020853a065d5c227f99a6987ec2cb024cfbffccd62326d1b2f36
7
- data.tar.gz: b233ac1a47544de489e147b2b021d1d98968f85feb8dc780d182147d4db6cb81098240f43b9da2893cba2b4cb1e7a823b07619fb7495dce3fb29d70e6174c1b4
6
+ metadata.gz: 395c7ca0d0618abd369307426edba5ada1d4dc002f55ff8c0906205e08924a07ec60b0905fd2031860a7b32effbe88265139faf397972ea1359448b5c1572ebb
7
+ data.tar.gz: 0fa93d697696700e24758eb3b774d183b1e24486a5846273c24d6ff7dc3684876b587e0afb90165bdb3f8bde8deeee938fc78d90361b4d0d2c193eeec7870ac0
data/README.md CHANGED
@@ -37,7 +37,7 @@ Or install it by yourself:
37
37
  - [Wrap](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)
38
38
  - [Resq](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)
39
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)
40
+ - [Doby/Aide](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)
41
41
  - [Step as a service](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)
42
42
  - [Error store](https://github.com/differencialx/decouplio/blob/master/docs/error_store.md)
43
43
  - [Benchmarks](https://github.com/differencialx/decouplio/blob/master/docs/benchmarks.md)
@@ -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 = 100_000_0
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]
@@ -1,6 +1,6 @@
1
1
  require_relative '../lib/decouplio'
2
2
 
3
- class SemanticDeny
3
+ class SemanticAide
4
4
  def self.call(ctx:, error_store:, semantic:, error_message:)
5
5
  ctx[:semantic] = semantic
6
6
  error_store.add_error(semantic, error_message)
@@ -10,7 +10,7 @@ end
10
10
  class SomeAction < Decouplio::Action
11
11
  logic do
12
12
  step :step_one
13
- deny SemanticDeny, semantic: :bad_request, error_message: 'Bad request'
13
+ aide SemanticAide, semantic: :bad_request, error_message: 'Bad request'
14
14
  step :step_two
15
15
  end
16
16
 
@@ -48,7 +48,7 @@ failure_action # =>
48
48
  # Result: failure
49
49
 
50
50
  # Railway Flow:
51
- # step_one -> SemanticDeny
51
+ # step_one -> SemanticAide
52
52
 
53
53
  # Context:
54
54
  # :step_one_param => false
@@ -1,13 +1,13 @@
1
- # Doby/Deny
1
+ # Doby/Aide
2
2
 
3
- It's a step type to make configurable manipulations with action context.
3
+ Steps which make configurable manipulations with action context.
4
4
 
5
5
 
6
6
  ## Signature
7
7
 
8
8
  ```ruby
9
9
  doby(class_constant, **options)
10
- deny(class_constant, **options)
10
+ aide(class_constant, **options)
11
11
  ```
12
12
 
13
13
  ## Behavior
@@ -18,9 +18,9 @@ deny(class_constant, **options)
18
18
  - `doby` doesn't have `on_success, on_failure, if, unless, finish_him` options.
19
19
  - All options passed after class constant will be passed as kwargs for `.call` method.
20
20
 
21
- ### Deny
22
- - `deny` behaves similar to `fail`, no matter which value will be returned by `.call` method, it moves to `failure` track.
23
- - `deny` doesn't have `on_success, on_failure, if, unless, finish_him` options.
21
+ ### Aide
22
+ - `aide` behaves similar to `fail`, no matter which value will be returned by `.call` method, it moves to `failure` track.
23
+ - `aide` doesn't have `on_success, on_failure, if, unless, finish_him` options.
24
24
  - All options passed after class constant will be passed as kwargs for `.call` method.
25
25
 
26
26
 
@@ -49,7 +49,7 @@ end
49
49
 
50
50
  # OR
51
51
 
52
- class SemanticDeny
52
+ class SemanticAide
53
53
  def self.call(ctx:, error_store:, semantic:, error_message:)
54
54
  ctx[:semantic] = semantic
55
55
  error_store.add_error(semantic, error_message)
@@ -81,7 +81,7 @@ end
81
81
  class SomeAction < Decouplio::Action
82
82
  logic do
83
83
  step :user
84
- step AssignDoby, to: :current_user, from: :user
84
+ doby AssignDoby, to: :current_user, from: :user
85
85
  end
86
86
 
87
87
  def user(id:, **)
@@ -107,11 +107,11 @@ action # =>
107
107
  # Errors:
108
108
  # {}
109
109
  ```
110
- `SemanticDeny` example.
110
+ `SemanticAide` example.
111
111
  ```ruby
112
112
  require 'decouplio'
113
113
 
114
- class SemanticDeny
114
+ class SemanticAide
115
115
  def self.call(ctx:, error_store:, semantic:, error_message:)
116
116
  ctx[:semantic] = semantic
117
117
  error_store.add_error(semantic, error_message)
@@ -121,7 +121,7 @@ end
121
121
  class SomeAction < Decouplio::Action
122
122
  logic do
123
123
  step :step_one
124
- deny SemanticDeny, semantic: :bad_request, error_message: 'Bad request'
124
+ aide SemanticAide, semantic: :bad_request, error_message: 'Bad request'
125
125
  step :step_two
126
126
  end
127
127
 
@@ -159,7 +159,7 @@ failure_action # =>
159
159
  # Result: failure
160
160
 
161
161
  # Railway Flow:
162
- # step_one -> SemanticDeny
162
+ # step_one -> SemanticAide
163
163
 
164
164
  # Context:
165
165
  # :step_one_param => false
@@ -169,3 +169,40 @@ failure_action # =>
169
169
  # Errors:
170
170
  # :bad_request => ["Bad request"]
171
171
  ```
172
+
173
+
174
+ ## Options
175
+
176
+ ### Doby
177
+ Has the same options and behavior as [step](https://github.com/differencialx/decouplio/blob/master/docs/step.md), just specify them along with doby class options like here:
178
+ ```ruby
179
+ # ...
180
+
181
+ logic do
182
+ doby AssignDoby,
183
+ to: :current_user,
184
+ from: :user,
185
+ on_success: :finish_him,
186
+ if: :condition
187
+ end
188
+
189
+ # ...
190
+ ```
191
+
192
+ ### Aide
193
+ Has the same options and behavior as [fail](https://github.com/differencialx/decouplio/blob/master/docs/fail.md), just specify them along with aide class options like here:
194
+
195
+ ```ruby
196
+ # ...
197
+
198
+ logic do
199
+ step :step_one
200
+ aide SemanticAide,
201
+ semantic: :bad_request,
202
+ error_message: 'Bad request',
203
+ on_failure: :PASS,
204
+ unless: :condition
205
+ end
206
+
207
+ # ...
208
+ ```
data/docs/index.md CHANGED
@@ -19,7 +19,7 @@ Decouplio is a zero dependency, thread safe and framework agnostic gem designed
19
19
  - [Wrap](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)
20
20
  - [Resq](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)
21
21
  - [Inner action](https://github.com/differencialx/decouplio/blob/master/docs/inner_action.md)
22
- - [Doby](https://github.com/differencialx/decouplio/blob/master/docs/doby.md)
22
+ - [Doby/Aide](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)
23
23
  - [Step as a service](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)
24
24
  - [Error store](https://github.com/differencialx/decouplio/blob/master/docs/error_store.md)
25
25
  - [Benchmarks](https://github.com/differencialx/decouplio/blob/master/docs/benchmarks.md)
data/docs/logic_block.md CHANGED
@@ -23,3 +23,7 @@ Possible logic steps:
23
23
  |octo|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/octo.md)|
24
24
  |wrap|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)|
25
25
  |resq|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)|
26
+ |doby|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)|
27
+ |aide|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)|
28
+ |inner action|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/inner_action.md)|
29
+ |step as service|[--->>>](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)|
data/docs/octo.md CHANGED
@@ -5,7 +5,7 @@ It's a step type which helps to implement strategy pattern.
5
5
  ## Signature
6
6
 
7
7
  ```ruby
8
- octo(octo_name, ctx_key:, **options) do
8
+ octo(octo_name, ctx_key:, method:, **options) do
9
9
  on :key1, palp: :palp_name_one
10
10
  on :key2, palp: :palp_name_two
11
11
  on :key3, palp: :palp_name_three
@@ -14,7 +14,11 @@ end
14
14
 
15
15
  ## Behavior
16
16
 
17
- - depending on the value inside `ctx_key` in context `octo` will perform flow defined for this key. So basically `octo` will be replaces with flow you defined.
17
+ - Depending on some value you can perform different flow. Imagine that `octo` will be replaced with another flow.
18
+ - You have two options to set value for octo. By `ctx_key` and `method` options.
19
+ - `ctx_key` and `method` options are controversial, so you can use only one of them.
20
+ - with `ctx_key` you can specify the key inside action context with value for `octo`
21
+ - with `method` you can specify method name symbol, which will be called to retrieve `octo` value, like we do for `if` and `unless` options.
18
22
  ```ruby
19
23
  logic do
20
24
  palp :palp_name_one do
@@ -263,7 +267,60 @@ Currently only one possibility is present to define flow for `octo`, it's `palp`
263
267
  ***
264
268
  ## Options
265
269
 
270
+ ### ctx_key: context key with octo value
271
+
272
+ See examples above
273
+
274
+ ***
275
+
276
+ ### method: method symbol which returns octo value
277
+ <details><summary><b>EXAMPLE (CLICK ME)</b></summary>
278
+ <p>
279
+
280
+ ```ruby
281
+ require 'decouplio'
282
+
283
+ class SomeAction < Decouplio::Action
284
+ logic do
285
+ palp :palp_one do
286
+ step :step_one
287
+ end
288
+
289
+ palp :palp_two do
290
+ step :step_two
291
+ end
292
+
293
+ octo :octo_name, method: :what_is_next? do
294
+ on :option_one, palp: :palp_one
295
+ on :option_two, palp: :palp_two
296
+ end
297
+ end
298
+
299
+ def step_one(**)
300
+ # ...
301
+ end
302
+
303
+ def step_two(**)
304
+ # ...
305
+ end
306
+
307
+ def what_is_next?(connection:, url:)
308
+ connection.get(url).body[:decision]
309
+ end
310
+ end
311
+ ```
312
+
313
+ </p>
314
+ </details>
315
+
316
+ ***
317
+
266
318
  ### if: condition method name
267
319
  The same as for [step](https://github.com/differencialx/decouplio/blob/master/docs/step.md)
320
+
321
+ ***
322
+
268
323
  ### unless: condition method name
269
324
  The same as for [step](https://github.com/differencialx/decouplio/blob/master/docs/step.md)
325
+
326
+ ***
data/docs/quick_start.md CHANGED
@@ -66,6 +66,6 @@ Learn more about all features:
66
66
  - [Wrap](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)
67
67
  - [Resq](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)
68
68
  - [Inner action](https://github.com/differencialx/decouplio/blob/master/docs/inner_action.md)
69
- - [Doby](https://github.com/differencialx/decouplio/blob/master/docs/doby.md)
69
+ - [Doby/Aide](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)
70
70
  - [Step as a service](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)
71
71
  - [Error store](https://github.com/differencialx/decouplio/blob/master/docs/error_store.md)
@@ -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/deny'
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::DENY_TYPE
135
- create_deny(stp)
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
 
@@ -269,19 +270,23 @@ module Decouplio
269
270
  )
270
271
  end
271
272
 
272
- def create_doby(stp)
273
+ def create_doby(stp, flow)
273
274
  Decouplio::Steps::Doby.new(
274
275
  name: stp[:name],
275
276
  doby_class: stp[:doby_class],
276
- doby_options: stp[:doby_options]
277
+ doby_options: stp[:doby_options],
278
+ on_success_type: success_type(flow, stp),
279
+ on_failure_type: failure_type(flow, stp)
277
280
  )
278
281
  end
279
282
 
280
- def create_deny(stp)
281
- Decouplio::Steps::Deny.new(
283
+ def create_aide(stp, flow)
284
+ Decouplio::Steps::Aide.new(
282
285
  name: stp[:name],
283
- deny_class: stp[:deny_class],
284
- deny_options: stp[:deny_options]
286
+ aide_class: stp[:aide_class],
287
+ aide_options: stp[:aide_options],
288
+ on_success_type: success_type(flow, stp),
289
+ on_failure_type: failure_type(flow, stp)
285
290
  )
286
291
  end
287
292
 
@@ -305,8 +310,8 @@ module Decouplio
305
310
  compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
306
311
  when Decouplio::Const::Types::DOBY_TYPE
307
312
  compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
308
- when Decouplio::Const::Types::DENY_TYPE
309
- compose_deny_flow(stp, step_id, flow, idx, flow_hash, next_steps)
313
+ when Decouplio::Const::Types::AIDE_TYPE
314
+ compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
310
315
  when Decouplio::Const::Types::IF_TYPE_PASS, Decouplio::Const::Types::UNLESS_TYPE_PASS
311
316
  compose_pass_condition_flow(stp, flow, idx, flow_hash)
312
317
  when Decouplio::Const::Types::IF_TYPE_FAIL, Decouplio::Const::Types::UNLESS_TYPE_FAIL
@@ -340,22 +345,22 @@ module Decouplio
340
345
  stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
341
346
  end
342
347
 
343
- def compose_doby_flow(stp, _step_id, flow, idx, flow_hash, next_steps)
348
+ def compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
344
349
  flow_values = flow.values + (next_steps&.values || [])
345
350
  stp[:flow][Decouplio::Const::Results::PASS] = next_success_step(
346
351
  flow_values,
347
352
  idx,
348
- nil
353
+ flow[step_id][:on_success]
349
354
  )
350
355
  stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
351
356
  flow_values,
352
357
  idx,
353
- nil
358
+ flow[step_id][:on_failure]
354
359
  )
355
360
  stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
356
361
  flow_values,
357
362
  idx,
358
- nil
363
+ flow[step_id][:on_error]
359
364
  )
360
365
  stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::PASS]
361
366
  stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
@@ -363,22 +368,22 @@ module Decouplio
363
368
  stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
364
369
  end
365
370
 
366
- def compose_deny_flow(stp, _step_id, flow, idx, flow_hash, next_steps)
371
+ def compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
367
372
  flow_values = flow.values + (next_steps&.values || [])
368
373
  stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
369
374
  flow_values,
370
375
  idx,
371
- nil
376
+ flow[step_id][:on_success]
372
377
  )
373
378
  stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
374
379
  flow_values,
375
380
  idx,
376
- nil
381
+ flow[step_id][:on_failure]
377
382
  )
378
383
  stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
379
384
  flow_values,
380
385
  idx,
381
- nil
386
+ flow[step_id][:on_error]
382
387
  )
383
388
  stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::FAIL]
384
389
  stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decouplio
4
+ module Const
5
+ module DobyAideOptions
6
+ ALLOWED = %i[
7
+ on_success
8
+ on_failure
9
+ finish_him
10
+ if
11
+ unless
12
+ ].freeze
13
+ end
14
+ end
15
+ end
@@ -14,7 +14,7 @@ module Decouplio
14
14
  UNLESS_TYPE_FAIL = :unless_fail
15
15
  OCTO_TYPE = :octo
16
16
  DOBY_TYPE = :doby
17
- DENY_TYPE = :deny
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
- DENY_TYPE => RESQ_TYPE_FAIL
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
- DENY_TYPE
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
- DENY_TYPE
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
- DENY_TYPE
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
- DENY_TYPE
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