decouplio 1.0.0alpha1 → 1.0.0alpha4

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +11 -1
  3. data/.rubocop.yml +7 -0
  4. data/README.md +12 -3
  5. data/benchmarks/Gemfile +2 -1
  6. data/benchmarks/multi_step_benchmark.rb +336 -0
  7. data/benchmarks/single_step_benchmark.rb +159 -0
  8. data/decouplio.gemspec +4 -4
  9. data/docker-compose.yml +13 -2
  10. data/lib/decouplio/action.rb +34 -3
  11. data/lib/decouplio/composer.rb +111 -22
  12. data/lib/decouplio/const/doby_aide_options.rb +15 -0
  13. data/lib/decouplio/const/error_messages.rb +9 -0
  14. data/lib/decouplio/const/reserved_methods.rb +13 -9
  15. data/lib/decouplio/const/results.rb +2 -0
  16. data/lib/decouplio/const/types.rb +19 -5
  17. data/lib/decouplio/const/validations/aide.rb +38 -0
  18. data/lib/decouplio/const/validations/doby.rb +36 -0
  19. data/lib/decouplio/const/validations/fail.rb +5 -1
  20. data/lib/decouplio/const/validations/octo.rb +2 -1
  21. data/lib/decouplio/errors/aide_can_not_be_first_step_error.rb +18 -0
  22. data/lib/decouplio/errors/aide_controversial_keys_error.rb +26 -0
  23. data/lib/decouplio/errors/aide_finish_him_error.rb +26 -0
  24. data/lib/decouplio/errors/doby_controversial_keys_error.rb +26 -0
  25. data/lib/decouplio/errors/doby_finish_him_error.rb +26 -0
  26. data/lib/decouplio/errors/execution_error.rb +20 -0
  27. data/lib/decouplio/errors/{fail_is_first_step_error.rb → fail_can_not_be_first_step_error.rb} +1 -1
  28. data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +26 -0
  29. data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +27 -0
  30. data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
  31. data/lib/decouplio/logic_dsl.rb +30 -3
  32. data/lib/decouplio/options_validator.rb +162 -13
  33. data/lib/decouplio/steps/aide.rb +37 -0
  34. data/lib/decouplio/steps/base_resq.rb +13 -3
  35. data/lib/decouplio/steps/doby.rb +14 -9
  36. data/lib/decouplio/steps/fail.rb +7 -22
  37. data/lib/decouplio/steps/inner_action_fail.rb +7 -22
  38. data/lib/decouplio/steps/inner_action_step.rb +7 -18
  39. data/lib/decouplio/steps/octo.rb +7 -2
  40. data/lib/decouplio/steps/service_fail.rb +11 -23
  41. data/lib/decouplio/steps/service_pass.rb +4 -1
  42. data/lib/decouplio/steps/service_step.rb +11 -19
  43. data/lib/decouplio/steps/shared/fail_resolver.rb +40 -0
  44. data/lib/decouplio/steps/shared/step_resolver.rb +43 -0
  45. data/lib/decouplio/steps/step.rb +7 -18
  46. data/lib/decouplio/steps/wrap.rb +7 -18
  47. data/lib/decouplio/validators/condition.rb +10 -0
  48. data/lib/decouplio/version.rb +1 -1
  49. metadata +30 -41
  50. data/benchmarks/benchmarks.rb +0 -527
  51. data/docs/_config.yml +0 -1
  52. data/docs/benchmarks.md +0 -1
  53. data/docs/context.md +0 -74
  54. data/docs/context.rb +0 -62
  55. data/docs/doby.md +0 -80
  56. data/docs/doby.rb +0 -38
  57. data/docs/error_store.md +0 -347
  58. data/docs/error_store.rb +0 -202
  59. data/docs/fail.md +0 -1016
  60. data/docs/fail.rb +0 -762
  61. data/docs/index.md +0 -25
  62. data/docs/inner_action.md +0 -63
  63. data/docs/inner_action.rb +0 -43
  64. data/docs/logic_block.md +0 -25
  65. data/docs/octo.md +0 -269
  66. data/docs/octo.rb +0 -164
  67. data/docs/pass.md +0 -309
  68. data/docs/pass.rb +0 -213
  69. data/docs/quick_start.md +0 -71
  70. data/docs/quick_start.rb +0 -38
  71. data/docs/resq.md +0 -263
  72. data/docs/resq.rb +0 -176
  73. data/docs/step.md +0 -737
  74. data/docs/step.rb +0 -526
  75. data/docs/step_as_a_service.md +0 -109
  76. data/docs/step_as_a_service.rb +0 -77
  77. data/docs/wrap.md +0 -232
  78. data/docs/wrap.rb +0 -137
