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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +11 -1
  3. data/.rubocop.yml +6 -0
  4. data/.ruby-version +1 -1
  5. data/README.md +2 -17
  6. data/benchmarks/multi_step_benchmark.rb +11 -10
  7. data/benchmarks/single_step_benchmark.rb +1 -1
  8. data/decouplio.gemspec +4 -4
  9. data/lib/decouplio/action.rb +12 -0
  10. data/lib/decouplio/composer.rb +47 -24
  11. data/lib/decouplio/const/doby_aide_options.rb +16 -0
  12. data/lib/decouplio/const/error_messages.rb +9 -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/execution_error.rb +20 -0
  24. data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
  25. data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
  26. data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
  27. data/lib/decouplio/logic_dsl.rb +23 -8
  28. data/lib/decouplio/options_validator.rb +157 -13
  29. data/lib/decouplio/steps/aide.rb +37 -0
  30. data/lib/decouplio/steps/base_resq.rb +13 -3
  31. data/lib/decouplio/steps/doby.rb +9 -8
  32. data/lib/decouplio/steps/octo.rb +7 -2
  33. data/lib/decouplio/validators/condition.rb +10 -0
  34. data/lib/decouplio/version.rb +1 -1
  35. metadata +24 -42
  36. data/docs/_config.yml +0 -1
  37. data/docs/benchmarks.md +0 -1
  38. data/docs/context.md +0 -74
  39. data/docs/context.rb +0 -62
  40. data/docs/deny.rb +0 -59
  41. data/docs/doby.rb +0 -38
  42. data/docs/doby_deny.md +0 -171
  43. data/docs/error_store.md +0 -347
  44. data/docs/error_store.rb +0 -202
  45. data/docs/fail.md +0 -1159
  46. data/docs/fail.rb +0 -859
  47. data/docs/index.md +0 -25
  48. data/docs/inner_action.md +0 -63
  49. data/docs/inner_action.rb +0 -43
  50. data/docs/logic_block.md +0 -25
  51. data/docs/octo.md +0 -269
  52. data/docs/octo.rb +0 -164
  53. data/docs/pass.md +0 -309
  54. data/docs/pass.rb +0 -213
  55. data/docs/quick_start.md +0 -71
  56. data/docs/quick_start.rb +0 -38
  57. data/docs/resq.md +0 -263
  58. data/docs/resq.rb +0 -176
  59. data/docs/step.md +0 -885
  60. data/docs/step.rb +0 -627
  61. data/docs/step_as_a_service.md +0 -123
  62. data/docs/step_as_a_service.rb +0 -77
  63. data/docs/wrap.md +0 -240
  64. data/docs/wrap.rb +0 -137
  65. data/lib/decouplio/const/validations/deny.rb +0 -11
  66. data/lib/decouplio/steps/deny.rb +0 -31
