decouplio 1.0.0alpha7 → 1.0.0rc
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 +313 -15
- data/decouplio.gemspec +8 -2
- data/lib/decouplio/action.rb +34 -74
- data/lib/decouplio/action_state_printer.rb +34 -0
- data/lib/decouplio/const/flows.rb +59 -0
- data/lib/decouplio/const/reserved_methods.rb +6 -13
- data/lib/decouplio/const/types.rb +1 -165
- data/lib/decouplio/const/validations/common.rb +10 -0
- data/lib/decouplio/const/validations/octo.rb +16 -0
- data/lib/decouplio/const/validations/resq.rb +12 -1
- data/lib/decouplio/ctx.rb +13 -0
- data/lib/decouplio/default_meta_store.rb +37 -0
- data/lib/decouplio/errors/action_class_error.rb +0 -3
- data/lib/decouplio/errors/base_error.rb +0 -3
- data/lib/decouplio/errors/execution_error.rb +0 -2
- data/lib/decouplio/errors/extra_key_for_pass_error.rb +0 -3
- data/lib/decouplio/errors/fail_can_not_be_first_step_error.rb +0 -3
- data/lib/decouplio/errors/fail_controversial_keys_error.rb +0 -3
- data/lib/decouplio/errors/fail_finish_him_error.rb +0 -3
- data/lib/decouplio/errors/invalid_error_class_error.rb +0 -3
- data/lib/decouplio/errors/invalid_options_for_resq_step.rb +18 -0
- data/lib/decouplio/errors/invalid_wrap_name_error.rb +0 -3
- data/lib/decouplio/errors/logic_is_not_defined_error.rb +0 -3
- data/lib/decouplio/errors/logic_redefinition_error.rb +0 -3
- data/lib/decouplio/errors/octo_block_is_not_defined_error.rb +0 -3
- data/lib/decouplio/errors/octo_case_is_not_defined_error.rb +19 -0
- data/lib/decouplio/errors/octo_controversial_keys_error.rb +0 -3
- data/lib/decouplio/errors/{error_store_error.rb → octo_finish_him_is_not_allowed_error.rb} +2 -4
- data/lib/decouplio/errors/options_validation_error.rb +13 -1
- data/lib/decouplio/errors/palp_block_is_not_defined_error.rb +0 -3
- data/lib/decouplio/errors/palp_validation_error.rb +0 -3
- data/lib/decouplio/errors/pass_controversial_keys_error.rb +0 -3
- data/lib/decouplio/errors/pass_finish_him_error.rb +0 -3
- data/lib/decouplio/errors/required_options_is_missing_for_octo_error.rb +0 -3
- data/lib/decouplio/errors/resq_definition_error.rb +0 -3
- data/lib/decouplio/errors/resq_error_class_error.rb +0 -3
- data/lib/decouplio/errors/resq_handler_method_error.rb +0 -3
- data/lib/decouplio/errors/step_controversial_keys_error.rb +0 -3
- data/lib/decouplio/errors/step_definition_error.rb +17 -0
- data/lib/decouplio/errors/step_finish_him_error.rb +0 -3
- data/lib/decouplio/errors/step_is_not_defined_for_fail_error.rb +0 -3
- data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +0 -4
- data/lib/decouplio/errors/step_is_not_defined_for_step_error.rb +0 -4
- data/lib/decouplio/errors/step_is_not_defined_for_wrap_error.rb +0 -3
- data/lib/decouplio/errors/step_name_error.rb +0 -3
- data/lib/decouplio/errors/wrap_block_is_not_defined_error.rb +0 -3
- data/lib/decouplio/errors/wrap_controversial_keys_error.rb +0 -3
- data/lib/decouplio/errors/wrap_finish_him_error.rb +0 -3
- data/lib/decouplio/errors/wrap_klass_method_error.rb +0 -3
- data/lib/decouplio/graph.rb +9 -0
- data/lib/decouplio/logic_dsl.rb +337 -107
- data/lib/decouplio/new_flow.rb +283 -0
- data/lib/decouplio/octo_hash_case.rb +20 -5
- data/lib/decouplio/octo_options_validator.rb +10 -64
- data/lib/decouplio/step_validator.rb +200 -0
- data/lib/decouplio/steps/base_condition.rb +21 -0
- data/lib/decouplio/steps/base_if_condition.rb +11 -0
- data/lib/decouplio/steps/base_inner_action.rb +42 -0
- data/lib/decouplio/steps/base_octo.rb +26 -0
- data/lib/decouplio/steps/base_resq.rb +25 -28
- data/lib/decouplio/steps/base_resq_with_mapping.rb +34 -0
- data/lib/decouplio/steps/base_service_step.rb +39 -0
- data/lib/decouplio/steps/base_step.rb +33 -6
- data/lib/decouplio/steps/base_unless_condition.rb +11 -0
- data/lib/decouplio/steps/base_wrap.rb +27 -0
- data/lib/decouplio/steps/fail.rb +1 -28
- data/lib/decouplio/steps/if_condition_fail.rb +1 -21
- data/lib/decouplio/steps/if_condition_pass.rb +1 -19
- data/lib/decouplio/steps/inner_action_fail.rb +1 -33
- data/lib/decouplio/steps/inner_action_pass.rb +12 -30
- data/lib/decouplio/steps/inner_action_step.rb +1 -33
- data/lib/decouplio/steps/octo_by_key.rb +31 -0
- data/lib/decouplio/steps/octo_by_method.rb +31 -0
- data/lib/decouplio/steps/pass.rb +5 -26
- data/lib/decouplio/steps/resq_fail.rb +0 -2
- data/lib/decouplio/steps/resq_pass.rb +1 -3
- data/lib/decouplio/steps/resq_with_mapping_fail.rb +8 -0
- data/lib/decouplio/steps/resq_with_mapping_pass.rb +8 -0
- data/lib/decouplio/steps/service_as_fail.rb +8 -0
- data/lib/decouplio/steps/service_as_pass.rb +16 -0
- data/lib/decouplio/steps/service_as_step.rb +8 -0
- data/lib/decouplio/steps/step.rb +0 -24
- data/lib/decouplio/steps/unless_condition_fail.rb +1 -21
- data/lib/decouplio/steps/unless_condition_pass.rb +1 -19
- data/lib/decouplio/steps/wrap.rb +25 -37
- data/lib/decouplio/steps/wrap_with_class.rb +43 -0
- data/lib/decouplio/steps/wrap_with_class_method.rb +45 -0
- data/lib/decouplio/utils/prepare_resq_mappings.rb +17 -0
- data/lib/decouplio/version.rb +1 -1
- data/lib/decouplio.rb +93 -0
- metadata +32 -55
- data/.circleci/config.yml +0 -63
- data/.dockerignore +0 -12
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.rubocop.yml +0 -116
- data/.rubocop_todo.yml +0 -147
- data/.ruby-version +0 -1
- data/.vscode/settings.json +0 -3
- data/Dockerfile +0 -12
- data/Gemfile +0 -8
- data/benchmarks/.ruby-version +0 -1
- data/benchmarks/Dockerfile +0 -12
- data/benchmarks/Gemfile +0 -12
- data/benchmarks/multi_step_benchmark.rb +0 -336
- data/benchmarks/single_step_benchmark.rb +0 -159
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/docker-compose.yml +0 -29
- data/lib/decouplio/composer.rb +0 -691
- data/lib/decouplio/const/colors.rb +0 -25
- data/lib/decouplio/const/doby_aide_options.rb +0 -16
- data/lib/decouplio/const/results.rb +0 -15
- data/lib/decouplio/const/step_options.rb +0 -16
- data/lib/decouplio/const/validations/aide.rb +0 -38
- data/lib/decouplio/const/validations/doby.rb +0 -36
- data/lib/decouplio/default_error_handler.rb +0 -39
- data/lib/decouplio/errors/aide_can_not_be_first_step_error.rb +0 -18
- data/lib/decouplio/errors/aide_controversial_keys_error.rb +0 -26
- data/lib/decouplio/errors/aide_finish_him_error.rb +0 -26
- data/lib/decouplio/errors/doby_controversial_keys_error.rb +0 -26
- data/lib/decouplio/errors/doby_finish_him_error.rb +0 -26
- data/lib/decouplio/errors/extra_key_for_fail_error.rb +0 -26
- data/lib/decouplio/errors/extra_key_for_octo_error.rb +0 -26
- data/lib/decouplio/errors/extra_key_for_resq_error.rb +0 -29
- data/lib/decouplio/errors/extra_key_for_step_error.rb +0 -23
- data/lib/decouplio/errors/extra_key_for_wrap_error.rb +0 -23
- data/lib/decouplio/errors/palp_is_not_defined_error.rb +0 -26
- data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +0 -26
- data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +0 -27
- data/lib/decouplio/flow.rb +0 -17
- data/lib/decouplio/options_validator.rb +0 -716
- data/lib/decouplio/processor.rb +0 -20
- data/lib/decouplio/steps/aide.rb +0 -37
- data/lib/decouplio/steps/doby.rb +0 -37
- data/lib/decouplio/steps/octo.rb +0 -27
- data/lib/decouplio/steps/service_fail.rb +0 -41
- data/lib/decouplio/steps/service_pass.rb +0 -41
- data/lib/decouplio/steps/service_step.rb +0 -41
- data/lib/decouplio/steps/shared/fail_resolver.rb +0 -40
- data/lib/decouplio/steps/shared/step_resolver.rb +0 -43
- data/lib/decouplio/validators/condition.rb +0 -59
@@ -1,716 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'const/types'
|
4
|
-
require_relative 'const/reserved_methods'
|
5
|
-
require_relative 'errors/action_class_error'
|
6
|
-
require_relative 'errors/extra_key_for_step_error'
|
7
|
-
require_relative 'errors/extra_key_for_fail_error'
|
8
|
-
require_relative 'errors/extra_key_for_octo_error'
|
9
|
-
require_relative 'errors/extra_key_for_pass_error'
|
10
|
-
require_relative 'errors/extra_key_for_resq_error'
|
11
|
-
require_relative 'errors/extra_key_for_wrap_error'
|
12
|
-
require_relative 'errors/fail_finish_him_error'
|
13
|
-
require_relative 'errors/doby_finish_him_error'
|
14
|
-
require_relative 'errors/aide_finish_him_error'
|
15
|
-
require_relative 'errors/invalid_error_class_error'
|
16
|
-
require_relative 'errors/invalid_wrap_name_error'
|
17
|
-
require_relative 'errors/pass_finish_him_error'
|
18
|
-
require_relative 'errors/required_options_is_missing_for_octo_error'
|
19
|
-
require_relative 'errors/resq_error_class_error'
|
20
|
-
require_relative 'errors/resq_handler_method_error'
|
21
|
-
require_relative 'errors/step_finish_him_error'
|
22
|
-
require_relative 'errors/step_is_not_defined_for_step_error'
|
23
|
-
require_relative 'errors/step_is_not_defined_for_fail_error'
|
24
|
-
require_relative 'errors/step_is_not_defined_for_pass_error'
|
25
|
-
require_relative 'errors/step_is_not_defined_for_wrap_error'
|
26
|
-
require_relative 'errors/step_is_not_defined_for_aide_error'
|
27
|
-
require_relative 'errors/step_is_not_defined_for_doby_error'
|
28
|
-
require_relative 'errors/wrap_finish_him_error'
|
29
|
-
require_relative 'errors/wrap_klass_method_error'
|
30
|
-
require_relative 'errors/step_controversial_keys_error'
|
31
|
-
require_relative 'errors/doby_controversial_keys_error'
|
32
|
-
require_relative 'errors/aide_controversial_keys_error'
|
33
|
-
require_relative 'errors/fail_controversial_keys_error'
|
34
|
-
require_relative 'errors/pass_controversial_keys_error'
|
35
|
-
require_relative 'errors/octo_controversial_keys_error'
|
36
|
-
require_relative 'errors/wrap_controversial_keys_error'
|
37
|
-
require_relative 'errors/palp_is_not_defined_error'
|
38
|
-
require_relative 'errors/error_store_error'
|
39
|
-
require_relative 'errors/step_name_error'
|
40
|
-
|
41
|
-
module Decouplio
|
42
|
-
class OptionsValidator
|
43
|
-
def initialize(flow:, palps:, next_steps:, action_class:)
|
44
|
-
@flow = flow
|
45
|
-
@palps = palps
|
46
|
-
@next_steps = next_steps
|
47
|
-
@action_class = action_class
|
48
|
-
end
|
49
|
-
|
50
|
-
def call
|
51
|
-
@flow.each_with_index do |(_step_id, options), index|
|
52
|
-
step_names = extract_step_names(flow: @flow.to_a[index..].to_h.merge(@next_steps || {}))
|
53
|
-
|
54
|
-
validate(options: options, step_names: step_names)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def validate(options:, step_names:)
|
61
|
-
filtered_options = options.reject { |key, _val| OPTIONS_TO_FILTER.include?(key) }
|
62
|
-
|
63
|
-
validate_name(name: options[:name])
|
64
|
-
@palps.each_key do |palp_name|
|
65
|
-
validate_name(name: palp_name)
|
66
|
-
end
|
67
|
-
|
68
|
-
case options[:type]
|
69
|
-
when Decouplio::Const::Types::STEP_TYPE
|
70
|
-
validate_step(options: filtered_options, step_names: step_names)
|
71
|
-
when Decouplio::Const::Types::FAIL_TYPE
|
72
|
-
validate_fail(options: filtered_options, step_names: step_names)
|
73
|
-
when Decouplio::Const::Types::PASS_TYPE
|
74
|
-
validate_pass(options: filtered_options, step_names: step_names)
|
75
|
-
when Decouplio::Const::Types::OCTO_TYPE
|
76
|
-
validate_octo(options: filtered_options, hash_case: options[:hash_case])
|
77
|
-
when Decouplio::Const::Types::WRAP_TYPE
|
78
|
-
validate_wrap(options: filtered_options, name: options[:name], step_names: step_names)
|
79
|
-
when Decouplio::Const::Types::ACTION_TYPE_STEP
|
80
|
-
validate_action(action_class: options[:action], type: Decouplio::Const::Types::STEP_TYPE)
|
81
|
-
validate_error_store(parent_action_class: @action_class, child_action_class: options[:action])
|
82
|
-
validate_step(options: filtered_options, step_names: step_names)
|
83
|
-
when Decouplio::Const::Types::ACTION_TYPE_FAIL
|
84
|
-
validate_action(action_class: options[:action], type: Decouplio::Const::Types::FAIL_TYPE)
|
85
|
-
validate_error_store(parent_action_class: @action_class, child_action_class: options[:action])
|
86
|
-
validate_fail(options: filtered_options, step_names: step_names)
|
87
|
-
when Decouplio::Const::Types::ACTION_TYPE_PASS
|
88
|
-
validate_action(action_class: options[:action], type: Decouplio::Const::Types::PASS_TYPE)
|
89
|
-
validate_error_store(parent_action_class: @action_class, child_action_class: options[:action])
|
90
|
-
validate_pass(options: filtered_options, step_names: step_names)
|
91
|
-
when Decouplio::Const::Types::RESQ_TYPE_STEP,
|
92
|
-
Decouplio::Const::Types::RESQ_TYPE_FAIL,
|
93
|
-
Decouplio::Const::Types::RESQ_TYPE_PASS
|
94
|
-
validate(options: options[:step_to_resq], step_names: step_names)
|
95
|
-
validate_resq(options: filtered_options)
|
96
|
-
when Decouplio::Const::Types::DOBY_TYPE
|
97
|
-
validate_doby(options: filtered_options, step_names: step_names)
|
98
|
-
when Decouplio::Const::Types::AIDE_TYPE
|
99
|
-
validate_aide(options: filtered_options, step_names: step_names)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def validate_action(action_class:, type:)
|
104
|
-
return if action_class.is_a?(Class) && action_class <= Decouplio::Action
|
105
|
-
|
106
|
-
raise Decouplio::Errors::ActionClassError.new(
|
107
|
-
step_type: type,
|
108
|
-
errored_option: "action: #{action_class}"
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
|
-
def validate_step(options:, step_names:)
|
113
|
-
check_step_presence_for_step(options: options, step_names: step_names)
|
114
|
-
check_step_controversial_keys(options: options)
|
115
|
-
check_step_extra_keys(options: options)
|
116
|
-
check_step_finish_him(options: options)
|
117
|
-
end
|
118
|
-
|
119
|
-
def validate_fail(options:, step_names:)
|
120
|
-
check_step_presence_for_fail(options: options, step_names: step_names)
|
121
|
-
check_fail_controversial_keys(options: options)
|
122
|
-
check_fail_extra_keys(options: options)
|
123
|
-
check_fail_finish_him(options: options)
|
124
|
-
end
|
125
|
-
|
126
|
-
def validate_pass(options:, step_names:)
|
127
|
-
check_step_presence_for_pass(options: options, step_names: step_names)
|
128
|
-
check_pass_extra_keys(options: options)
|
129
|
-
check_pass_finish_him(options: options)
|
130
|
-
end
|
131
|
-
|
132
|
-
def validate_octo(options:, hash_case:)
|
133
|
-
check_octo_required_keys(options: options)
|
134
|
-
check_octo_extra_keys(options: options)
|
135
|
-
check_octo_palps(hash_case: hash_case)
|
136
|
-
end
|
137
|
-
|
138
|
-
def validate_wrap(options:, name:, step_names:)
|
139
|
-
check_wrap_name(name: name)
|
140
|
-
check_wrap_controversial_keys(options: options)
|
141
|
-
check_step_presence_for_wrap(options: options, step_names: step_names)
|
142
|
-
check_wrap_extra_keys(options: options)
|
143
|
-
check_wrap_finish_him(options: options)
|
144
|
-
check_wrap_klass_method_presence(options: options)
|
145
|
-
end
|
146
|
-
|
147
|
-
def validate_resq(options:)
|
148
|
-
options[:handler_hash].each_value do |error_handler_name|
|
149
|
-
validate_name(name: error_handler_name)
|
150
|
-
end
|
151
|
-
check_resq_extra_keys(options: options)
|
152
|
-
check_resq_handler_method_is_a_symbol(options: options)
|
153
|
-
check_resq_error_classes(options: options)
|
154
|
-
check_resq_exception_classes_inheritance(options: options)
|
155
|
-
end
|
156
|
-
|
157
|
-
def validate_doby(options:, step_names:)
|
158
|
-
check_step_presence_for_doby(options: options, step_names: step_names)
|
159
|
-
check_doby_controversial_keys(options: options)
|
160
|
-
check_doby_finish_him(options: options)
|
161
|
-
end
|
162
|
-
|
163
|
-
def validate_aide(options:, step_names:)
|
164
|
-
check_step_presence_for_aide(options: options, step_names: step_names)
|
165
|
-
check_aide_controversial_keys(options: options)
|
166
|
-
check_aide_finish_him(options: options)
|
167
|
-
end
|
168
|
-
|
169
|
-
def validate_name(name:)
|
170
|
-
return unless Decouplio::Const::ReservedMethods::NAMES.include?(name)
|
171
|
-
|
172
|
-
raise Decouplio::Errors::StepNameError.new(
|
173
|
-
errored_option: name
|
174
|
-
)
|
175
|
-
end
|
176
|
-
|
177
|
-
def check_step_presence_for_step(options:, step_names:)
|
178
|
-
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
179
|
-
next if %i[on_success on_failure on_error].include?(option_key) &&
|
180
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
181
|
-
|
182
|
-
next if step_names.keys.include?(option_value)
|
183
|
-
|
184
|
-
raise Decouplio::Errors::StepIsNotDefinedForStepError.new(
|
185
|
-
errored_option: options.slice(option_key).to_s,
|
186
|
-
details: option_value
|
187
|
-
)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def check_step_presence_for_pass(options:, step_names:)
|
192
|
-
options.slice(*PASS_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
193
|
-
next if %i[on_error].include?(option_key) &&
|
194
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
195
|
-
|
196
|
-
next if step_names.keys.include?(option_value)
|
197
|
-
|
198
|
-
raise Decouplio::Errors::StepIsNotDefinedForPassError.new(
|
199
|
-
errored_option: options.slice(option_key).to_s,
|
200
|
-
details: option_value
|
201
|
-
)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def check_step_presence_for_doby(options:, step_names:)
|
206
|
-
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
207
|
-
next if %i[on_success on_failure on_error].include?(option_key) &&
|
208
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
209
|
-
|
210
|
-
next if step_names.keys.include?(option_value)
|
211
|
-
|
212
|
-
raise Decouplio::Errors::StepIsNotDefinedForDobyError.new(
|
213
|
-
errored_option: options.slice(option_key).to_s,
|
214
|
-
details: option_value
|
215
|
-
)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def check_step_presence_for_aide(options:, step_names:)
|
220
|
-
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
221
|
-
next if %i[on_success on_failure on_error].include?(option_key) &&
|
222
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
223
|
-
|
224
|
-
next if step_names.keys.include?(option_value)
|
225
|
-
|
226
|
-
raise Decouplio::Errors::StepIsNotDefinedForAideError.new(
|
227
|
-
errored_option: options.slice(option_key).to_s,
|
228
|
-
details: option_value
|
229
|
-
)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
def check_step_presence_for_fail(options:, step_names:)
|
234
|
-
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
235
|
-
next if %i[on_success on_failure on_error].include?(option_key) &&
|
236
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
237
|
-
|
238
|
-
next if step_names.keys.include?(option_value)
|
239
|
-
|
240
|
-
raise Decouplio::Errors::StepIsNotDefinedForFailError.new(
|
241
|
-
errored_option: options.slice(option_key).to_s,
|
242
|
-
details: option_value
|
243
|
-
)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
def check_step_presence_for_wrap(options:, step_names:)
|
248
|
-
options.slice(*WRAP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
249
|
-
next if %i[on_success on_failure on_error].include?(option_key) &&
|
250
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
251
|
-
|
252
|
-
next if step_names.keys.include?(option_value)
|
253
|
-
|
254
|
-
raise Decouplio::Errors::StepIsNotDefinedForWrapError.new(
|
255
|
-
errored_option: options.slice(option_key).to_s,
|
256
|
-
details: option_value
|
257
|
-
)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def check_step_extra_keys(options:)
|
262
|
-
extra_keys = options.keys - STEP_ALLOWED_OPTIONS
|
263
|
-
|
264
|
-
if extra_keys.size.positive?
|
265
|
-
raise Decouplio::Errors::ExtraKeyForStepError.new(
|
266
|
-
errored_option: options.slice(*extra_keys).to_s
|
267
|
-
)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
def check_step_controversial_keys(options:)
|
272
|
-
on_success_on_failure = options.slice(:on_success, :on_failure)
|
273
|
-
finish_him = options.slice(:finish_him)
|
274
|
-
|
275
|
-
if !on_success_on_failure.empty? && !finish_him.empty?
|
276
|
-
raise Decouplio::Errors::StepControversialKeysError.new(
|
277
|
-
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
278
|
-
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
279
|
-
)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
def check_doby_controversial_keys(options:)
|
284
|
-
on_success_on_failure = options.slice(:on_success, :on_failure)
|
285
|
-
finish_him = options.slice(:finish_him)
|
286
|
-
|
287
|
-
if !on_success_on_failure.empty? && !finish_him.empty?
|
288
|
-
raise Decouplio::Errors::DobyControversialKeysError.new(
|
289
|
-
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
290
|
-
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
291
|
-
)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
def check_aide_controversial_keys(options:)
|
296
|
-
on_success_on_failure = options.slice(:on_success, :on_failure)
|
297
|
-
finish_him = options.slice(:finish_him)
|
298
|
-
|
299
|
-
if !on_success_on_failure.empty? && !finish_him.empty?
|
300
|
-
raise Decouplio::Errors::AideControversialKeysError.new(
|
301
|
-
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
302
|
-
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
303
|
-
)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
def validate_error_store(parent_action_class:, child_action_class:)
|
308
|
-
return if parent_action_class.error_store == child_action_class.error_store
|
309
|
-
|
310
|
-
raise Decouplio::Errors::ErrorStoreError
|
311
|
-
end
|
312
|
-
|
313
|
-
def check_fail_extra_keys(options:)
|
314
|
-
extra_keys = options.keys - FAIL_ALLOWED_OPTIONS
|
315
|
-
|
316
|
-
return if extra_keys.size.zero?
|
317
|
-
|
318
|
-
raise Decouplio::Errors::ExtraKeyForFailError.new(
|
319
|
-
errored_option: options.slice(*extra_keys).to_s,
|
320
|
-
details: extra_keys.join(', ')
|
321
|
-
)
|
322
|
-
end
|
323
|
-
|
324
|
-
def check_fail_controversial_keys(options:)
|
325
|
-
on_success_on_failure = options.slice(:on_success, :on_failure)
|
326
|
-
finish_him = options.slice(:finish_him)
|
327
|
-
|
328
|
-
if !on_success_on_failure.empty? && !finish_him.empty?
|
329
|
-
raise Decouplio::Errors::FailControversialKeysError.new(
|
330
|
-
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
331
|
-
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
332
|
-
)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
def check_pass_extra_keys(options:)
|
337
|
-
extra_keys = options.keys - PASS_ALLOWED_OPTIONS
|
338
|
-
|
339
|
-
if extra_keys.size.positive?
|
340
|
-
raise Decouplio::Errors::ExtraKeyForPassError.new(
|
341
|
-
errored_option: options.slice(*extra_keys).to_s,
|
342
|
-
details: extra_keys.join(', ')
|
343
|
-
)
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
def check_octo_extra_keys(options:)
|
348
|
-
extra_keys = options.keys - OCTO_ALLOWED_OPTIONS
|
349
|
-
|
350
|
-
if extra_keys.size.positive?
|
351
|
-
raise Decouplio::Errors::ExtraKeyForOctoError.new(
|
352
|
-
errored_option: options.slice(*extra_keys).to_s,
|
353
|
-
details: extra_keys.join(', ')
|
354
|
-
)
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def check_wrap_extra_keys(options:)
|
359
|
-
extra_keys = options.keys - WRAP_ALLOWED_OPTIONS
|
360
|
-
|
361
|
-
if extra_keys.size.positive?
|
362
|
-
raise Decouplio::Errors::ExtraKeyForWrapError.new(
|
363
|
-
errored_option: options.slice(*extra_keys).to_s
|
364
|
-
)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
def check_wrap_controversial_keys(options:)
|
369
|
-
on_success_on_failure = options.slice(:on_success, :on_failure)
|
370
|
-
finish_him = options.slice(:finish_him)
|
371
|
-
|
372
|
-
if !on_success_on_failure.empty? && !finish_him.empty?
|
373
|
-
raise Decouplio::Errors::WrapControversialKeysError.new(
|
374
|
-
errored_option: on_success_on_failure.merge(finish_him).to_s,
|
375
|
-
details: [on_success_on_failure.keys.join(', '), :finish_him]
|
376
|
-
)
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
def check_octo_palps(hash_case:)
|
381
|
-
hash_casse_palps = hash_case.map { |_octo_key, hash| hash[:palp] }.compact
|
382
|
-
undefined_palps = hash_casse_palps - @palps.keys
|
383
|
-
|
384
|
-
return if undefined_palps.empty?
|
385
|
-
|
386
|
-
errored_options = hash_case.select do |_key, val|
|
387
|
-
undefined_palps.include?(val[:palp])
|
388
|
-
end
|
389
|
-
errored_options = errored_options.map do |key, val|
|
390
|
-
"\"on :#{key}, palp: :#{val[:palp]}\""
|
391
|
-
end
|
392
|
-
|
393
|
-
raise Decouplio::Errors::PalpIsNotDefinedError.new(
|
394
|
-
errored_option: errored_options,
|
395
|
-
details: undefined_palps
|
396
|
-
)
|
397
|
-
end
|
398
|
-
|
399
|
-
def check_octo_required_keys(options:)
|
400
|
-
if (OCTO_REQUIRED_KEYS - options.keys).size.zero?
|
401
|
-
if options.keys.sort == OCTO_REQUIRED_KEYS.sort
|
402
|
-
raise Decouplio::Errors::OctoControversialKeysError.new(
|
403
|
-
errored_option: options.slice(*OCTO_REQUIRED_KEYS),
|
404
|
-
details: OCTO_REQUIRED_KEYS
|
405
|
-
)
|
406
|
-
end
|
407
|
-
else
|
408
|
-
return if options.slice(*OCTO_REQUIRED_KEYS).size == 1
|
409
|
-
|
410
|
-
raise Decouplio::Errors::RequiredOptionsIsMissingForOctoError.new(
|
411
|
-
details: OCTO_REQUIRED_KEYS.join(', ')
|
412
|
-
)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
|
416
|
-
def check_step_finish_him(options:)
|
417
|
-
finish_him_value = options.dig(:finish_him)
|
418
|
-
|
419
|
-
return unless finish_him_value && options.key?(:finish_him)
|
420
|
-
|
421
|
-
unless ALLOWED_STEP_FINISH_HIM_VALUES.include?(finish_him_value)
|
422
|
-
raise Decouplio::Errors::StepFinishHimError.new(
|
423
|
-
errored_option: options.slice(:finish_him).to_s,
|
424
|
-
details: finish_him_value
|
425
|
-
)
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
def check_doby_finish_him(options:)
|
430
|
-
finish_him_value = options.dig(:finish_him)
|
431
|
-
|
432
|
-
return unless finish_him_value && options.key?(:finish_him)
|
433
|
-
|
434
|
-
unless ALLOWED_STEP_FINISH_HIM_VALUES.include?(finish_him_value)
|
435
|
-
raise Decouplio::Errors::DobyFinishHimError.new(
|
436
|
-
errored_option: options.slice(:finish_him).to_s,
|
437
|
-
details: finish_him_value
|
438
|
-
)
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
def check_aide_finish_him(options:)
|
443
|
-
finish_him_value = options.dig(:finish_him)
|
444
|
-
|
445
|
-
return unless options.key?(:finish_him)
|
446
|
-
|
447
|
-
return if ALLOWED_FAIL_FINISH_HIM_VALUES.include?(finish_him_value)
|
448
|
-
|
449
|
-
raise Decouplio::Errors::AideFinishHimError.new(
|
450
|
-
errored_option: options.slice(:finish_him).to_s,
|
451
|
-
details: finish_him_value
|
452
|
-
)
|
453
|
-
end
|
454
|
-
|
455
|
-
def check_fail_finish_him(options:)
|
456
|
-
finish_him_value = options.dig(:finish_him)
|
457
|
-
|
458
|
-
return unless options.key?(:finish_him)
|
459
|
-
|
460
|
-
return if ALLOWED_FAIL_FINISH_HIM_VALUES.include?(finish_him_value)
|
461
|
-
|
462
|
-
raise Decouplio::Errors::FailFinishHimError.new(
|
463
|
-
errored_option: options.slice(:finish_him).to_s,
|
464
|
-
details: finish_him_value
|
465
|
-
)
|
466
|
-
end
|
467
|
-
|
468
|
-
def check_pass_finish_him(options:)
|
469
|
-
finish_him_value = options.dig(:finish_him)
|
470
|
-
|
471
|
-
return unless finish_him_value && options.key?(:finish_him)
|
472
|
-
|
473
|
-
unless ALLOWED_PASS_FINISH_HIM_VALUES.include?(finish_him_value)
|
474
|
-
raise Decouplio::Errors::PassFinishHimError.new(
|
475
|
-
errored_option: options.slice(:finish_him).to_s,
|
476
|
-
details: finish_him_value
|
477
|
-
)
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
def check_wrap_finish_him(options:)
|
482
|
-
finish_him_value = options.dig(:finish_him)
|
483
|
-
|
484
|
-
return unless finish_him_value && options.key?(:finish_him)
|
485
|
-
|
486
|
-
unless ALLOWED_WRAP_FINISH_HIM_VALUES.include?(finish_him_value)
|
487
|
-
raise Decouplio::Errors::WrapFinishHimError.new(
|
488
|
-
errored_option: options.slice(:finish_him).to_s,
|
489
|
-
details: finish_him_value
|
490
|
-
)
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
def check_wrap_klass_method_presence(options:)
|
495
|
-
klass_method_options = options.slice(:klass, :method)
|
496
|
-
klass_method_options_size = klass_method_options.size
|
497
|
-
|
498
|
-
return if klass_method_options_size.zero? || klass_method_options_size == 2
|
499
|
-
|
500
|
-
raise Decouplio::Errors::WrapKlassMethodError.new(
|
501
|
-
errored_option: klass_method_options.to_s
|
502
|
-
)
|
503
|
-
end
|
504
|
-
|
505
|
-
def check_wrap_name(name:)
|
506
|
-
return if name.is_a?(Symbol)
|
507
|
-
|
508
|
-
raise Decouplio::Errors::InvalidWrapNameError
|
509
|
-
end
|
510
|
-
|
511
|
-
def check_resq_extra_keys(options:)
|
512
|
-
extra_options = options[:handler_hash].values.select do |option|
|
513
|
-
RESQ_NOT_ALLOWED_OPTIONS.include?(option)
|
514
|
-
end
|
515
|
-
|
516
|
-
return if extra_options.empty?
|
517
|
-
|
518
|
-
raise Decouplio::Errors::ExtraKeyForResqError.new(
|
519
|
-
errored_option: extra_options.join(', ').to_s,
|
520
|
-
details: extra_options.join(', ').to_s
|
521
|
-
)
|
522
|
-
end
|
523
|
-
|
524
|
-
def check_resq_handler_method_is_a_symbol(options:)
|
525
|
-
options[:handler_hash].values.uniq.each do |handler_method|
|
526
|
-
next if handler_method.is_a?(Symbol)
|
527
|
-
|
528
|
-
raise Decouplio::Errors::ResqHandlerMethodError.new(
|
529
|
-
errored_option: handler_method.to_s
|
530
|
-
)
|
531
|
-
end
|
532
|
-
end
|
533
|
-
|
534
|
-
def check_resq_error_classes(options:)
|
535
|
-
options[:handler_hash].each_key do |error_class|
|
536
|
-
next if error_class.is_a?(Class)
|
537
|
-
|
538
|
-
raise Decouplio::Errors::ResqErrorClassError.new(
|
539
|
-
errored_option: error_class.to_s,
|
540
|
-
details: options[:handler_hash][error_class].to_s
|
541
|
-
)
|
542
|
-
end
|
543
|
-
end
|
544
|
-
|
545
|
-
def check_resq_exception_classes_inheritance(options:)
|
546
|
-
options[:handler_hash].each_key do |klass|
|
547
|
-
next if klass < Exception
|
548
|
-
|
549
|
-
raise Decouplio::Errors::InvalidErrorClassError.new(
|
550
|
-
errored_option: klass.to_s,
|
551
|
-
details: klass.to_s
|
552
|
-
)
|
553
|
-
end
|
554
|
-
end
|
555
|
-
|
556
|
-
def extract_step_names(flow:)
|
557
|
-
flow.to_h do |_step_id, stp|
|
558
|
-
[stp[:name], stp[:type]]
|
559
|
-
end
|
560
|
-
end
|
561
|
-
|
562
|
-
OPTIONS_TO_FILTER = %i[
|
563
|
-
step_id
|
564
|
-
flow
|
565
|
-
name
|
566
|
-
type
|
567
|
-
hash_case
|
568
|
-
wrap_flow
|
569
|
-
step_to_resq
|
570
|
-
_args
|
571
|
-
].freeze
|
572
|
-
|
573
|
-
# *************************************************
|
574
|
-
# STEP
|
575
|
-
# *************************************************
|
576
|
-
|
577
|
-
STEP_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
578
|
-
on_success
|
579
|
-
on_failure
|
580
|
-
on_error
|
581
|
-
if
|
582
|
-
unless
|
583
|
-
].freeze
|
584
|
-
STEP_CHECK_STEP_PRESENCE = %i[
|
585
|
-
on_success
|
586
|
-
on_failure
|
587
|
-
on_error
|
588
|
-
].freeze
|
589
|
-
STEP_ALLOWED_ON_S_ON_F_VALUES = [
|
590
|
-
Decouplio::Const::Results::STEP_PASS,
|
591
|
-
Decouplio::Const::Results::STEP_FAIL,
|
592
|
-
Decouplio::Const::Results::FINISH_HIM
|
593
|
-
].freeze
|
594
|
-
STEP_ALLOWED_OPTIONS = %i[
|
595
|
-
on_success
|
596
|
-
on_failure
|
597
|
-
on_error
|
598
|
-
finish_him
|
599
|
-
if
|
600
|
-
unless
|
601
|
-
action
|
602
|
-
].freeze
|
603
|
-
ALLOWED_STEP_FINISH_HIM_VALUES = %i[
|
604
|
-
on_success
|
605
|
-
on_failure
|
606
|
-
on_error
|
607
|
-
].freeze
|
608
|
-
|
609
|
-
# *************************************************
|
610
|
-
# FAIL
|
611
|
-
# *************************************************
|
612
|
-
|
613
|
-
FAIL_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
614
|
-
if
|
615
|
-
unless
|
616
|
-
].freeze
|
617
|
-
FAIL_ALLOWED_OPTIONS = %i[
|
618
|
-
on_success
|
619
|
-
on_failure
|
620
|
-
on_error
|
621
|
-
finish_him
|
622
|
-
if
|
623
|
-
unless
|
624
|
-
action
|
625
|
-
].freeze
|
626
|
-
ALLOWED_FAIL_FINISH_HIM_VALUES = [true, :on_success, :on_failure, :on_error].freeze
|
627
|
-
|
628
|
-
# *************************************************
|
629
|
-
# PASS
|
630
|
-
# *************************************************
|
631
|
-
|
632
|
-
PASS_ALLOWED_OPTIONS = %i[
|
633
|
-
finish_him
|
634
|
-
if
|
635
|
-
unless
|
636
|
-
action
|
637
|
-
on_error
|
638
|
-
].freeze
|
639
|
-
|
640
|
-
PASS_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
641
|
-
if
|
642
|
-
unless
|
643
|
-
].freeze
|
644
|
-
PASS_CHECK_STEP_PRESENCE = %i[
|
645
|
-
on_error
|
646
|
-
].freeze
|
647
|
-
ALLOWED_PASS_FINISH_HIM_VALUES = [true, :on_error].freeze
|
648
|
-
|
649
|
-
# *************************************************
|
650
|
-
# OCTO
|
651
|
-
# *************************************************
|
652
|
-
|
653
|
-
OCTO_ALLOWED_OPTIONS = %i[
|
654
|
-
ctx_key
|
655
|
-
method
|
656
|
-
if
|
657
|
-
unless
|
658
|
-
].freeze
|
659
|
-
OCTO_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
660
|
-
if
|
661
|
-
unless
|
662
|
-
].freeze
|
663
|
-
OCTO_REQUIRED_KEYS = %i[
|
664
|
-
ctx_key
|
665
|
-
method
|
666
|
-
].freeze
|
667
|
-
|
668
|
-
# *************************************************
|
669
|
-
# WRAP
|
670
|
-
# *************************************************
|
671
|
-
|
672
|
-
WRAP_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
673
|
-
on_success
|
674
|
-
on_failure
|
675
|
-
on_error
|
676
|
-
if
|
677
|
-
unless
|
678
|
-
].freeze
|
679
|
-
WRAP_CHECK_STEP_PRESENCE = %i[
|
680
|
-
on_success
|
681
|
-
on_failure
|
682
|
-
on_error
|
683
|
-
].freeze
|
684
|
-
WRAP_ALLOWED_OPTIONS = %i[
|
685
|
-
on_success
|
686
|
-
on_failure
|
687
|
-
on_error
|
688
|
-
finish_him
|
689
|
-
if
|
690
|
-
unless
|
691
|
-
klass
|
692
|
-
method
|
693
|
-
wrap_block
|
694
|
-
].freeze
|
695
|
-
ALLOWED_WRAP_FINISH_HIM_VALUES = %i[
|
696
|
-
on_success
|
697
|
-
on_failure
|
698
|
-
on_error
|
699
|
-
].freeze
|
700
|
-
|
701
|
-
# *************************************************
|
702
|
-
# RESQ
|
703
|
-
# *************************************************
|
704
|
-
|
705
|
-
RESQ_NOT_ALLOWED_OPTIONS = %i[
|
706
|
-
on_success
|
707
|
-
on_failure
|
708
|
-
on_error
|
709
|
-
finish_him
|
710
|
-
if
|
711
|
-
unless
|
712
|
-
klass
|
713
|
-
method
|
714
|
-
].freeze
|
715
|
-
end
|
716
|
-
end
|