@@ -21,6 +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/aide'
24
25
  require_relative 'options_validator'
25
26
  require_relative 'validators/condition'
26
27
 
@@ -129,7 +130,9 @@ module Decouplio
129
130
  when Decouplio::Const::Types::SERVICE_TYPE_PASS
130
131
  create_inner_service_pass(stp, flow)
131
132
  when Decouplio::Const::Types::DOBY_TYPE
132
- create_doby(stp)
133
+ create_doby(stp, flow)
134
+ when Decouplio::Const::Types::AIDE_TYPE
135
+ create_aide(stp, flow)
133
136
  end
134
137
  end
135
138
 
@@ -183,7 +186,8 @@ module Decouplio
183
186
  def create_octo(stp)
184
187
  Decouplio::Steps::Octo.new(
185
188
  name: stp[:name],
186
- ctx_key: stp[:ctx_key]
189
+ ctx_key: stp[:ctx_key],
190
+ method: stp[:method]
187
191
  )
188
192
  end
189
193
 
@@ -201,14 +205,16 @@ module Decouplio
201
205
  def create_resq_pass(stp, flow)
202
206
  Decouplio::Steps::ResqPass.new(
203
207
  handler_hash: stp[:handler_hash],
204
- 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)
205
210
  )
206
211
  end
207
212
 
208
213
  def create_resq_fail(stp, flow)
209
214
  Decouplio::Steps::ResqFail.new(
210
215
  handler_hash: stp[:handler_hash],
211
- 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)
212
218
  )
213
219
  end
214
220
 
@@ -266,11 +272,23 @@ module Decouplio
266
272
  )
267
273
  end
268
274
 
269
- def create_doby(stp)
275
+ def create_doby(stp, flow)
270
276
  Decouplio::Steps::Doby.new(
271
277
  name: stp[:name],
272
278
  doby_class: stp[:doby_class],
273
- 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)
282
+ )
283
+ end
284
+
285
+ def create_aide(stp, flow)
286
+ Decouplio::Steps::Aide.new(
287
+ name: stp[:name],
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)
274
292
  )
275
293
  end
276
294
 
@@ -294,6 +312,8 @@ module Decouplio
294
312
  compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
295
313
  when Decouplio::Const::Types::DOBY_TYPE
296
314
  compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
315
+ when Decouplio::Const::Types::AIDE_TYPE
316
+ compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
297
317
  when Decouplio::Const::Types::IF_TYPE_PASS, Decouplio::Const::Types::UNLESS_TYPE_PASS
298
318
  compose_pass_condition_flow(stp, flow, idx, flow_hash)
299
319
  when Decouplio::Const::Types::IF_TYPE_FAIL, Decouplio::Const::Types::UNLESS_TYPE_FAIL
@@ -327,22 +347,22 @@ module Decouplio
327
347
  stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
328
348
  end
329
349
 
330
- def compose_doby_flow(stp, _step_id, flow, idx, flow_hash, next_steps)
350
+ def compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
331
351
  flow_values = flow.values + (next_steps&.values || [])
332
352
  stp[:flow][Decouplio::Const::Results::PASS] = next_success_step(
333
353
  flow_values,
334
354
  idx,
335
- nil
355
+ flow[step_id][:on_success]
336
356
  )
337
357
  stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
338
358
  flow_values,
339
359
  idx,
340
- nil
360
+ flow[step_id][:on_failure]
341
361
  )
342
362
  stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
343
363
  flow_values,
