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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/benchmarks/multi_step_benchmark.rb +11 -10
- data/benchmarks/single_step_benchmark.rb +1 -1
- data/docs/{deny.rb → aide.rb} +3 -3
- data/docs/{doby_deny.md → doby_aide.md} +49 -12
- data/docs/index.md +1 -1
- data/docs/logic_block.md +4 -0
- data/docs/octo.md +59 -2
- data/docs/quick_start.md +1 -1
- data/lib/decouplio/composer.rb +26 -21
- data/lib/decouplio/const/doby_aide_options.rb +15 -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/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/logic_dsl.rb +23 -8
- data/lib/decouplio/options_validator.rb +114 -5
- data/lib/decouplio/steps/aide.rb +37 -0
- 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 +15 -7
- data/lib/decouplio/const/validations/deny.rb +0 -11
- data/lib/decouplio/steps/deny.rb +0 -31
@@ -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
|
@@ -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,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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/doby'
|
5
|
+
require_relative '../const/validations/common'
|
6
|
+
|
7
|
+
module Decouplio
|
8
|
+
module Errors
|
9
|
+
class StepIsNotDefinedForDobyError < Decouplio::Errors::BaseError
|
10
|
+
def template
|
11
|
+
Decouplio::Const::Validations::Doby::VALIDATION_ERROR_MESSAGE
|
12
|
+
end
|
13
|
+
|
14
|
+
def interpolation_values
|
15
|
+
[
|
16
|
+
@errored_option,
|
17
|
+
format(
|
18
|
+
Decouplio::Const::Validations::Common::STEP_IS_NOT_DEFINED,
|
19
|
+
@details
|
20
|
+
),
|
21
|
+
Decouplio::Const::Validations::Doby::ALLOWED_OPTIONS_MESSAGE,
|
22
|
+
Decouplio::Const::Validations::Doby::MANUAL_URL
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/decouplio/logic_dsl.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'flow'
|
4
4
|
require_relative 'const/types'
|
5
|
+
require_relative 'const/doby_aide_options'
|
5
6
|
require_relative 'octo_hash_case'
|
6
7
|
require_relative 'errors/options_validation_error'
|
7
8
|
require_relative 'errors/palp_validation_error'
|
@@ -9,7 +10,7 @@ require_relative 'errors/resq_definition_error'
|
|
9
10
|
require_relative 'errors/wrap_block_is_not_defined_error'
|
10
11
|
require_relative 'errors/palp_block_is_not_defined_error'
|
11
12
|
require_relative 'errors/fail_can_not_be_first_step_error'
|
12
|
-
require_relative 'errors/
|
13
|
+
require_relative 'errors/aide_can_not_be_first_step_error'
|
13
14
|
require_relative 'errors/octo_block_is_not_defined_error'
|
14
15
|
|
15
16
|
module Decouplio
|
@@ -85,22 +86,36 @@ module Decouplio
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def doby(doby_class, **options)
|
89
|
+
step_options = {}
|
90
|
+
options.each_key do |key|
|
91
|
+
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
92
|
+
end
|
93
|
+
doby_options = options
|
94
|
+
|
88
95
|
@steps << {
|
89
96
|
type: Decouplio::Const::Types::DOBY_TYPE,
|
90
97
|
name: doby_class.name.to_sym,
|
91
98
|
doby_class: doby_class,
|
92
|
-
doby_options:
|
99
|
+
doby_options: doby_options,
|
100
|
+
**step_options
|
93
101
|
}
|
94
102
|
end
|
95
103
|
|
96
|
-
def
|
97
|
-
raise Decouplio::Errors::
|
104
|
+
def aide(aide_class, **options)
|
105
|
+
raise Decouplio::Errors::AideCanNotBeFirstStepError if @steps.empty?
|
106
|
+
|
107
|
+
step_options = {}
|
108
|
+
options.each_key do |key|
|
109
|
+
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
110
|
+
end
|
111
|
+
aide_options = options
|
98
112
|
|
99
113
|
@steps << {
|
100
|
-
type: Decouplio::Const::Types::
|
101
|
-
name:
|
102
|
-
|
103
|
-
|
114
|
+
type: Decouplio::Const::Types::AIDE_TYPE,
|
115
|
+
name: aide_class.name.to_sym,
|
116
|
+
aide_class: aide_class,
|
117
|
+
aide_options: aide_options,
|
118
|
+
**step_options
|
104
119
|
}
|
105
120
|
end
|
106
121
|
end
|
@@ -10,6 +10,8 @@ require_relative 'errors/extra_key_for_pass_error'
|
|
10
10
|
require_relative 'errors/extra_key_for_resq_error'
|
11
11
|
require_relative 'errors/extra_key_for_wrap_error'
|
12
12
|
require_relative 'errors/fail_finish_him_error'
|
13
|
+
require_relative 'errors/doby_finish_him_error'
|
14
|
+
require_relative 'errors/aide_finish_him_error'
|
13
15
|
require_relative 'errors/invalid_error_class_error'
|
14
16
|
require_relative 'errors/invalid_wrap_name_error'
|
15
17
|
require_relative 'errors/pass_finish_him_error'
|
@@ -20,9 +22,13 @@ require_relative 'errors/step_finish_him_error'
|
|
20
22
|
require_relative 'errors/step_is_not_defined_for_step_error'
|
21
23
|
require_relative 'errors/step_is_not_defined_for_fail_error'
|
22
24
|
require_relative 'errors/step_is_not_defined_for_wrap_error'
|
25
|
+
require_relative 'errors/step_is_not_defined_for_aide_error'
|
26
|
+
require_relative 'errors/step_is_not_defined_for_doby_error'
|
23
27
|
require_relative 'errors/wrap_finish_him_error'
|
24
28
|
require_relative 'errors/wrap_klass_method_error'
|
25
29
|
require_relative 'errors/step_controversial_keys_error'
|
30
|
+
require_relative 'errors/doby_controversial_keys_error'
|
31
|
+
require_relative 'errors/aide_controversial_keys_error'
|
26
32
|
require_relative 'errors/fail_controversial_keys_error'
|
27
33
|
require_relative 'errors/pass_controversial_keys_error'
|
28
34
|
require_relative 'errors/octo_controversial_keys_error'
|
@@ -86,6 +92,10 @@ module Decouplio
|
|
86
92
|
Decouplio::Const::Types::RESQ_TYPE_PASS
|
87
93
|
validate(options: options[:step_to_resq], step_names: step_names)
|
88
94
|
validate_resq(options: filtered_options)
|
95
|
+
when Decouplio::Const::Types::DOBY_TYPE
|
96
|
+
validate_doby(options: filtered_options, step_names: step_names)
|
97
|
+
when Decouplio::Const::Types::AIDE_TYPE
|
98
|
+
validate_aide(options: filtered_options, step_names: step_names)
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
@@ -142,6 +152,18 @@ module Decouplio
|
|
142
152
|
check_resq_exception_classes_inheritance(options: options)
|
143
153
|
end
|
144
154
|
|
155
|
+
def validate_doby(options:, step_names:)
|
156
|
+
check_step_presence_for_doby(options: options, step_names: step_names)
|
157
|
+
check_doby_controversial_keys(options: options)
|
158
|
+
check_doby_finish_him(options: options)
|
159
|
+
end
|
160
|
+
|
161
|
+
def validate_aide(options:, step_names:)
|
162
|
+
check_step_presence_for_aide(options: options, step_names: step_names)
|
163
|
+
check_aide_controversial_keys(options: options)
|
164
|
+
check_aide_finish_him(options: options)
|
165
|
+
end
|
166
|
+
|
145
167
|
def validate_name(name:)
|
146
168
|
return unless Decouplio::Const::ReservedMethods::NAMES.include?(name)
|
147
169
|
|
@@ -163,6 +185,32 @@ module Decouplio
|
|
163
185
|
end
|
164
186
|
end
|
165
187
|
|
188
|
+
def check_step_presence_for_doby(options:, step_names:)
|
189
|
+
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
190
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
191
|
+
|
192
|
+
next if step_names.keys.include?(option_value)
|
193
|
+
|
194
|
+
raise Decouplio::Errors::StepIsNotDefinedForDobyError.new(
|
195
|
+
errored_option: options.slice(option_key).to_s,
|
196
|
+
details: option_value
|
197
|
+
)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def check_step_presence_for_aide(options:, step_names:)
|
202
|
+
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
203
|
+
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
204
|
+
|
205
|
+
next if step_names.keys.include?(option_value)
|
206
|
+
|
207
|
+
raise Decouplio::Errors::StepIsNotDefinedForAideError.new(
|
208
|
+
errored_option: options.slice(option_key).to_s,
|
209
|
+
details: option_value
|
210
|
+
)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
166
214
|
def check_step_presence_for_fail(options:, step_names:)
|
167
215
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
168
216
|
next if %i[on_success on_failure].include?(option_key) && STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
@@ -211,6 +259,30 @@ module Decouplio
|
|
211
259
|
end
|
212
260
|
end
|
213
261
|
|
262
|
+
def check_doby_controversial_keys(options:)
|
263
|
+
on_success_on_failure = options.slice(:on_success, :on_failure)
|
264
|
+
finish_him = options.slice(:finish_him)
|
265
|
+
|
266
|
+
if !on_success_on_failure.empty? && !finish_him.empty?
|
267
|
+
raise Decouplio::Errors::DobyControversialKeysError.new(
|
268
|
+
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
269
|
+
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
270
|
+
)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def check_aide_controversial_keys(options:)
|
275
|
+
on_success_on_failure = options.slice(:on_success, :on_failure)
|
276
|
+
finish_him = options.slice(:finish_him)
|
277
|
+
|
278
|
+
if !on_success_on_failure.empty? && !finish_him.empty?
|
279
|
+
raise Decouplio::Errors::AideControversialKeysError.new(
|
280
|
+
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
281
|
+
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
282
|
+
)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
214
286
|
def validate_error_store(parent_action_class:, child_action_class:)
|
215
287
|
return if parent_action_class.error_store == child_action_class.error_store
|
216
288
|
|
@@ -304,11 +376,20 @@ module Decouplio
|
|
304
376
|
end
|
305
377
|
|
306
378
|
def check_octo_required_keys(options:)
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
379
|
+
if (OCTO_REQUIRED_KEYS - options.keys).size.zero?
|
380
|
+
if options.keys.sort == OCTO_REQUIRED_KEYS.sort
|
381
|
+
raise Decouplio::Errors::OctoControversialKeysError.new(
|
382
|
+
errored_option: options.slice(*OCTO_REQUIRED_KEYS),
|
383
|
+
details: OCTO_REQUIRED_KEYS
|
384
|
+
)
|
385
|
+
end
|
386
|
+
else
|
387
|
+
return if options.slice(*OCTO_REQUIRED_KEYS).size == 1
|
388
|
+
|
389
|
+
raise Decouplio::Errors::RequiredOptionsIsMissingForOctoError.new(
|
390
|
+
details: OCTO_REQUIRED_KEYS.join(', ')
|
391
|
+
)
|
392
|
+
end
|
312
393
|
end
|
313
394
|
|
314
395
|
def check_step_finish_him(options:)
|
@@ -324,6 +405,32 @@ module Decouplio
|
|
324
405
|
end
|
325
406
|
end
|
326
407
|
|
408
|
+
def check_doby_finish_him(options:)
|
409
|
+
finish_him_value = options.dig(:finish_him)
|
410
|
+
|
411
|
+
return unless finish_him_value && options.key?(:finish_him)
|
412
|
+
|
413
|
+
unless ALLOWED_STEP_FINISH_HIM_VALUES.include?(finish_him_value)
|
414
|
+
raise Decouplio::Errors::DobyFinishHimError.new(
|
415
|
+
errored_option: options.slice(:finish_him).to_s,
|
416
|
+
details: finish_him_value
|
417
|
+
)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
def check_aide_finish_him(options:)
|
422
|
+
finish_him_value = options.dig(:finish_him)
|
423
|
+
|
424
|
+
return unless options.key?(:finish_him)
|
425
|
+
|
426
|
+
return if ALLOWED_FAIL_FINISH_HIM_VALUES.include?(finish_him_value)
|
427
|
+
|
428
|
+
raise Decouplio::Errors::AideFinishHimError.new(
|
429
|
+
errored_option: options.slice(:finish_him).to_s,
|
430
|
+
details: finish_him_value
|
431
|
+
)
|
432
|
+
end
|
433
|
+
|
327
434
|
def check_fail_finish_him(options:)
|
328
435
|
finish_him_value = options.dig(:finish_him)
|
329
436
|
|
@@ -514,6 +621,7 @@ module Decouplio
|
|
514
621
|
|
515
622
|
OCTO_ALLOWED_OPTIONS = %i[
|
516
623
|
ctx_key
|
624
|
+
method
|
517
625
|
if
|
518
626
|
unless
|
519
627
|
].freeze
|
@@ -523,6 +631,7 @@ module Decouplio
|
|
523
631
|
].freeze
|
524
632
|
OCTO_REQUIRED_KEYS = %i[
|
525
633
|
ctx_key
|
634
|
+
method
|
526
635
|
].freeze
|
527
636
|
|
528
637
|
# *************************************************
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_step'
|
4
|
+
|
5
|
+
module Decouplio
|
6
|
+
module Steps
|
7
|
+
class Aide < Decouplio::Steps::BaseStep
|
8
|
+
def initialize(name:, aide_class:, aide_options:, on_success_type:, on_failure_type:)
|
9
|
+
super()
|
10
|
+
@name = name
|
11
|
+
@aide_class = aide_class
|
12
|
+
@aide_options = aide_options
|
13
|
+
@on_success_type = on_success_type
|
14
|
+
@on_failure_type = on_failure_type
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(instance:)
|
18
|
+
instance.append_railway_flow(@name)
|
19
|
+
result = @aide_class.call(
|
20
|
+
ctx: instance.ctx,
|
21
|
+
error_store: instance.error_store,
|
22
|
+
**@aide_options
|
23
|
+
)
|
24
|
+
resolve(instance: instance, result: result)
|
25
|
+
end
|
26
|
+
|
27
|
+
def resolve(instance:, result:)
|
28
|
+
Decouplio::Steps::Shared::FailResolver.call(
|
29
|
+
instance: instance,
|
30
|
+
result: result,
|
31
|
+
on_success_type: @on_success_type,
|
32
|
+
on_failure_type: @on_failure_type
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/decouplio/steps/doby.rb
CHANGED
@@ -5,11 +5,13 @@ require_relative 'base_step'
|
|
5
5
|
module Decouplio
|
6
6
|
module Steps
|
7
7
|
class Doby < Decouplio::Steps::BaseStep
|
8
|
-
def initialize(name:, doby_class:, doby_options:)
|
8
|
+
def initialize(name:, doby_class:, doby_options:, on_success_type:, on_failure_type:)
|
9
9
|
super()
|
10
10
|
@name = name
|
11
11
|
@doby_class = doby_class
|
12
12
|
@doby_options = doby_options
|
13
|
+
@on_success_type = on_success_type
|
14
|
+
@on_failure_type = on_failure_type
|
13
15
|
end
|
14
16
|
|
15
17
|
def process(instance:)
|
@@ -23,13 +25,12 @@ module Decouplio
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def resolve(result:, instance:)
|
26
|
-
|
27
|
-
instance
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
28
|
+
Decouplio::Steps::Shared::StepResolver.call(
|
29
|
+
instance: instance,
|
30
|
+
result: result,
|
31
|
+
on_success_type: @on_success_type,
|
32
|
+
on_failure_type: @on_failure_type
|
33
|
+
)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
data/lib/decouplio/steps/octo.rb
CHANGED
@@ -7,15 +7,20 @@ module Decouplio
|
|
7
7
|
class Octo < BaseStep
|
8
8
|
attr_accessor :hash_case
|
9
9
|
|
10
|
-
def initialize(name:, ctx_key:)
|
10
|
+
def initialize(name:, ctx_key:, method:)
|
11
11
|
super()
|
12
12
|
@name = name
|
13
13
|
@ctx_key = ctx_key
|
14
|
+
@method = method
|
14
15
|
end
|
15
16
|
|
16
17
|
def process(instance:)
|
17
18
|
instance.append_railway_flow(@name)
|
18
|
-
|
19
|
+
if @method
|
20
|
+
instance.send(@method, **instance.ctx)
|
21
|
+
else
|
22
|
+
instance[@ctx_key]
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -42,6 +42,16 @@ module Decouplio
|
|
42
42
|
errored_option: condition_options.to_s,
|
43
43
|
details: %i[if unless]
|
44
44
|
)
|
45
|
+
when Decouplio::Const::Types::DOBY_TYPE
|
46
|
+
raise Decouplio::Errors::DobyControversialKeysError.new(
|
47
|
+
errored_option: condition_options.to_s,
|
48
|
+
details: %i[if unless]
|
49
|
+
)
|
50
|
+
when Decouplio::Const::Types::AIDE_TYPE
|
51
|
+
raise Decouplio::Errors::AideControversialKeysError.new(
|
52
|
+
errored_option: condition_options.to_s,
|
53
|
+
details: %i[if unless]
|
54
|
+
)
|
45
55
|
end
|
46
56
|
end
|
47
57
|
end
|
data/lib/decouplio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decouplio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Bal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,12 +127,12 @@ files:
|
|
127
127
|
- decouplio.gemspec
|
128
128
|
- docker-compose.yml
|
129
129
|
- docs/_config.yml
|
130
|
+
- docs/aide.rb
|
130
131
|
- docs/benchmarks.md
|
131
132
|
- docs/context.md
|
132
133
|
- docs/context.rb
|
133
|
-
- docs/deny.rb
|
134
134
|
- docs/doby.rb
|
135
|
-
- docs/
|
135
|
+
- docs/doby_aide.md
|
136
136
|
- docs/error_store.md
|
137
137
|
- docs/error_store.rb
|
138
138
|
- docs/fail.md
|
@@ -159,12 +159,14 @@ files:
|
|
159
159
|
- lib/decouplio/action.rb
|
160
160
|
- lib/decouplio/composer.rb
|
161
161
|
- lib/decouplio/const/colors.rb
|
162
|
+
- lib/decouplio/const/doby_aide_options.rb
|
162
163
|
- lib/decouplio/const/reserved_methods.rb
|
163
164
|
- lib/decouplio/const/results.rb
|
164
165
|
- lib/decouplio/const/types.rb
|
165
166
|
- lib/decouplio/const/validations/action_option_class.rb
|
167
|
+
- lib/decouplio/const/validations/aide.rb
|
166
168
|
- lib/decouplio/const/validations/common.rb
|
167
|
-
- lib/decouplio/const/validations/
|
169
|
+
- lib/decouplio/const/validations/doby.rb
|
168
170
|
- lib/decouplio/const/validations/fail.rb
|
169
171
|
- lib/decouplio/const/validations/logic.rb
|
170
172
|
- lib/decouplio/const/validations/octo.rb
|
@@ -175,8 +177,12 @@ files:
|
|
175
177
|
- lib/decouplio/const/validations/wrap.rb
|
176
178
|
- lib/decouplio/default_error_handler.rb
|
177
179
|
- lib/decouplio/errors/action_class_error.rb
|
180
|
+
- lib/decouplio/errors/aide_can_not_be_first_step_error.rb
|
181
|
+
- lib/decouplio/errors/aide_controversial_keys_error.rb
|
182
|
+
- lib/decouplio/errors/aide_finish_him_error.rb
|
178
183
|
- lib/decouplio/errors/base_error.rb
|
179
|
-
- lib/decouplio/errors/
|
184
|
+
- lib/decouplio/errors/doby_controversial_keys_error.rb
|
185
|
+
- lib/decouplio/errors/doby_finish_him_error.rb
|
180
186
|
- lib/decouplio/errors/error_store_error.rb
|
181
187
|
- lib/decouplio/errors/extra_key_for_fail_error.rb
|
182
188
|
- lib/decouplio/errors/extra_key_for_octo_error.rb
|
@@ -205,6 +211,8 @@ files:
|
|
205
211
|
- lib/decouplio/errors/resq_handler_method_error.rb
|
206
212
|
- lib/decouplio/errors/step_controversial_keys_error.rb
|
207
213
|
- lib/decouplio/errors/step_finish_him_error.rb
|
214
|
+
- lib/decouplio/errors/step_is_not_defined_for_aide_error.rb
|
215
|
+
- lib/decouplio/errors/step_is_not_defined_for_doby_error.rb
|
208
216
|
- lib/decouplio/errors/step_is_not_defined_for_fail_error.rb
|
209
217
|
- lib/decouplio/errors/step_is_not_defined_for_step_error.rb
|
210
218
|
- lib/decouplio/errors/step_is_not_defined_for_wrap_error.rb
|
@@ -219,9 +227,9 @@ files:
|
|
219
227
|
- lib/decouplio/octo_options_validator.rb
|
220
228
|
- lib/decouplio/options_validator.rb
|
221
229
|
- lib/decouplio/processor.rb
|
230
|
+
- lib/decouplio/steps/aide.rb
|
222
231
|
- lib/decouplio/steps/base_resq.rb
|
223
232
|
- lib/decouplio/steps/base_step.rb
|
224
|
-
- lib/decouplio/steps/deny.rb
|
225
233
|
- lib/decouplio/steps/doby.rb
|
226
234
|
- lib/decouplio/steps/fail.rb
|
227
235
|
- lib/decouplio/steps/if_condition_fail.rb
|
data/lib/decouplio/steps/deny.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'base_step'
|
4
|
-
|
5
|
-
module Decouplio
|
6
|
-
module Steps
|
7
|
-
class Deny < Decouplio::Steps::BaseStep
|
8
|
-
def initialize(name:, deny_class:, deny_options:)
|
9
|
-
super()
|
10
|
-
@name = name
|
11
|
-
@deny_class = deny_class
|
12
|
-
@deny_options = deny_options
|
13
|
-
end
|
14
|
-
|
15
|
-
def process(instance:)
|
16
|
-
instance.append_railway_flow(@name)
|
17
|
-
@deny_class.call(
|
18
|
-
ctx: instance.ctx,
|
19
|
-
error_store: instance.error_store,
|
20
|
-
**@deny_options
|
21
|
-
)
|
22
|
-
resolve(instance: instance)
|
23
|
-
end
|
24
|
-
|
25
|
-
def resolve(instance:)
|
26
|
-
instance.fail_action
|
27
|
-
Decouplio::Const::Results::FAIL
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|