data/docs/step.rb DELETED
@@ -1,627 +0,0 @@
1
- require_relative '../lib/decouplio'
2
-
3
-
4
-
5
- # Behavior
6
- class SomeAction < Decouplio::Action
7
- logic do
8
- step :step_one
9
- fail :fail_one
10
- step :step_two
11
- end
12
-
13
- def step_one(param_for_step_one:, **)
14
- param_for_step_one
15
- end
16
-
17
- def fail_one(**)
18
- ctx[:action_failed] = true
19
- end
20
-
21
- def step_two(**)
22
- ctx[:result] = 'Success'
23
- end
24
- end
25
-
26
- success_action = SomeAction.call(param_for_step_one: true)
27
- failure_action = SomeAction.call(param_for_step_one: false)
28
-
29
- success_action # =>
30
- # Result: success
31
-
32
- # Railway Flow:
33
- # step_one -> step_two
34
-
35
- # Context:
36
- # {:param_for_step_one=>true, :result=>"Success"}
37
-
38
- # Errors:
39
- # {}
40
-
41
- failure_action # =>
42
- # Result: failure
43
-
44
- # Railway Flow:
45
- # step_one -> fail_one
46
-
47
- # Context:
48
- # {:param_for_step_one=>false, :action_failed=>true}
49
-
50
- # Errors:
51
- # {}
52
-
53
-
54
-
55
- # on_success: :finish_him
56
- class SomeActionOnSuccessFinishHim < Decouplio::Action
57
- logic do
58
- step :step_one, on_success: :finish_him
59
- fail :fail_one
60
- step :step_two
61
- end
62
-
63
- def step_one(param_for_step_one:, **)
64
- param_for_step_one
65
- end
66
-
67
- def fail_one(**)
68
- ctx[:action_failed] = true
69
- end
70
-
71
- def step_two(**)
72
- ctx[:result] = 'Success'
73
- end
74
- end
75
-
76
- success_action = SomeActionOnSuccessFinishHim.call(param_for_step_one: true)
77
- failure_action = SomeActionOnSuccessFinishHim.call(param_for_step_one: false)
78
-
79
- success_action # =>
80
- # Result: success
81
-
82
- # Railway Flow:
83
- # step_one
84
-
85
- # Context:
86
- # {:param_for_step_one=>true}
87
-
88
- # Errors:
89
- # {}
90
-
91
- failure_action # =>
92
- # Result: failure
93
-
94
- # Railway Flow:
95
- # step_one -> fail_one
96
-
97
- # Context:
98
- # {:param_for_step_one=>false, :action_failed=>true}
99
-
100
- # Errors:
101
- # {}
102
-
103
-
104
-
105
- # on_success: next success track step
106
- class SomeActionOnSuccessToSuccessTrack < Decouplio::Action
107
- logic do
108
- step :step_one, on_success: :step_three
109
- fail :fail_one
110
- step :step_two
111
- step :step_three
112
- end
113
-
114
- def step_one(param_for_step_one:, **)
115
- param_for_step_one
116
- end
117
-
118
- def fail_one(**)
119
- ctx[:action_failed] = true
120
- end
121
-
122
- def step_two(**)
123
- ctx[:step_two] = 'Success'
124
- end
125
-
126
- def step_three(**)
127
- ctx[:result] = 'Result'
128
- end
129
- end
130
-
131
- success_action = SomeActionOnSuccessToSuccessTrack.call(param_for_step_one: true)
132
- failure_action = SomeActionOnSuccessToSuccessTrack.call(param_for_step_one: false)
133
- success_action # =>
134
- # Result: success
135
-
136
- # Railway Flow:
137
- # step_one -> step_three
138
-
139
- # Context:
140
- # {:param_for_step_one=>true, :result=>"Result"}
141
-
142
- # Errors:
143
- # {}
144
-
145
-
146
- failure_action # =>
147
- # Result: failure
148
-
149
- # Railway Flow:
150
- # step_one -> fail_one
151
-
152
- # Context:
153
- # {:param_for_step_one=>false, :action_failed=>true}
154
-
155
- # Errors:
156
- # {}
157
-
158
-
159
-
160
- # on_success: next failure track step
161
- class SomeActionOnSuccessToFailureTrack < Decouplio::Action
162
- logic do
163
- step :step_one, on_success: :fail_two
164
- fail :fail_one
165
- step :step_two
166
- step :step_three
167
- fail :fail_two
168
- end
169
-
170
- def step_one(param_for_step_one:, **)
171
- param_for_step_one
172
- end
173
-
174
- def fail_one(**)
175
- ctx[:action_failed] = true
176
- end
177
-
178
- def step_two(**)
179
- ctx[:step_two] = 'Success'
180
- end
181
-
182
- def step_three(**)
183
- ctx[:result] = 'Result'
184
- end
185
-
186
- def fail_two(**)
187
- ctx[:fail_two] = 'Failure'
188
- end
189
- end
190
-
191
- success_action = SomeActionOnSuccessToFailureTrack.call(param_for_step_one: true)
192
- failure_action = SomeActionOnSuccessToFailureTrack.call(param_for_step_one: false)
193
- success_action # =>
194
- # Result: failure
195
-
196
- # Railway Flow:
197
- # step_one -> fail_two
198
-
199
- # Context:
200
- # {:param_for_step_one=>true, :fail_two=>"Failure"}
201
-
202
- # Errors:
203
- # {}
204
-
205
- failure_action # =>
206
- # Result: failure
207
-
208
- # Railway Flow:
209
- # step_one -> fail_one -> fail_two
210
-
211
- # Context:
212
- # {:param_for_step_one=>false, :action_failed=>true, :fail_two=>"Failure"}
213
-
214
- # Errors:
215
- # {}
216
-
217
-
218
-
219
- # on_success: :FAIL
220
-
221
- class SomeActionOnSuccessFail < Decouplio::Action
222
- logic do
223
- step :step_one
224
- step :step_two, on_success: :FAIL
225
- end
226
-
227
- def step_one(**)
228
- ctx[:step_one] = 'Success'
229
- end
230
-
231
- def step_two(step_two_param:, **)
232
- ctx[:step_two] = step_two_param
233
- end
234
- end
235
-
236
- success_action = SomeActionOnSuccessFail.call(step_two_param: true)
237
- failure_action = SomeActionOnSuccessFail.call(step_two_param: false)
238
-
239
- success_action # =>
240
- # Result: failure
241
-
242
- # Railway Flow:
243
- # step_one -> step_two
244
-
245
- # Context:
246
- # :step_two_param => true
247
- # :step_one => "Success"
248
- # :step_two => true
249
-
250
- # Errors:
251
- # {}
252
-
253
- failure_action # =>
254
- # Result: failure
255
-
256
- # Railway Flow:
257
- # step_one -> step_two
258
-
259
- # Context:
260
- # :step_two_param => false
261
- # :step_one => "Success"
262
- # :step_two => false
263
-
264
- # Errors:
265
- # {}
266
-
267
-
268
-
269
- # on_failure: :finish_him
270
- class SomeActionOnFailureFinishHim < Decouplio::Action
271
- logic do
272
- step :step_one, on_failure: :finish_him
273
- fail :fail_one
274
- step :step_two
275
- fail :fail_two
276
- end
277
-
278
- def step_one(param_for_step_one:, **)
279
- param_for_step_one
280
- end
281
-
282
- def fail_one(**)
283
- ctx[:action_failed] = true
284
- end
285
-
286
- def step_two(**)
287
- ctx[:result] = 'Success'
288
- end
289
-
290
- def fail_two(**)
291
- ctx[:fail_two] = 'failure'
292
- end
293
- end
294
-
295
- success_action = SomeActionOnFailureFinishHim.call(param_for_step_one: true)
296
- failure_action = SomeActionOnFailureFinishHim.call(param_for_step_one: false)
297
- success_action # =>
298
- # Result: success
299
-
300
- # Railway Flow:
301
- # step_one -> step_two
302
-
303
- # Context:
304
- # {:param_for_step_one=>true, :result=>"Success"}
305
-
306
- # Errors:
307
- # {}
308
-
309
- failure_action # =>
310
- # Result: failure
311
-
312
- # Railway Flow:
313
- # step_one
314
-
315
- # Context:
316
- # {:param_for_step_one=>false}
317
-
318
- # Errors:
319
- # {}
320
-
321
-
322
-
323
- # on_failure: next success track step
324
- class SomeActionOnFailureToSuccessTrack < Decouplio::Action
325
- logic do
326
- step :step_one, on_failure: :step_three
327
- fail :fail_one
328
- step :step_two
329
- fail :fail_two
330
- step :step_three
331
- end
332
-
333
- def step_one(param_for_step_one:, **)
334
- param_for_step_one
335
- end
336
-
337
- def fail_one(**)
338
- ctx[:action_failed] = true
339
- end
340
-
341
- def step_two(**)
342
- ctx[:result] = 'Success'
343
- end
344
-
345
- def fail_two(**)
346
- ctx[:fail_two] = 'failure'
347
- end
348
-
349
- def step_three(**)
350
- ctx[:step_three] = 'Success'
351
- end
352
- end
353
-
354
- success_action = SomeActionOnFailureToSuccessTrack.call(param_for_step_one: true)
355
- failure_action = SomeActionOnFailureToSuccessTrack.call(param_for_step_one: false)
356
- success_action # =>
357
- # Result: success
358
-
359
- # Railway Flow:
360
- # step_one -> step_two -> step_three
361
-
362
- # Context:
363
- # {:param_for_step_one=>true, :result=>"Success", :step_three=>"Success"}
364
-
365
- # Errors:
366
- # {}
367
-
368
-
369
- failure_action # =>
370
- # Result: success
371
-
372
- # Railway Flow:
373
- # step_one -> step_three
374
-
375
- # Context:
376
- # {:param_for_step_one=>false, :step_three=>"Success"}
377
-
378
- # Errors:
379
- # {}
380
-
381
-
382
-
383
- # on_failure: next failure track step
384
- class SomeActionOnFailureToFailureTrack < Decouplio::Action
385
- logic do
386
- step :step_one, on_failure: :fail_two
387
- fail :fail_one
388
- step :step_two
389
- fail :fail_two
390
- step :step_three
391
- end
392
-
393
- def step_one(param_for_step_one:, **)
394
- param_for_step_one
395
- end
396
-
397
- def fail_one(**)
398
- ctx[:action_failed] = true
399
- end
400
-
401
- def step_two(**)
402
- ctx[:result] = 'Success'
403
- end
404
-
405
- def fail_two(**)
406
- ctx[:fail_two] = 'failure'
407
- end
408
-
409
- def step_three(**)
410
- ctx[:step_three] = 'Success'
411
- end
412
- end
413
-
414
- success_action = SomeActionOnFailureToFailureTrack.call(param_for_step_one: true)
415
- failure_action = SomeActionOnFailureToFailureTrack.call(param_for_step_one: false)
416
- success_action # =>
417
- # Result: success
418
-
419
- # Railway Flow:
420
- # step_one -> step_two -> step_three
421
-
422
- # Context:
423
- # {:param_for_step_one=>true, :result=>"Success", :step_three=>"Success"}
424
-
425
- # Errors:
426
- # {}
427
-
428
- failure_action # =>
429
- # Result: failure
430
-
431
- # Railway Flow:
432
- # step_one -> fail_two
433
-
434
- # Context:
435
- # {:param_for_step_one=>false, :fail_two=>"failure"}
436
-
437
- # Errors:
438
- # {}
439
-
440
-
441
-
442
- # on_failure: :PASS
443
- class SomeActionOnFailurePass < Decouplio::Action
444
- logic do
445
- step :step_one
446
- step :step_two, on_failure: :PASS
447
- end
448
-
449
- def step_one(**)
450
- ctx[:step_one] = true
451
- end
452
-
453
- def step_two(step_two_param:, **)
454
- ctx[:step_two] = step_two_param
455
- end
456
- end
457
-
458
-
459
- success_action = SomeActionOnFailurePass.call(step_two_param: true)
460
- failure_action = SomeActionOnFailurePass.call(step_two_param: false)
461
-
462
- success_action # =>
463
- # Result: success
464
-
465
- # Railway Flow:
466
- # step_one -> step_two
467
-
468
- # Context:
469
- # :step_two_param => true
470
- # :step_one => true
471
- # :step_two => true
472
-
473
- # Errors:
474
- # {}
475
-
476
- failure_action # =>
477
- # Result: success
478
-
479
- # Railway Flow:
480
- # step_one -> step_two
481
-
482
- # Context:
483
- # :step_two_param => false
484
- # :step_one => true
485
- # :step_two => false
486
-
487
- # Errors:
488
- # {}
489
-
490
-
491
-
492
-
493
- # if: condition method name
494
- class SomeActionOnIfCondition < Decouplio::Action
495
- logic do
496
- step :step_one
497
- fail :fail_one
498
- step :step_two
499
- fail :fail_two
500
- step :step_three, if: :step_condition?
501
- end
502
-
503
- def step_one(param_for_step_one:, **)
504
- param_for_step_one
505
- end
506
-
507
- def fail_one(**)
508
- ctx[:action_failed] = true
509
- end
510
-
511
- def step_two(**)
512
- ctx[:result] = 'Success'
513
- end
514
-
515
- def fail_two(**)
516
- ctx[:fail_two] = 'failure'
517
- end
518
-
519
- def step_three(**)
520
- ctx[:step_three] = 'Success'
521
- end
522
-
523
- def step_condition?(step_condition_param:, **)
524
- step_condition_param
525
- end
526
- end
527
-
528
- condition_positive = SomeActionOnIfCondition.call(
529
- param_for_step_one: true,
530
- step_condition_param: true
531
- )
532
- condition_negative = SomeActionOnIfCondition.call(
533
- param_for_step_one: true,
534
- step_condition_param: false
535
- )
536
- condition_positive # =>
537
- # Result: success
538
-
539
- # Railway Flow:
540
- # step_one -> step_two -> step_three
541
-
542
- # Context:
543
- # {:param_for_step_one=>true, :step_condition_param=>true, :result=>"Success", :step_three=>"Success"}
544
-
545
- # Errors:
546
- # {}
547
-
548
- condition_negative # =>
549
- # Result: success
550
-
551
- # Railway Flow:
552
- # step_one -> step_two
553
-
554
- # Context:
555
- # {:param_for_step_one=>true, :step_condition_param=>false, :result=>"Success"}
556
-
557
- # Errors:
558
- # {}
559
-
560
-
561
-
562
- # unless: condition method name
563
- class SomeActionOnUnlessCondition < Decouplio::Action
564
- logic do
565
- step :step_one
566
- fail :fail_one
567
- step :step_two
568
- fail :fail_two
569
- step :step_three, unless: :step_condition?
570
- end
571
-
572
- def step_one(param_for_step_one:, **)
573
- param_for_step_one
574
- end
575
-
576
- def fail_one(**)
577
- ctx[:action_failed] = true
578
- end
579
-
580
- def step_two(**)
581
- ctx[:result] = 'Success'
582
- end
583
-
584
- def fail_two(**)
585
- ctx[:fail_two] = 'failure'
586
- end
587
-
588
- def step_three(**)
589
- ctx[:step_three] = 'Success'
590
- end
591
-
592
- def step_condition?(step_condition_param:, **)
593
- step_condition_param
594
- end
595
- end
596
-
597
- condition_positive = SomeActionOnUnlessCondition.call(
598
- param_for_step_one: true,
599
- step_condition_param: true
600
- )
601
- condition_negative = SomeActionOnUnlessCondition.call(
602
- param_for_step_one: true,
603
- step_condition_param: false
604
- )
605
- condition_positive # =>
606
- # Result: success
607
-
608
- # Railway Flow:
609
- # step_one -> step_two
610
-
611
- # Context:
612
- # {:param_for_step_one=>true, :step_condition_param=>true, :result=>"Success"}
613
-
614
- # Errors:
615
- # {}
616
-
617
- condition_negative # =>
618
- # Result: success
619
-
620
- # Railway Flow:
621
- # step_one -> step_two -> step_three
622
-
623
- # Context:
624
- # {:param_for_step_one=>true, :step_condition_param=>false, :result=>"Success", :step_three=>"Success"}
625
-
626
- # Errors:
627
- # {}