344
364
  idx,
345
- nil
365
+ flow[step_id][:on_error]
346
366
  )
347
367
  stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::PASS]
348
368
  stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
@@ -350,6 +370,29 @@ module Decouplio
350
370
  stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
351
371
  end
352
372
 
373
+ def compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
374
+ flow_values = flow.values + (next_steps&.values || [])
375
+ stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
376
+ flow_values,
377
+ idx,
378
+ flow[step_id][:on_success]
379
+ )
380
+ stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
381
+ flow_values,
382
+ idx,
383
+ flow[step_id][:on_failure]
384
+ )
385
+ stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
386
+ flow_values,
387
+ idx,
388
+ flow[step_id][:on_error]
389
+ )
390
+ stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::FAIL]
391
+ stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
392
+ stp[:flow][Decouplio::Const::Results::ERROR] ||= flow_hash[Decouplio::Const::Results::ERROR]
393
+ stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
394
+ end
395
+
353
396
  def compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
354
397
  flow_values = flow.values + (next_steps&.values || [])
355
398
  stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
@@ -409,18 +452,45 @@ module Decouplio
409
452
  return :finish_him if [:on_success, true].include?(finish_him(stp))
410
453
 
411
454
  step_id = stp.dig(:flow, Decouplio::Const::Results::PASS)
412
- Decouplio::Const::Types::PASS_FLOW.include?(
413
- flow[step_id]&.[](:type)
414
- )
455
+ if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_success]
456
+ Decouplio::Const::Results::STEP_PASS
457
+ elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_success]
458
+ Decouplio::Const::Results::STEP_FAIL
459
+ else
460
+ Decouplio::Const::Types::PASS_FLOW.include?(
461
+ flow[step_id]&.[](:type)
462
+ )
463
+ end
415
464
  end
416
465
 
417
466
  def failure_type(flow, stp)
418
467
  return :finish_him if [:on_failure, true].include?(finish_him(stp))
419
468
 
420
469
  step_id = stp.dig(:flow, Decouplio::Const::Results::FAIL)
421
- Decouplio::Const::Types::FAIL_FLOW.include?(
422
- flow[step_id]&.[](:type)
423
- )
470
+ if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_failure]
471
+ Decouplio::Const::Results::STEP_PASS
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]
488
+ Decouplio::Const::Results::STEP_FAIL
489
+ else
490
+ Decouplio::Const::Types::FAIL_FLOW.include?(
491
+ flow[step_id]&.[](:type)
492
+ )
493
+ end
424
494
  end
425
495
 
426
496
  def finish_him(stp)
