decouplio 1.0.0alpha
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 +7 -0
- data/.circleci/config.yml +53 -0
- data/.dockerignore +12 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +106 -0
- data/.rubocop_todo.yml +147 -0
- data/.ruby-version +1 -0
- data/.vscode/settings.json +3 -0
- data/Dockerfile +12 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/benchmarks/.ruby-version +1 -0
- data/benchmarks/Dockerfile +12 -0
- data/benchmarks/Gemfile +11 -0
- data/benchmarks/benchmarks.rb +527 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/decouplio.gemspec +40 -0
- data/docker-compose.yml +18 -0
- data/docs/_config.yml +1 -0
- data/docs/benchmarks.md +1 -0
- data/docs/context.md +74 -0
- data/docs/context.rb +62 -0
- data/docs/doby.md +80 -0
- data/docs/doby.rb +38 -0
- data/docs/error_store.md +347 -0
- data/docs/error_store.rb +202 -0
- data/docs/fail.md +1016 -0
- data/docs/fail.rb +762 -0
- data/docs/index.md +25 -0
- data/docs/inner_action.md +63 -0
- data/docs/inner_action.rb +43 -0
- data/docs/logic_block.md +25 -0
- data/docs/octo.md +269 -0
- data/docs/octo.rb +164 -0
- data/docs/pass.md +309 -0
- data/docs/pass.rb +213 -0
- data/docs/quick_start.md +71 -0
- data/docs/quick_start.rb +38 -0
- data/docs/resq.md +263 -0
- data/docs/resq.rb +176 -0
- data/docs/step.md +737 -0
- data/docs/step.rb +526 -0
- data/docs/step_as_a_service.md +109 -0
- data/docs/step_as_a_service.rb +77 -0
- data/docs/wrap.md +232 -0
- data/docs/wrap.rb +137 -0
- data/lib/decouplio/action.rb +111 -0
- data/lib/decouplio/composer.rb +599 -0
- data/lib/decouplio/const/colors.rb +25 -0
- data/lib/decouplio/const/reserved_methods.rb +18 -0
- data/lib/decouplio/const/results.rb +13 -0
- data/lib/decouplio/const/types.rb +173 -0
- data/lib/decouplio/const/validations/action_option_class.rb +17 -0
- data/lib/decouplio/const/validations/common.rb +14 -0
- data/lib/decouplio/const/validations/fail.rb +34 -0
- data/lib/decouplio/const/validations/logic.rb +15 -0
- data/lib/decouplio/const/validations/octo.rb +44 -0
- data/lib/decouplio/const/validations/palp.rb +20 -0
- data/lib/decouplio/const/validations/pass.rb +32 -0
- data/lib/decouplio/const/validations/resq.rb +67 -0
- data/lib/decouplio/const/validations/step.rb +35 -0
- data/lib/decouplio/const/validations/wrap.rb +41 -0
- data/lib/decouplio/default_error_handler.rb +24 -0
- data/lib/decouplio/errors/action_class_error.rb +26 -0
- data/lib/decouplio/errors/base_error.rb +30 -0
- data/lib/decouplio/errors/error_store_error.rb +17 -0
- data/lib/decouplio/errors/extra_key_for_fail_error.rb +26 -0
- data/lib/decouplio/errors/extra_key_for_octo_error.rb +26 -0
- data/lib/decouplio/errors/extra_key_for_pass_error.rb +26 -0
- data/lib/decouplio/errors/extra_key_for_resq_error.rb +29 -0
- data/lib/decouplio/errors/extra_key_for_step_error.rb +23 -0
- data/lib/decouplio/errors/extra_key_for_wrap_error.rb +23 -0
- data/lib/decouplio/errors/fail_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/fail_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/fail_is_first_step_error.rb +18 -0
- data/lib/decouplio/errors/invalid_error_class_error.rb +29 -0
- data/lib/decouplio/errors/invalid_wrap_name_error.rb +23 -0
- data/lib/decouplio/errors/logic_is_not_defined_error.rb +23 -0
- data/lib/decouplio/errors/logic_redefinition_error.rb +23 -0
- data/lib/decouplio/errors/octo_block_is_not_defined_error.rb +18 -0
- data/lib/decouplio/errors/octo_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/options_validation_error.rb +7 -0
- data/lib/decouplio/errors/palp_block_is_not_defined_error.rb +18 -0
- data/lib/decouplio/errors/palp_is_not_defined_error.rb +26 -0
- data/lib/decouplio/errors/palp_validation_error.rb +21 -0
- data/lib/decouplio/errors/pass_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/pass_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/required_options_is_missing_for_octo_error.rb +25 -0
- data/lib/decouplio/errors/resq_definition_error.rb +21 -0
- data/lib/decouplio/errors/resq_error_class_error.rb +29 -0
- data/lib/decouplio/errors/resq_handler_method_error.rb +26 -0
- data/lib/decouplio/errors/step_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/step_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/step_is_not_defined_for_fail_error.rb +26 -0
- data/lib/decouplio/errors/step_is_not_defined_for_step_error.rb +27 -0
- data/lib/decouplio/errors/step_is_not_defined_for_wrap_error.rb +26 -0
- data/lib/decouplio/errors/step_name_error.rb +20 -0
- data/lib/decouplio/errors/wrap_block_is_not_defined_error.rb +18 -0
- data/lib/decouplio/errors/wrap_controversial_keys_error.rb +26 -0
- data/lib/decouplio/errors/wrap_finish_him_error.rb +26 -0
- data/lib/decouplio/errors/wrap_klass_method_error.rb +23 -0
- data/lib/decouplio/flow.rb +17 -0
- data/lib/decouplio/logic_dsl.rb +96 -0
- data/lib/decouplio/octo_hash_case.rb +31 -0
- data/lib/decouplio/octo_options_validator.rb +89 -0
- data/lib/decouplio/options_validator.rb +566 -0
- data/lib/decouplio/processor.rb +20 -0
- data/lib/decouplio/steps/base_resq.rb +31 -0
- data/lib/decouplio/steps/base_step.rb +16 -0
- data/lib/decouplio/steps/doby.rb +32 -0
- data/lib/decouplio/steps/fail.rb +50 -0
- data/lib/decouplio/steps/if_condition_fail.rb +28 -0
- data/lib/decouplio/steps/if_condition_pass.rb +26 -0
- data/lib/decouplio/steps/inner_action_fail.rb +55 -0
- data/lib/decouplio/steps/inner_action_pass.rb +38 -0
- data/lib/decouplio/steps/inner_action_step.rb +51 -0
- data/lib/decouplio/steps/octo.rb +22 -0
- data/lib/decouplio/steps/pass.rb +35 -0
- data/lib/decouplio/steps/resq_fail.rb +10 -0
- data/lib/decouplio/steps/resq_pass.rb +10 -0
- data/lib/decouplio/steps/service_fail.rb +51 -0
- data/lib/decouplio/steps/service_pass.rb +36 -0
- data/lib/decouplio/steps/service_step.rb +47 -0
- data/lib/decouplio/steps/step.rb +43 -0
- data/lib/decouplio/steps/unless_condition_fail.rb +28 -0
- data/lib/decouplio/steps/unless_condition_pass.rb +26 -0
- data/lib/decouplio/steps/wrap.rb +62 -0
- data/lib/decouplio/validators/condition.rb +49 -0
- data/lib/decouplio/version.rb +5 -0
- data/lib/decouplio.rb +7 -0
- metadata +266 -0
@@ -0,0 +1,173 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Types
|
6
|
+
STEP_TYPE = :step
|
7
|
+
FAIL_TYPE = :fail
|
8
|
+
PASS_TYPE = :pass
|
9
|
+
IF_TYPE = :if
|
10
|
+
UNLESS_TYPE = :unless
|
11
|
+
IF_TYPE_PASS = :if_pass
|
12
|
+
UNLESS_TYPE_PASS = :unless_pass
|
13
|
+
IF_TYPE_FAIL = :if_fail
|
14
|
+
UNLESS_TYPE_FAIL = :unless_fail
|
15
|
+
OCTO_TYPE = :octo
|
16
|
+
DOBY_TYPE = :doby
|
17
|
+
ACTION_TYPE_STEP = :action_step
|
18
|
+
ACTION_TYPE_FAIL = :action_fail
|
19
|
+
ACTION_TYPE_PASS = :action_pass
|
20
|
+
SERVICE_TYPE_STEP = :service_step
|
21
|
+
SERVICE_TYPE_FAIL = :service_fail
|
22
|
+
SERVICE_TYPE_PASS = :service_pass
|
23
|
+
WRAP_TYPE = :wrap
|
24
|
+
RESQ_TYPE = :resq
|
25
|
+
RESQ_TYPE_STEP = :resq_step
|
26
|
+
RESQ_TYPE_FAIL = :resq_fail
|
27
|
+
RESQ_TYPE_PASS = :resq_pass
|
28
|
+
STEP_TYPE_TO_CONDITION_TYPE = {
|
29
|
+
STEP_TYPE => {
|
30
|
+
IF_TYPE => IF_TYPE_PASS,
|
31
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
32
|
+
},
|
33
|
+
FAIL_TYPE => {
|
34
|
+
IF_TYPE => IF_TYPE_FAIL,
|
35
|
+
UNLESS_TYPE => UNLESS_TYPE_FAIL
|
36
|
+
},
|
37
|
+
PASS_TYPE => {
|
38
|
+
IF_TYPE => IF_TYPE_PASS,
|
39
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
40
|
+
},
|
41
|
+
OCTO_TYPE => {
|
42
|
+
IF_TYPE => IF_TYPE_PASS,
|
43
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
44
|
+
},
|
45
|
+
WRAP_TYPE => {
|
46
|
+
IF_TYPE => IF_TYPE_PASS,
|
47
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
48
|
+
},
|
49
|
+
RESQ_TYPE_STEP => {
|
50
|
+
IF_TYPE => IF_TYPE_PASS,
|
51
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
52
|
+
},
|
53
|
+
RESQ_TYPE_FAIL => {
|
54
|
+
IF_TYPE => IF_TYPE_FAIL,
|
55
|
+
UNLESS_TYPE => UNLESS_TYPE_FAIL
|
56
|
+
},
|
57
|
+
RESQ_TYPE_PASS => {
|
58
|
+
IF_TYPE => IF_TYPE_PASS,
|
59
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
60
|
+
},
|
61
|
+
ACTION_TYPE_STEP => {
|
62
|
+
IF_TYPE => IF_TYPE_PASS,
|
63
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
64
|
+
},
|
65
|
+
ACTION_TYPE_FAIL => {
|
66
|
+
IF_TYPE => IF_TYPE_FAIL,
|
67
|
+
UNLESS_TYPE => UNLESS_TYPE_FAIL
|
68
|
+
},
|
69
|
+
ACTION_TYPE_PASS => {
|
70
|
+
IF_TYPE => IF_TYPE_PASS,
|
71
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
72
|
+
},
|
73
|
+
SERVICE_TYPE_STEP => {
|
74
|
+
IF_TYPE => IF_TYPE_PASS,
|
75
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
76
|
+
},
|
77
|
+
SERVICE_TYPE_FAIL => {
|
78
|
+
IF_TYPE => IF_TYPE_FAIL,
|
79
|
+
UNLESS_TYPE => UNLESS_TYPE_FAIL
|
80
|
+
},
|
81
|
+
SERVICE_TYPE_PASS => {
|
82
|
+
IF_TYPE => IF_TYPE_PASS,
|
83
|
+
UNLESS_TYPE => UNLESS_TYPE_PASS
|
84
|
+
}
|
85
|
+
}.freeze
|
86
|
+
STEP_TYPE_TO_RESQ_TYPE = {
|
87
|
+
STEP_TYPE => RESQ_TYPE_STEP,
|
88
|
+
FAIL_TYPE => RESQ_TYPE_FAIL,
|
89
|
+
PASS_TYPE => RESQ_TYPE_PASS,
|
90
|
+
OCTO_TYPE => RESQ_TYPE_STEP,
|
91
|
+
WRAP_TYPE => RESQ_TYPE_STEP,
|
92
|
+
IF_TYPE_PASS => RESQ_TYPE_STEP,
|
93
|
+
UNLESS_TYPE_PASS => RESQ_TYPE_STEP,
|
94
|
+
IF_TYPE_FAIL => RESQ_TYPE_FAIL,
|
95
|
+
UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL,
|
96
|
+
DOBY_TYPE => RESQ_TYPE_STEP
|
97
|
+
}.freeze
|
98
|
+
STEP_TYPE_TO_INNER_TYPE = {
|
99
|
+
STEP_TYPE => ACTION_TYPE_STEP,
|
100
|
+
FAIL_TYPE => ACTION_TYPE_FAIL,
|
101
|
+
PASS_TYPE => ACTION_TYPE_PASS,
|
102
|
+
RESQ_TYPE_STEP => ACTION_TYPE_STEP,
|
103
|
+
RESQ_TYPE_FAIL => ACTION_TYPE_FAIL,
|
104
|
+
RESQ_TYPE_PASS => ACTION_TYPE_PASS
|
105
|
+
}.freeze
|
106
|
+
STEP_TYPE_TO_SERVICE_TYPE = {
|
107
|
+
STEP_TYPE => SERVICE_TYPE_STEP,
|
108
|
+
FAIL_TYPE => SERVICE_TYPE_FAIL,
|
109
|
+
PASS_TYPE => SERVICE_TYPE_PASS,
|
110
|
+
RESQ_TYPE_STEP => SERVICE_TYPE_STEP,
|
111
|
+
RESQ_TYPE_FAIL => SERVICE_TYPE_FAIL,
|
112
|
+
RESQ_TYPE_PASS => SERVICE_TYPE_PASS
|
113
|
+
}.freeze
|
114
|
+
ACTION_NOT_ALLOWED_STEPS = [
|
115
|
+
OCTO_TYPE,
|
116
|
+
WRAP_TYPE,
|
117
|
+
RESQ_TYPE,
|
118
|
+
DOBY_TYPE
|
119
|
+
].freeze
|
120
|
+
PASS_FLOW = [
|
121
|
+
STEP_TYPE,
|
122
|
+
PASS_TYPE,
|
123
|
+
OCTO_TYPE,
|
124
|
+
WRAP_TYPE,
|
125
|
+
IF_TYPE_PASS,
|
126
|
+
UNLESS_TYPE_PASS,
|
127
|
+
ACTION_TYPE_PASS,
|
128
|
+
ACTION_TYPE_STEP,
|
129
|
+
SERVICE_TYPE_STEP,
|
130
|
+
SERVICE_TYPE_PASS,
|
131
|
+
DOBY_TYPE
|
132
|
+
].freeze
|
133
|
+
FAIL_FLOW = [
|
134
|
+
FAIL_TYPE,
|
135
|
+
IF_TYPE_FAIL,
|
136
|
+
UNLESS_TYPE_FAIL,
|
137
|
+
ACTION_TYPE_FAIL,
|
138
|
+
SERVICE_TYPE_FAIL
|
139
|
+
].freeze
|
140
|
+
|
141
|
+
MAIN_FLOW_TYPES = [
|
142
|
+
STEP_TYPE,
|
143
|
+
FAIL_TYPE,
|
144
|
+
PASS_TYPE,
|
145
|
+
WRAP_TYPE,
|
146
|
+
DOBY_TYPE
|
147
|
+
].freeze
|
148
|
+
SUCCESS_TRACK_STEP_TYPES = [
|
149
|
+
STEP_TYPE,
|
150
|
+
PASS_TYPE,
|
151
|
+
IF_TYPE_PASS,
|
152
|
+
UNLESS_TYPE_PASS,
|
153
|
+
WRAP_TYPE,
|
154
|
+
ACTION_TYPE_STEP,
|
155
|
+
ACTION_TYPE_PASS,
|
156
|
+
SERVICE_TYPE_STEP,
|
157
|
+
SERVICE_TYPE_PASS,
|
158
|
+
RESQ_TYPE_STEP,
|
159
|
+
RESQ_TYPE_PASS,
|
160
|
+
OCTO_TYPE,
|
161
|
+
DOBY_TYPE
|
162
|
+
].freeze
|
163
|
+
FAILURE_TRACK_STEP_TYPES = [
|
164
|
+
FAIL_TYPE,
|
165
|
+
IF_TYPE_FAIL,
|
166
|
+
UNLESS_TYPE_FAIL,
|
167
|
+
RESQ_TYPE_FAIL,
|
168
|
+
ACTION_TYPE_FAIL,
|
169
|
+
SERVICE_TYPE_FAIL
|
170
|
+
].freeze
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module ActionOptionClass
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "%s":
|
9
|
+
%s
|
10
|
+
|
11
|
+
Details:
|
12
|
+
"action" allows only classes inherited from Decouplio::Action
|
13
|
+
ERROR_MESSAGE
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Common
|
7
|
+
WRONG_FINISH_HIM_VALUE = '"finish_him" does not allow "%s" value'
|
8
|
+
METHOD_IS_NOT_DEFINED = 'Method "%s" is not defined'
|
9
|
+
STEP_IS_NOT_DEFINED = 'Step "%s" is not defined'
|
10
|
+
STEP_NAME = '"%s" method is reserved by Decouplio, please another name.'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Fail
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "fail":
|
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
|
+
finish_him: true
|
23
|
+
if: <instance method symbol>
|
24
|
+
unless: <instance method symbol>
|
25
|
+
ALLOWED_OPTIONS
|
26
|
+
MANUAL_URL = 'https://stub.fail.manual.url'
|
27
|
+
OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "fail"'
|
28
|
+
METHOD_NOT_DEFINED = 'fail :%s'
|
29
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
30
|
+
FIRST_STEP = '"fail" can not be first step'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Logic
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
%s
|
9
|
+
ERROR_MESSAGE
|
10
|
+
REDEFINITION = 'The logic for "%s" class has already been defined.'
|
11
|
+
NOT_DEFINED = 'The logic for "%s" class is not define'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Octo
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "octo":
|
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
|
+
REQUIRED_VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
21
|
+
Details:
|
22
|
+
%s
|
23
|
+
|
24
|
+
Allowed options are:
|
25
|
+
%s
|
26
|
+
|
27
|
+
Please read the manual about allowed options here:
|
28
|
+
%s
|
29
|
+
ERROR_MESSAGE
|
30
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
31
|
+
ctx_key: <ctx key with strategy name to be used for strategy mapping> - required
|
32
|
+
if: <instance method symbol>
|
33
|
+
unless: <instance method symbol>
|
34
|
+
ALLOWED_OPTIONS
|
35
|
+
OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "octo"'
|
36
|
+
MANUAL_URL = 'https://stub.strategy.manual.url'
|
37
|
+
OPTIONS_IS_REQUIRED = 'Next option(s) "%s" are required for "octo"'
|
38
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
39
|
+
PALPS_IS_NOT_DEFINED = 'Next palp(s): "%s" is not difined'
|
40
|
+
OCTO_BLOCK = 'Block for "octo" is not defined'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Palp
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Details:
|
9
|
+
%s
|
10
|
+
Please read the manual about allowed options here:
|
11
|
+
%s
|
12
|
+
ERROR_MESSAGE
|
13
|
+
|
14
|
+
DOES_NOT_ALLOW_ANY_OPTION = '"palp" does not allow any options'
|
15
|
+
MANUAL_URL = 'https://stub.palp.manual.url'
|
16
|
+
NOT_DEFINED = 'The palp block is not defined'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Pass
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "pass":
|
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
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
21
|
+
finish_him: true
|
22
|
+
if: <instance method symbol>
|
23
|
+
unless: <instance method symbol>
|
24
|
+
ALLOWED_OPTIONS
|
25
|
+
MANUAL_URL = 'https://stub.pass.manual.url'
|
26
|
+
OPTIONS_IS_NOT_ALLOWED = '"%s" option(s) is not allowed for "pass"'
|
27
|
+
METHOD_NOT_DEFINED = 'pass :%s'
|
28
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Resq
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "resq":
|
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
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
21
|
+
<method name> => <exception class>
|
22
|
+
OR
|
23
|
+
<method name> => [<excpetion class one>, <exception class two>]
|
24
|
+
|
25
|
+
RESQ can have several handler methods, e.g.:
|
26
|
+
logic do
|
27
|
+
step :some_step
|
28
|
+
resq first_handler: [NoMethodError, ArgumentError],
|
29
|
+
second_handler: StandardError
|
30
|
+
end
|
31
|
+
|
32
|
+
def some_step(**)
|
33
|
+
ctx[:result] = <code which may raise an error>
|
34
|
+
end
|
35
|
+
|
36
|
+
def first_handler(error, **)
|
37
|
+
# Error handling code
|
38
|
+
end
|
39
|
+
|
40
|
+
def second_handler(error, **)
|
41
|
+
# Error handling code
|
42
|
+
end
|
43
|
+
|
44
|
+
ALLOWED_OPTIONS
|
45
|
+
|
46
|
+
DEFINITION_ERROR_MESSAGE = <<~ERROR
|
47
|
+
Details:
|
48
|
+
"resq" should be defined only after:
|
49
|
+
%s
|
50
|
+
|
51
|
+
Please read the manual about allowed options here:
|
52
|
+
%s
|
53
|
+
ERROR
|
54
|
+
|
55
|
+
DOES_NOT_ALLOW_OPTIONS = '"resq" does not allow "%s" option(s)'
|
56
|
+
MANUAL_URL = 'https://stub.resq.manual.url'
|
57
|
+
PLEASE_DEFINE_HANDLER_METHOD = 'Please define "%s" method'
|
58
|
+
HANDLER_METHOD_SHOULD_BE_A_SYMBOL = 'Handler method should be a symbol'
|
59
|
+
ERROR_CLASS_INHERITANCE = 'Please use exception class. %s does not inherited from Exception class'
|
60
|
+
INVALID_ERROR_CLASS_VALUE = 'Invalid handler class value "%s"'
|
61
|
+
WRONG_ERROR_CLASS = 'Please specify exception class(es) for "%s"'
|
62
|
+
NOT_ALLOWED_HANDLER_METHOD_VALUE = '"%s" is not allowed as a handler method for "resq"'
|
63
|
+
NOT_ALLOWED_EXCEPTION_CLASS = '"%s" class is not allowed for "resq"'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Step
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "step":
|
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
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
21
|
+
on_success: <step name OR :finish_him>
|
22
|
+
on_failure: <step name OR :finish_him>
|
23
|
+
finish_him: :on_success
|
24
|
+
finish_him: :on_failure
|
25
|
+
if: <instance method symbol>
|
26
|
+
unless: <instance method symbol>
|
27
|
+
ALLOWED_OPTIONS
|
28
|
+
MANUAL_URL = 'https://stub.step.manual.url'
|
29
|
+
EXTRA_KEYS_ARE_NOT_ALLOWED = 'Please check if step option is allowed'
|
30
|
+
METHOD_NOT_DEFINED = 'step :%s'
|
31
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
module Const
|
5
|
+
module Validations
|
6
|
+
module Wrap
|
7
|
+
VALIDATION_ERROR_MESSAGE = <<~ERROR_MESSAGE
|
8
|
+
Next options are not allowed for "wrap":
|
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
|
+
ALLOWED_OPTIONS_MESSAGE = <<~ALLOWED_OPTIONS
|
21
|
+
on_success: <step name OR :finish_him>
|
22
|
+
on_failure: <step name OR :finish_him>
|
23
|
+
finish_him: :on_success
|
24
|
+
finish_him: :on_failure
|
25
|
+
if: <instance method symbol>
|
26
|
+
unless: <instance method symbol>
|
27
|
+
klass: <class which implements wrap method, "method" option should be present>
|
28
|
+
method: <method name for wrapping, "klass" option should be present>
|
29
|
+
ALLOWED_OPTIONS
|
30
|
+
MANUAL_URL = 'https://stub.wrap.manual.url'
|
31
|
+
EXTRA_KEYS_ARE_NOT_ALLOWED = 'Please check if wrap option is allowed'
|
32
|
+
KLASS_AND_METHOD_PRESENCE = '"klass" options should be passed along with "method" option'
|
33
|
+
METHOD_IS_NOT_DEFINED_FOR_KLASS = 'Method "%s" is not defined for "%s" class'
|
34
|
+
NAME_IS_EMPTY = 'wrap name is empty'
|
35
|
+
SPECIFY_NAME = 'Please specify name for "wrap"'
|
36
|
+
CONTROVERSIAL_KEYS = '"%s" option(s) is not allowed along with "%s" option(s)'
|
37
|
+
NOT_DEFINED = 'The wrap block is not defined'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
class DefaultErrorHandler
|
5
|
+
attr_reader :errors
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@errors = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_error(key, message)
|
12
|
+
@errors.store(
|
13
|
+
key,
|
14
|
+
(@errors[key] || []) + [message].flatten
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def merge(error_store)
|
19
|
+
@errors = @errors.merge(error_store.errors) do |_key, this_val, other_val|
|
20
|
+
this_val + other_val
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/action_option_class'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class ActionClassError < Decouplio::Errors::BaseError
|
9
|
+
def initialize(step_type:, errored_option:)
|
10
|
+
super(errored_option: errored_option)
|
11
|
+
@step_type = step_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def template
|
15
|
+
Decouplio::Const::Validations::ActionOptionClass::VALIDATION_ERROR_MESSAGE
|
16
|
+
end
|
17
|
+
|
18
|
+
def interpolation_values
|
19
|
+
[
|
20
|
+
@step_type,
|
21
|
+
@errored_option
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../const/colors'
|
4
|
+
require_relative '../const/validations/common'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class BaseError < StandardError
|
9
|
+
def initialize(errored_option: nil, details: nil)
|
10
|
+
@errored_option = errored_option
|
11
|
+
@details = details
|
12
|
+
super(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def message
|
16
|
+
template % interpolation_values
|
17
|
+
end
|
18
|
+
|
19
|
+
def template
|
20
|
+
raise NotImplementedError,
|
21
|
+
'Please specify error template'
|
22
|
+
end
|
23
|
+
|
24
|
+
def interpolation_values
|
25
|
+
raise NotImplementedError,
|
26
|
+
'Please specify interpolation values for error template'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
|
5
|
+
module Decouplio
|
6
|
+
module Errors
|
7
|
+
class ErrorStoreError < Decouplio::Errors::BaseError
|
8
|
+
def template
|
9
|
+
'Error store for action and inner action should be the same.'
|
10
|
+
end
|
11
|
+
|
12
|
+
def interpolation_values
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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 ExtraKeyForFailError < Decouplio::Errors::BaseError
|
9
|
+
def template
|
10
|
+
Decouplio::Const::Validations::Fail::VALIDATION_ERROR_MESSAGE
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpolation_values
|
14
|
+
[
|
15
|
+
@errored_option,
|
16
|
+
format(
|
17
|
+
Decouplio::Const::Validations::Fail::OPTIONS_IS_NOT_ALLOWED,
|
18
|
+
@details
|
19
|
+
),
|
20
|
+
Decouplio::Const::Validations::Fail::ALLOWED_OPTIONS_MESSAGE,
|
21
|
+
Decouplio::Const::Validations::Fail::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/octo'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class ExtraKeyForOctoError < Decouplio::Errors::BaseError
|
9
|
+
def template
|
10
|
+
Decouplio::Const::Validations::Octo::VALIDATION_ERROR_MESSAGE
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpolation_values
|
14
|
+
[
|
15
|
+
@errored_option,
|
16
|
+
format(
|
17
|
+
Decouplio::Const::Validations::Octo::OPTIONS_IS_NOT_ALLOWED,
|
18
|
+
@details
|
19
|
+
),
|
20
|
+
Decouplio::Const::Validations::Octo::ALLOWED_OPTIONS_MESSAGE,
|
21
|
+
Decouplio::Const::Validations::Octo::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/pass'
|
5
|
+
|
6
|
+
module Decouplio
|
7
|
+
module Errors
|
8
|
+
class ExtraKeyForPassError < Decouplio::Errors::BaseError
|
9
|
+
def template
|
10
|
+
Decouplio::Const::Validations::Pass::VALIDATION_ERROR_MESSAGE
|
11
|
+
end
|
12
|
+
|
13
|
+
def interpolation_values
|
14
|
+
[
|
15
|
+
@errored_option,
|
16
|
+
format(
|
17
|
+
Decouplio::Const::Validations::Pass::OPTIONS_IS_NOT_ALLOWED,
|
18
|
+
@details
|
19
|
+
),
|
20
|
+
Decouplio::Const::Validations::Pass::ALLOWED_OPTIONS_MESSAGE,
|
21
|
+
Decouplio::Const::Validations::Pass::MANUAL_URL
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|