@@ -523,6 +593,7 @@ module Decouplio
523
593
  options_for_resq = stp[:step_to_resq].slice(
524
594
  :on_success,
525
595
  :on_failure,
596
+ :on_error,
526
597
  :finish_him,
527
598
  :if,
528
599
  :unless
@@ -543,7 +614,18 @@ module Decouplio
543
614
  def next_success_step(steps, idx, value)
544
615
  steps_slice = steps[(idx + 1)..]
545
616
  steps_slice.each_with_index do |stp, index|
546
- if value == stp[:name]
617
+ if (
618
+ Decouplio::Const::Results::STEP_PASS == value &&
619
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
620
+ ) || (
621
+ Decouplio::Const::Results::STEP_FAIL == value &&
622
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
623
+ ) || (
624
+ !value &&
625
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
626
+ )
627
+ return stp[:step_id]
628
+ elsif value == stp[:name]
547
629
  prev_step = steps_slice[index - 1]
548
630
  if [
549
631
  Decouplio::Const::Types::IF_TYPE_PASS,
@@ -553,8 +635,6 @@ module Decouplio
553
635
  else
554
636
  return stp[:step_id]
555
637
  end
556
- elsif !value && Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
557
- return stp[:step_id]
558
638
  end
559
639
  end
560
640
 
@@ -564,7 +644,18 @@ module Decouplio
564
644
  def next_failure_step(steps, idx, value)
565
645
  steps_slice = steps[(idx + 1)..]
566
646
  steps_slice.each_with_index do |stp, index|
567
- if value == stp[:name]
647
+ if (
648
+ Decouplio::Const::Results::STEP_PASS == value &&
649
+ Decouplio::Const::Types::SUCCESS_TRACK_STEP_TYPES.include?(stp[:type])
650
+ ) || (
651
+ Decouplio::Const::Results::STEP_FAIL == value &&
652
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
653
+ ) || (
654
+ !value &&
655
+ Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
656
+ )
657
+ return stp[:step_id]
658
+ elsif value == stp[:name]
568
659
  prev_step = steps_slice[index - 1]
569
660
  if [
570
661
  Decouplio::Const::Types::IF_TYPE_FAIL,
@@ -574,8 +665,6 @@ module Decouplio
574
665
  else
575
666
  return stp[:step_id]
576
667
  end
577
- elsif !value && Decouplio::Const::Types::FAILURE_TRACK_STEP_TYPES.include?(stp[:type])
578
- return stp[:step_id]
579
668
  end
580
669
  end
581
670
 
@@ -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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decouplio
4
+ module Const
5
+ module ErrorMessages
6
+ EXECUTION_ERROR = 'Action failed.'
7
+ end
8
+ end
9
+ end
@@ -1,17 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'results'
4
+
3
5
  module Decouplio
4
6
  module Const
5
7
  module ReservedMethods
6
- NAMES = %i[
7
- []
8
- success?
9
- failure?
10
- fail_action
11
- pass_action
12
- append_railway_flow
13
- inspect
14
- to_s
8
+ NAMES = [
9
+ :[],
10
+ :success?,
11
+ :failure?,
12
+ :fail_action,
13
+ :pass_action,
14
+ :append_railway_flow,
15
+ :inspect,
16
+ :to_s,
17
+ Decouplio::Const::Results::STEP_PASS,
18
+ Decouplio::Const::Results::STEP_FAIL
15
19
  ].freeze
16
20
  end
17
21
  end
@@ -8,6 +8,8 @@ module Decouplio
8
8
  ERROR = :error
9
9
  FINISH_HIM = :finish_him
10
10
  NO_STEP = nil
11
+ STEP_PASS = :PASS
12
+ STEP_FAIL = :FAIL
11
13
  end
12
14
  end
13
15
  end
@@ -14,6 +14,7 @@ module Decouplio
14
14
  UNLESS_TYPE_FAIL = :unless_fail
15
15
  OCTO_TYPE = :octo
16
16
  DOBY_TYPE = :doby
17
+ AIDE_TYPE = :aide
17
18
  ACTION_TYPE_STEP = :action_step
18
19
  ACTION_TYPE_FAIL = :action_fail
19
20
  ACTION_TYPE_PASS = :action_pass
@@ -81,6 +82,14 @@ module Decouplio
81
82
  SERVICE_TYPE_PASS => {
82
83
  IF_TYPE => IF_TYPE_PASS,
83
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
84
93
  }
85
94
  }.freeze
86
95
  STEP_TYPE_TO_RESQ_TYPE = {
@@ -93,7 +102,8 @@ module Decouplio
93
102
  UNLESS_TYPE_PASS => RESQ_TYPE_STEP,
94
103
  IF_TYPE_FAIL => RESQ_TYPE_FAIL,
95
104
  UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL,
96
- DOBY_TYPE => RESQ_TYPE_STEP
105
+ DOBY_TYPE => RESQ_TYPE_STEP,
106
+ AIDE_TYPE => RESQ_TYPE_FAIL
97
107
  }.freeze
98
108
  STEP_TYPE_TO_INNER_TYPE = {
99
109
  STEP_TYPE => ACTION_TYPE_STEP,
@@ -115,7 +125,8 @@ module Decouplio
115
125
  OCTO_TYPE,
116
126
  WRAP_TYPE,
117
127
  RESQ_TYPE,
118
- DOBY_TYPE
128
+ DOBY_TYPE,
129
+ AIDE_TYPE
119
130
  ].freeze
120
131
  PASS_FLOW = [
121
132
  STEP_TYPE,
@@ -135,7 +146,8 @@ module Decouplio
135
146
  IF_TYPE_FAIL,
136
147
  UNLESS_TYPE_FAIL,
137
148
  ACTION_TYPE_FAIL,
138
- SERVICE_TYPE_FAIL
149
+ SERVICE_TYPE_FAIL,
150
+ AIDE_TYPE
139
151
  ].freeze
140
152
 
141
153
  MAIN_FLOW_TYPES = [
@@ -143,7 +155,8 @@ module Decouplio
143
155
  FAIL_TYPE,
144
156
  PASS_TYPE,
145
157
  WRAP_TYPE,
146
- DOBY_TYPE
158
+ DOBY_TYPE,
159
+ AIDE_TYPE
147
160
  ].freeze
148
161
  SUCCESS_TRACK_STEP_TYPES = [
149
162
  STEP_TYPE,
@@ -166,7 +179,8 @@ module Decouplio
166
179
  UNLESS_TYPE_FAIL,
167
180
  RESQ_TYPE_FAIL,
168
181
  ACTION_TYPE_FAIL,
169
- SERVICE_TYPE_FAIL
182
+ SERVICE_TYPE_FAIL,
183
+ AIDE_TYPE
170
184
  ].freeze
171
185
  end
172
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>
@@ -27,7 +31,7 @@ module Decouplio
27
31
  OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "fail"'
28
32
  METHOD_NOT_DEFINED = 'fail :%s'
29
33
  CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
30
- FIRST_STEP = '"fail" can not be first step'
34
+ FIRST_STEP = '"fail" can not be the first step'
31
35
  end
32
36
  end
33
37
  end
@@ -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
@@ -0,0 +1,18 @@
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 AideCanNotBeFirstStepError < Decouplio::Errors::BaseError
9
+ def template
10
+ Decouplio::Const::Validations::Aide::FIRST_STEP
11
+ end
12
+
13
+ def interpolation_values
14
+ []
15
+ end
16
+ end
17
+ end
18
+ 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 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
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_error'
4
+ require_relative '../const/validations/doby'
5
+
6
+ module Decouplio
7
+ module Errors
8
+ class DobyControversialKeysError < Decouplio::Errors::BaseError
9
+ def template
10
+ Decouplio::Const::Validations::Doby::VALIDATION_ERROR_MESSAGE
11
+ end
12
+
13
+ def interpolation_values
14
+ [
15
+ @errored_option,
16
+ format(
17
+ Decouplio::Const::Validations::Doby::CONTROVERSIAL_KEYS,
18
+ *@details
19
+ ),
20
+ Decouplio::Const::Validations::Doby::ALLOWED_OPTIONS_MESSAGE,
21
+ Decouplio::Const::Validations::Doby::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/doby'
5
+
6
+ module Decouplio
7
+ module Errors
8
+ class DobyFinishHimError < Decouplio::Errors::BaseError
9
+ def template
10
+ Decouplio::Const::Validations::Doby::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::Doby::ALLOWED_OPTIONS_MESSAGE,
21
+ Decouplio::Const::Validations::Doby::MANUAL_URL
22
+ ]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../const/error_messages'
4
+
5
+ module Decouplio
6
+ module Errors
7
+ class ExecutionError < StandardError
8
+ attr_reader :action
9
+
10
+ def initialize(action:)
11
+ @action = action
12
+ super(message)
13
+ end
14
+
15
+ def message
16
+ Decouplio::Const::ErrorMessages::EXECUTION_ERROR
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ require_relative '../const/validations/fail'
5
5
 
6
6
  module Decouplio
7
7
  module Errors
8
- class FailCanNotBeTheFirstStepError < Decouplio::Errors::BaseError
8
+ class FailCanNotBeFirstStepError < Decouplio::Errors::BaseError
9
9
  def template
10
10
  Decouplio::Const::Validations::Fail::FIRST_STEP
11
11
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_error'
4
+ require_relative '../const/validations/fail'
5
+
6
+ module Decouplio
7
+ module Errors
8
+ class StepIsNotDefinedForAideError < 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::STEP_IS_NOT_DEFINED,
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