decouplio 1.0.0alpha7 → 1.0.0alpha8
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/.rubocop.yml +3 -11
- data/lib/decouplio/action.rb +17 -41
- data/lib/decouplio/action_state_printer.rb +37 -0
- data/lib/decouplio/composer.rb +0 -76
- data/lib/decouplio/const/types.rb +7 -27
- data/lib/decouplio/default_meta_store.rb +39 -0
- data/lib/decouplio/logic_dsl.rb +5 -36
- data/lib/decouplio/options_validator.rb +0 -110
- data/lib/decouplio/steps/inner_action_fail.rb +5 -3
- data/lib/decouplio/steps/inner_action_pass.rb +7 -5
- data/lib/decouplio/steps/inner_action_step.rb +5 -3
- data/lib/decouplio/steps/service_fail.rb +1 -1
- data/lib/decouplio/steps/service_pass.rb +1 -1
- data/lib/decouplio/steps/service_step.rb +1 -1
- data/lib/decouplio/validators/condition.rb +0 -10
- data/lib/decouplio/version.rb +1 -1
- metadata +4 -15
- data/lib/decouplio/const/doby_aide_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/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/steps/aide.rb +0 -37
- data/lib/decouplio/steps/doby.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13faf170a6cfce8a57a5263eb8ba404ee1ceadcda93990c9c780987bd6a79a8e
|
4
|
+
data.tar.gz: 18e855d3cbf016a0e1976e72147309db0ec0e91d764b1c7988cdb7172868c804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53426aa0ac2fdd513d7fb80dea55e4e5e1425b3ef08912fe53f3fefbdfa25773d8fa3dce9dc8a84efec89c8078f42756af1b741a34f9d937050a823f577bdfad
|
7
|
+
data.tar.gz: 5209925b7857efa198cae3f9e2ceb1341cd160944ab9855557fea6bacb1762c3239f0b08a33abf837d5d610de36d157a761c132b053eed25b07c676ceaaf191d
|
data/.rubocop.yml
CHANGED
@@ -75,7 +75,6 @@ Lint/ConstantDefinitionInBlock:
|
|
75
75
|
- spec/fail_spec.rb
|
76
76
|
- spec/palp_block_spec.rb
|
77
77
|
- spec/wrap_block_spec.rb
|
78
|
-
- spec/error_store_for_inner_step_spec.rb
|
79
78
|
|
80
79
|
RSpec/LeakyConstantDeclaration:
|
81
80
|
Exclude:
|
@@ -83,16 +82,6 @@ RSpec/LeakyConstantDeclaration:
|
|
83
82
|
- spec/fail_spec.rb
|
84
83
|
- spec/palp_block_spec.rb
|
85
84
|
- spec/wrap_block_spec.rb
|
86
|
-
- spec/error_store_for_inner_step_spec.rb
|
87
|
-
|
88
|
-
RSpec/FilePath:
|
89
|
-
Exclude:
|
90
|
-
- spec/default_error_handler_spec.rb
|
91
|
-
|
92
|
-
RSpec/ExampleLength:
|
93
|
-
Max: 15
|
94
|
-
Exclude:
|
95
|
-
- spec/default_error_handler_spec.rb
|
96
85
|
|
97
86
|
RSpec/MultipleExpectations:
|
98
87
|
Enabled: false
|
@@ -114,3 +103,6 @@ Naming/RescuedExceptionsVariableName:
|
|
114
103
|
|
115
104
|
Layout/LineContinuationSpacing:
|
116
105
|
Enabled: false
|
106
|
+
|
107
|
+
RSpec/ExampleLength:
|
108
|
+
Enabled: false
|
data/lib/decouplio/action.rb
CHANGED
@@ -3,23 +3,23 @@
|
|
3
3
|
require 'forwardable'
|
4
4
|
require_relative 'flow'
|
5
5
|
require_relative 'processor'
|
6
|
-
require_relative '
|
6
|
+
require_relative 'default_meta_store'
|
7
|
+
require_relative 'action_state_printer'
|
7
8
|
require_relative 'errors/logic_redefinition_error'
|
8
9
|
require_relative 'errors/logic_is_not_defined_error'
|
9
|
-
require_relative 'errors/error_store_error'
|
10
10
|
require_relative 'errors/execution_error'
|
11
11
|
require_relative 'const/results'
|
12
12
|
|
13
13
|
module Decouplio
|
14
14
|
class Action
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
attr_reader :railway_flow, :ctx, :meta_store
|
16
|
+
|
17
|
+
alias ms meta_store
|
18
18
|
|
19
19
|
def initialize(
|
20
|
-
parent_railway_flow: nil, parent_ctx: nil,
|
20
|
+
parent_railway_flow: nil, parent_ctx: nil, meta_store:, **params
|
21
21
|
)
|
22
|
-
@
|
22
|
+
@meta_store = meta_store
|
23
23
|
@ctx = parent_ctx || params
|
24
24
|
@railway_flow = parent_railway_flow || []
|
25
25
|
@failure = false
|
@@ -45,39 +45,12 @@ module Decouplio
|
|
45
45
|
@failure = false
|
46
46
|
end
|
47
47
|
|
48
|
-
def previous_step
|
49
|
-
railway_flow[PREVIOUS_STEP_INDEX]
|
50
|
-
end
|
51
|
-
|
52
48
|
def append_railway_flow(stp)
|
53
49
|
railway_flow << stp
|
54
50
|
end
|
55
51
|
|
56
52
|
def inspect
|
57
|
-
|
58
|
-
Result: #{success? ? 'success' : 'failure'}
|
59
|
-
|
60
|
-
Railway Flow:
|
61
|
-
#{railway_flow.join(' -> ')}
|
62
|
-
|
63
|
-
Context:
|
64
|
-
#{ctx.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join("\n ")}
|
65
|
-
|
66
|
-
Errors:
|
67
|
-
#{
|
68
|
-
if errors.is_a?(Hash)
|
69
|
-
if errors.empty?
|
70
|
-
'None'
|
71
|
-
else
|
72
|
-
errors.map do |k, v|
|
73
|
-
"#{k.inspect} => #{v.inspect}"
|
74
|
-
end.join("\n ")
|
75
|
-
end
|
76
|
-
else
|
77
|
-
errors
|
78
|
-
end
|
79
|
-
}
|
80
|
-
INSPECT
|
53
|
+
Decouplio::ActionStatePrinter.call(self)
|
81
54
|
end
|
82
55
|
|
83
56
|
def to_s
|
@@ -85,16 +58,19 @@ module Decouplio
|
|
85
58
|
end
|
86
59
|
|
87
60
|
class << self
|
88
|
-
attr_accessor :
|
61
|
+
attr_accessor :meta_store
|
89
62
|
|
90
|
-
def
|
91
|
-
self.
|
63
|
+
def meta_store_class(klass)
|
64
|
+
self.meta_store = klass
|
92
65
|
end
|
93
66
|
|
94
67
|
def call(**params)
|
95
|
-
instance = new(
|
68
|
+
instance = new(
|
69
|
+
**{
|
70
|
+
meta_store: meta_store.new
|
71
|
+
}.merge(**params)
|
72
|
+
)
|
96
73
|
Decouplio::Processor.call(instance: instance, **@flow)
|
97
|
-
# TODO: process block with after actions
|
98
74
|
instance
|
99
75
|
end
|
100
76
|
|
@@ -112,7 +88,7 @@ module Decouplio
|
|
112
88
|
private
|
113
89
|
|
114
90
|
def inherited(child_class)
|
115
|
-
child_class.
|
91
|
+
child_class.meta_store = meta_store || Decouplio::DefaultMetaStore
|
116
92
|
end
|
117
93
|
|
118
94
|
def logic(&block)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
class ActionStatePrinter
|
5
|
+
def self.call(action)
|
6
|
+
<<~INSPECT
|
7
|
+
|
8
|
+
Result: #{result(action)}
|
9
|
+
|
10
|
+
RailwayFlow:
|
11
|
+
#{railway_flow(action)}
|
12
|
+
|
13
|
+
Context:
|
14
|
+
#{action_context(action)}
|
15
|
+
|
16
|
+
#{meta_store(action)}
|
17
|
+
|
18
|
+
INSPECT
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.result(action)
|
22
|
+
action.success? ? 'success' : 'failure'
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.railway_flow(action)
|
26
|
+
action.railway_flow.join(' -> ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.action_context(action)
|
30
|
+
action.ctx.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join("\n ")
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.meta_store(action)
|
34
|
+
action.ms.to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/decouplio/composer.rb
CHANGED
@@ -20,8 +20,6 @@ require_relative 'steps/inner_action_pass'
|
|
20
20
|
require_relative 'steps/service_step'
|
21
21
|
require_relative 'steps/service_fail'
|
22
22
|
require_relative 'steps/service_pass'
|
23
|
-
require_relative 'steps/doby'
|
24
|
-
require_relative 'steps/aide'
|
25
23
|
require_relative 'options_validator'
|
26
24
|
require_relative 'validators/condition'
|
27
25
|
|
@@ -129,10 +127,6 @@ module Decouplio
|
|
129
127
|
create_inner_service_fail(stp, flow)
|
130
128
|
when Decouplio::Const::Types::SERVICE_TYPE_PASS
|
131
129
|
create_inner_service_pass(stp, flow)
|
132
|
-
when Decouplio::Const::Types::DOBY_TYPE
|
133
|
-
create_doby(stp, flow)
|
134
|
-
when Decouplio::Const::Types::AIDE_TYPE
|
135
|
-
create_aide(stp, flow)
|
136
130
|
end
|
137
131
|
end
|
138
132
|
|
@@ -275,26 +269,6 @@ module Decouplio
|
|
275
269
|
)
|
276
270
|
end
|
277
271
|
|
278
|
-
def create_doby(stp, flow)
|
279
|
-
Decouplio::Steps::Doby.new(
|
280
|
-
name: stp[:name],
|
281
|
-
doby_class: stp[:doby_class],
|
282
|
-
doby_options: stp[:doby_options],
|
283
|
-
on_success_type: success_type(flow, stp),
|
284
|
-
on_failure_type: failure_type(flow, stp)
|
285
|
-
)
|
286
|
-
end
|
287
|
-
|
288
|
-
def create_aide(stp, flow)
|
289
|
-
Decouplio::Steps::Aide.new(
|
290
|
-
name: stp[:name],
|
291
|
-
aide_class: stp[:aide_class],
|
292
|
-
aide_options: stp[:aide_options],
|
293
|
-
on_success_type: success_type(flow, stp),
|
294
|
-
on_failure_type: failure_type(flow, stp)
|
295
|
-
)
|
296
|
-
end
|
297
|
-
|
298
272
|
def compose_flow(flow, palps, next_steps, action_class, flow_hash = {})
|
299
273
|
flow.each_with_index do |(step_id, stp), idx|
|
300
274
|
case stp[:type]
|
@@ -313,10 +287,6 @@ module Decouplio
|
|
313
287
|
Decouplio::Const::Types::ACTION_TYPE_FAIL,
|
314
288
|
Decouplio::Const::Types::SERVICE_TYPE_FAIL
|
315
289
|
compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
316
|
-
when Decouplio::Const::Types::DOBY_TYPE
|
317
|
-
compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
318
|
-
when Decouplio::Const::Types::AIDE_TYPE
|
319
|
-
compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
320
290
|
when Decouplio::Const::Types::IF_TYPE_PASS, Decouplio::Const::Types::UNLESS_TYPE_PASS
|
321
291
|
compose_pass_condition_flow(stp, flow, idx, flow_hash)
|
322
292
|
when Decouplio::Const::Types::IF_TYPE_FAIL, Decouplio::Const::Types::UNLESS_TYPE_FAIL
|
@@ -350,52 +320,6 @@ module Decouplio
|
|
350
320
|
stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
|
351
321
|
end
|
352
322
|
|
353
|
-
def compose_doby_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
354
|
-
flow_values = flow.values + (next_steps&.values || [])
|
355
|
-
stp[:flow][Decouplio::Const::Results::PASS] = next_success_step(
|
356
|
-
flow_values,
|
357
|
-
idx,
|
358
|
-
flow[step_id][:on_success]
|
359
|
-
)
|
360
|
-
stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
|
361
|
-
flow_values,
|
362
|
-
idx,
|
363
|
-
flow[step_id][:on_failure]
|
364
|
-
)
|
365
|
-
stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
|
366
|
-
flow_values,
|
367
|
-
idx,
|
368
|
-
flow[step_id][:on_error]
|
369
|
-
)
|
370
|
-
stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::PASS]
|
371
|
-
stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
372
|
-
stp[:flow][Decouplio::Const::Results::ERROR] ||= flow_hash[Decouplio::Const::Results::ERROR]
|
373
|
-
stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
|
374
|
-
end
|
375
|
-
|
376
|
-
def compose_aide_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
377
|
-
flow_values = flow.values + (next_steps&.values || [])
|
378
|
-
stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
|
379
|
-
flow_values,
|
380
|
-
idx,
|
381
|
-
flow[step_id][:on_success]
|
382
|
-
)
|
383
|
-
stp[:flow][Decouplio::Const::Results::FAIL] = next_failure_step(
|
384
|
-
flow_values,
|
385
|
-
idx,
|
386
|
-
flow[step_id][:on_failure]
|
387
|
-
)
|
388
|
-
stp[:flow][Decouplio::Const::Results::ERROR] = next_failure_step(
|
389
|
-
flow_values,
|
390
|
-
idx,
|
391
|
-
flow[step_id][:on_error]
|
392
|
-
)
|
393
|
-
stp[:flow][Decouplio::Const::Results::PASS] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
394
|
-
stp[:flow][Decouplio::Const::Results::FAIL] ||= flow_hash[Decouplio::Const::Results::FAIL]
|
395
|
-
stp[:flow][Decouplio::Const::Results::ERROR] ||= flow_hash[Decouplio::Const::Results::ERROR]
|
396
|
-
stp[:flow][Decouplio::Const::Results::FINISH_HIM] = Decouplio::Const::Results::NO_STEP
|
397
|
-
end
|
398
|
-
|
399
323
|
def compose_fail_flow(stp, step_id, flow, idx, flow_hash, next_steps)
|
400
324
|
flow_values = flow.values + (next_steps&.values || [])
|
401
325
|
stp[:flow][Decouplio::Const::Results::PASS] = next_failure_step(
|
@@ -13,8 +13,6 @@ module Decouplio
|
|
13
13
|
IF_TYPE_FAIL = :if_fail
|
14
14
|
UNLESS_TYPE_FAIL = :unless_fail
|
15
15
|
OCTO_TYPE = :octo
|
16
|
-
DOBY_TYPE = :doby
|
17
|
-
AIDE_TYPE = :aide
|
18
16
|
ACTION_TYPE_STEP = :action_step
|
19
17
|
ACTION_TYPE_FAIL = :action_fail
|
20
18
|
ACTION_TYPE_PASS = :action_pass
|
@@ -82,14 +80,6 @@ module Decouplio
|
|
82
80
|
SERVICE_TYPE_PASS => {
|
83
81
|
IF_TYPE => IF_TYPE_PASS,
|
84
82
|
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
|
93
83
|
}
|
94
84
|
}.freeze
|
95
85
|
STEP_TYPE_TO_RESQ_TYPE = {
|
@@ -101,9 +91,7 @@ module Decouplio
|
|
101
91
|
IF_TYPE_PASS => RESQ_TYPE_STEP,
|
102
92
|
UNLESS_TYPE_PASS => RESQ_TYPE_STEP,
|
103
93
|
IF_TYPE_FAIL => RESQ_TYPE_FAIL,
|
104
|
-
UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL
|
105
|
-
DOBY_TYPE => RESQ_TYPE_STEP,
|
106
|
-
AIDE_TYPE => RESQ_TYPE_FAIL
|
94
|
+
UNLESS_TYPE_FAIL => RESQ_TYPE_FAIL
|
107
95
|
}.freeze
|
108
96
|
STEP_TYPE_TO_INNER_TYPE = {
|
109
97
|
STEP_TYPE => ACTION_TYPE_STEP,
|
@@ -124,9 +112,7 @@ module Decouplio
|
|
124
112
|
ACTION_NOT_ALLOWED_STEPS = [
|
125
113
|
OCTO_TYPE,
|
126
114
|
WRAP_TYPE,
|
127
|
-
RESQ_TYPE
|
128
|
-
DOBY_TYPE,
|
129
|
-
AIDE_TYPE
|
115
|
+
RESQ_TYPE
|
130
116
|
].freeze
|
131
117
|
PASS_FLOW = [
|
132
118
|
STEP_TYPE,
|
@@ -138,25 +124,21 @@ module Decouplio
|
|
138
124
|
ACTION_TYPE_PASS,
|
139
125
|
ACTION_TYPE_STEP,
|
140
126
|
SERVICE_TYPE_STEP,
|
141
|
-
SERVICE_TYPE_PASS
|
142
|
-
DOBY_TYPE
|
127
|
+
SERVICE_TYPE_PASS
|
143
128
|
].freeze
|
144
129
|
FAIL_FLOW = [
|
145
130
|
FAIL_TYPE,
|
146
131
|
IF_TYPE_FAIL,
|
147
132
|
UNLESS_TYPE_FAIL,
|
148
133
|
ACTION_TYPE_FAIL,
|
149
|
-
SERVICE_TYPE_FAIL
|
150
|
-
AIDE_TYPE
|
134
|
+
SERVICE_TYPE_FAIL
|
151
135
|
].freeze
|
152
136
|
|
153
137
|
MAIN_FLOW_TYPES = [
|
154
138
|
STEP_TYPE,
|
155
139
|
FAIL_TYPE,
|
156
140
|
PASS_TYPE,
|
157
|
-
WRAP_TYPE
|
158
|
-
DOBY_TYPE,
|
159
|
-
AIDE_TYPE
|
141
|
+
WRAP_TYPE
|
160
142
|
].freeze
|
161
143
|
SUCCESS_TRACK_STEP_TYPES = [
|
162
144
|
STEP_TYPE,
|
@@ -170,8 +152,7 @@ module Decouplio
|
|
170
152
|
SERVICE_TYPE_PASS,
|
171
153
|
RESQ_TYPE_STEP,
|
172
154
|
RESQ_TYPE_PASS,
|
173
|
-
OCTO_TYPE
|
174
|
-
DOBY_TYPE
|
155
|
+
OCTO_TYPE
|
175
156
|
].freeze
|
176
157
|
FAILURE_TRACK_STEP_TYPES = [
|
177
158
|
FAIL_TYPE,
|
@@ -179,8 +160,7 @@ module Decouplio
|
|
179
160
|
UNLESS_TYPE_FAIL,
|
180
161
|
RESQ_TYPE_FAIL,
|
181
162
|
ACTION_TYPE_FAIL,
|
182
|
-
SERVICE_TYPE_FAIL
|
183
|
-
AIDE_TYPE
|
163
|
+
SERVICE_TYPE_FAIL
|
184
164
|
].freeze
|
185
165
|
end
|
186
166
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decouplio
|
4
|
+
class DefaultMetaStore
|
5
|
+
attr_accessor :status
|
6
|
+
attr_reader :errors
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@errors = {}
|
10
|
+
@status = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_error(key, messages)
|
14
|
+
@errors.store(
|
15
|
+
key,
|
16
|
+
(@errors[key] || []) + [messages].flatten
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
<<~METASTORE
|
22
|
+
Status: #{@status || 'NONE'}
|
23
|
+
|
24
|
+
Errors:
|
25
|
+
#{errors_string}
|
26
|
+
METASTORE
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def errors_string
|
32
|
+
return 'NONE' if @errors.empty?
|
33
|
+
|
34
|
+
@errors.map do |k, v|
|
35
|
+
"#{k.inspect} => #{v.inspect}"
|
36
|
+
end.join("\n ")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/decouplio/logic_dsl.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative 'flow'
|
4
4
|
require_relative 'const/types'
|
5
|
-
require_relative 'const/doby_aide_options'
|
6
5
|
require_relative 'const/step_options'
|
7
6
|
require_relative 'octo_hash_case'
|
8
7
|
require_relative 'errors/options_validation_error'
|
@@ -11,7 +10,6 @@ require_relative 'errors/resq_definition_error'
|
|
11
10
|
require_relative 'errors/wrap_block_is_not_defined_error'
|
12
11
|
require_relative 'errors/palp_block_is_not_defined_error'
|
13
12
|
require_relative 'errors/fail_can_not_be_first_step_error'
|
14
|
-
require_relative 'errors/aide_can_not_be_first_step_error'
|
15
13
|
require_relative 'errors/octo_block_is_not_defined_error'
|
16
14
|
|
17
15
|
module Decouplio
|
@@ -130,42 +128,13 @@ module Decouplio
|
|
130
128
|
)
|
131
129
|
end
|
132
130
|
|
133
|
-
def doby(
|
134
|
-
|
135
|
-
|
136
|
-
)
|
137
|
-
step_options = {}
|
138
|
-
options.each_key do |key|
|
139
|
-
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
140
|
-
end
|
141
|
-
doby_options = options
|
142
|
-
|
143
|
-
@steps << {
|
144
|
-
type: Decouplio::Const::Types::DOBY_TYPE,
|
145
|
-
name: doby_class.name.to_sym,
|
146
|
-
doby_class: doby_class,
|
147
|
-
doby_options: doby_options,
|
148
|
-
**step_options
|
149
|
-
}
|
131
|
+
def doby(_doby_class, **_options)
|
132
|
+
raise '"doby" step is deprecated. Please use "step" or "pass" instead. ' \
|
133
|
+
'Just simply replace "doby " with "step " or "pass "'
|
150
134
|
end
|
151
135
|
|
152
|
-
def aide(
|
153
|
-
|
154
|
-
raise Decouplio::Errors::AideCanNotBeFirstStepError if @steps.empty?
|
155
|
-
|
156
|
-
step_options = {}
|
157
|
-
options.each_key do |key|
|
158
|
-
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
159
|
-
end
|
160
|
-
aide_options = options
|
161
|
-
|
162
|
-
@steps << {
|
163
|
-
type: Decouplio::Const::Types::AIDE_TYPE,
|
164
|
-
name: aide_class.name.to_sym,
|
165
|
-
aide_class: aide_class,
|
166
|
-
aide_options: aide_options,
|
167
|
-
**step_options
|
168
|
-
}
|
136
|
+
def aide(_aide_class, **_options)
|
137
|
+
raise '"aide" step is deprecated. Please use "fail". Just simply replace "aide " with "fail "'
|
169
138
|
end
|
170
139
|
end
|
171
140
|
end
|
@@ -10,8 +10,6 @@ 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'
|
15
13
|
require_relative 'errors/invalid_error_class_error'
|
16
14
|
require_relative 'errors/invalid_wrap_name_error'
|
17
15
|
require_relative 'errors/pass_finish_him_error'
|
@@ -23,19 +21,14 @@ require_relative 'errors/step_is_not_defined_for_step_error'
|
|
23
21
|
require_relative 'errors/step_is_not_defined_for_fail_error'
|
24
22
|
require_relative 'errors/step_is_not_defined_for_pass_error'
|
25
23
|
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
24
|
require_relative 'errors/wrap_finish_him_error'
|
29
25
|
require_relative 'errors/wrap_klass_method_error'
|
30
26
|
require_relative 'errors/step_controversial_keys_error'
|
31
|
-
require_relative 'errors/doby_controversial_keys_error'
|
32
|
-
require_relative 'errors/aide_controversial_keys_error'
|
33
27
|
require_relative 'errors/fail_controversial_keys_error'
|
34
28
|
require_relative 'errors/pass_controversial_keys_error'
|
35
29
|
require_relative 'errors/octo_controversial_keys_error'
|
36
30
|
require_relative 'errors/wrap_controversial_keys_error'
|
37
31
|
require_relative 'errors/palp_is_not_defined_error'
|
38
|
-
require_relative 'errors/error_store_error'
|
39
32
|
require_relative 'errors/step_name_error'
|
40
33
|
|
41
34
|
module Decouplio
|
@@ -78,25 +71,18 @@ module Decouplio
|
|
78
71
|
validate_wrap(options: filtered_options, name: options[:name], step_names: step_names)
|
79
72
|
when Decouplio::Const::Types::ACTION_TYPE_STEP
|
80
73
|
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
74
|
validate_step(options: filtered_options, step_names: step_names)
|
83
75
|
when Decouplio::Const::Types::ACTION_TYPE_FAIL
|
84
76
|
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
77
|
validate_fail(options: filtered_options, step_names: step_names)
|
87
78
|
when Decouplio::Const::Types::ACTION_TYPE_PASS
|
88
79
|
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
80
|
validate_pass(options: filtered_options, step_names: step_names)
|
91
81
|
when Decouplio::Const::Types::RESQ_TYPE_STEP,
|
92
82
|
Decouplio::Const::Types::RESQ_TYPE_FAIL,
|
93
83
|
Decouplio::Const::Types::RESQ_TYPE_PASS
|
94
84
|
validate(options: options[:step_to_resq], step_names: step_names)
|
95
85
|
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
86
|
end
|
101
87
|
end
|
102
88
|
|
@@ -154,18 +140,6 @@ module Decouplio
|
|
154
140
|
check_resq_exception_classes_inheritance(options: options)
|
155
141
|
end
|
156
142
|
|
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
143
|
def validate_name(name:)
|
170
144
|
return unless Decouplio::Const::ReservedMethods::NAMES.include?(name)
|
171
145
|
|
@@ -202,34 +176,6 @@ module Decouplio
|
|
202
176
|
end
|
203
177
|
end
|
204
178
|
|
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
179
|
def check_step_presence_for_fail(options:, step_names:)
|
234
180
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
235
181
|
next if %i[on_success on_failure on_error].include?(option_key) &&
|
@@ -280,36 +226,6 @@ module Decouplio
|
|
280
226
|
end
|
281
227
|
end
|
282
228
|
|
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
229
|
def check_fail_extra_keys(options:)
|
314
230
|
extra_keys = options.keys - FAIL_ALLOWED_OPTIONS
|
315
231
|
|
@@ -426,32 +342,6 @@ module Decouplio
|
|
426
342
|
end
|
427
343
|
end
|
428
344
|
|
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
345
|
def check_fail_finish_him(options:)
|
456
346
|
finish_him_value = options.dig(:finish_him)
|
457
347
|
|
@@ -16,7 +16,11 @@ module Decouplio
|
|
16
16
|
|
17
17
|
def process(instance:)
|
18
18
|
instance.append_railway_flow(@name)
|
19
|
-
outcome = @action.call(
|
19
|
+
outcome = @action.call(
|
20
|
+
parent_ctx: instance.ctx,
|
21
|
+
parent_railway_flow: instance.railway_flow,
|
22
|
+
meta_store: instance.ms
|
23
|
+
)
|
20
24
|
|
21
25
|
resolve(outcome: outcome, instance: instance)
|
22
26
|
end
|
@@ -26,8 +30,6 @@ module Decouplio
|
|
26
30
|
def resolve(outcome:, instance:)
|
27
31
|
result = outcome.success?
|
28
32
|
|
29
|
-
instance.error_store.merge(outcome.error_store)
|
30
|
-
|
31
33
|
Decouplio::Steps::Shared::FailResolver.call(
|
32
34
|
instance: instance,
|
33
35
|
result: result,
|
@@ -15,16 +15,18 @@ module Decouplio
|
|
15
15
|
|
16
16
|
def process(instance:)
|
17
17
|
instance.append_railway_flow(@name)
|
18
|
-
|
18
|
+
@action.call(
|
19
|
+
parent_ctx: instance.ctx,
|
20
|
+
parent_railway_flow: instance.railway_flow,
|
21
|
+
meta_store: instance.ms
|
22
|
+
)
|
19
23
|
|
20
|
-
resolve(
|
24
|
+
resolve(instance: instance)
|
21
25
|
end
|
22
26
|
|
23
27
|
private
|
24
28
|
|
25
|
-
def resolve(
|
26
|
-
instance.error_store.merge(outcome.error_store)
|
27
|
-
|
29
|
+
def resolve(instance:)
|
28
30
|
instance.pass_action
|
29
31
|
|
30
32
|
if @on_success_type == Decouplio::Const::Results::FINISH_HIM
|
@@ -16,7 +16,11 @@ module Decouplio
|
|
16
16
|
|
17
17
|
def process(instance:)
|
18
18
|
instance.append_railway_flow(@name)
|
19
|
-
outcome = @action.call(
|
19
|
+
outcome = @action.call(
|
20
|
+
parent_ctx: instance.ctx,
|
21
|
+
parent_railway_flow: instance.railway_flow,
|
22
|
+
meta_store: instance.ms
|
23
|
+
)
|
20
24
|
|
21
25
|
resolve(outcome: outcome, instance: instance)
|
22
26
|
end
|
@@ -26,8 +30,6 @@ module Decouplio
|
|
26
30
|
def resolve(outcome:, instance:)
|
27
31
|
result = outcome.success?
|
28
32
|
|
29
|
-
instance.error_store.merge(outcome.error_store)
|
30
|
-
|
31
33
|
Decouplio::Steps::Shared::StepResolver.call(
|
32
34
|
instance: instance,
|
33
35
|
result: result,
|
@@ -42,16 +42,6 @@ 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
|
-
)
|
55
45
|
end
|
56
46
|
end
|
57
47
|
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.0alpha8
|
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-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,18 +128,16 @@ files:
|
|
128
128
|
- docker-compose.yml
|
129
129
|
- lib/decouplio.rb
|
130
130
|
- lib/decouplio/action.rb
|
131
|
+
- lib/decouplio/action_state_printer.rb
|
131
132
|
- lib/decouplio/composer.rb
|
132
133
|
- lib/decouplio/const/colors.rb
|
133
|
-
- lib/decouplio/const/doby_aide_options.rb
|
134
134
|
- lib/decouplio/const/error_messages.rb
|
135
135
|
- lib/decouplio/const/reserved_methods.rb
|
136
136
|
- lib/decouplio/const/results.rb
|
137
137
|
- lib/decouplio/const/step_options.rb
|
138
138
|
- lib/decouplio/const/types.rb
|
139
139
|
- lib/decouplio/const/validations/action_option_class.rb
|
140
|
-
- lib/decouplio/const/validations/aide.rb
|
141
140
|
- lib/decouplio/const/validations/common.rb
|
142
|
-
- lib/decouplio/const/validations/doby.rb
|
143
141
|
- lib/decouplio/const/validations/fail.rb
|
144
142
|
- lib/decouplio/const/validations/logic.rb
|
145
143
|
- lib/decouplio/const/validations/octo.rb
|
@@ -148,14 +146,9 @@ files:
|
|
148
146
|
- lib/decouplio/const/validations/resq.rb
|
149
147
|
- lib/decouplio/const/validations/step.rb
|
150
148
|
- lib/decouplio/const/validations/wrap.rb
|
151
|
-
- lib/decouplio/
|
149
|
+
- lib/decouplio/default_meta_store.rb
|
152
150
|
- lib/decouplio/errors/action_class_error.rb
|
153
|
-
- lib/decouplio/errors/aide_can_not_be_first_step_error.rb
|
154
|
-
- lib/decouplio/errors/aide_controversial_keys_error.rb
|
155
|
-
- lib/decouplio/errors/aide_finish_him_error.rb
|
156
151
|
- lib/decouplio/errors/base_error.rb
|
157
|
-
- lib/decouplio/errors/doby_controversial_keys_error.rb
|
158
|
-
- lib/decouplio/errors/doby_finish_him_error.rb
|
159
152
|
- lib/decouplio/errors/error_store_error.rb
|
160
153
|
- lib/decouplio/errors/execution_error.rb
|
161
154
|
- lib/decouplio/errors/extra_key_for_fail_error.rb
|
@@ -185,8 +178,6 @@ files:
|
|
185
178
|
- lib/decouplio/errors/resq_handler_method_error.rb
|
186
179
|
- lib/decouplio/errors/step_controversial_keys_error.rb
|
187
180
|
- lib/decouplio/errors/step_finish_him_error.rb
|
188
|
-
- lib/decouplio/errors/step_is_not_defined_for_aide_error.rb
|
189
|
-
- lib/decouplio/errors/step_is_not_defined_for_doby_error.rb
|
190
181
|
- lib/decouplio/errors/step_is_not_defined_for_fail_error.rb
|
191
182
|
- lib/decouplio/errors/step_is_not_defined_for_pass_error.rb
|
192
183
|
- lib/decouplio/errors/step_is_not_defined_for_step_error.rb
|
@@ -202,10 +193,8 @@ files:
|
|
202
193
|
- lib/decouplio/octo_options_validator.rb
|
203
194
|
- lib/decouplio/options_validator.rb
|
204
195
|
- lib/decouplio/processor.rb
|
205
|
-
- lib/decouplio/steps/aide.rb
|
206
196
|
- lib/decouplio/steps/base_resq.rb
|
207
197
|
- lib/decouplio/steps/base_step.rb
|
208
|
-
- lib/decouplio/steps/doby.rb
|
209
198
|
- lib/decouplio/steps/fail.rb
|
210
199
|
- lib/decouplio/steps/if_condition_fail.rb
|
211
200
|
- lib/decouplio/steps/if_condition_pass.rb
|
@@ -1,38 +0,0 @@
|
|
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
|
@@ -1,36 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decouplio
|
4
|
-
class DefaultErrorHandler
|
5
|
-
attr_reader :errors, :status
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@errors = {}
|
9
|
-
@status = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_error(*args)
|
13
|
-
case args.size
|
14
|
-
when 1
|
15
|
-
args[0].each do |key, message|
|
16
|
-
@errors.store(
|
17
|
-
key,
|
18
|
-
(@errors[key] || []) + [message].flatten
|
19
|
-
)
|
20
|
-
end
|
21
|
-
when 2
|
22
|
-
@errors.store(
|
23
|
-
args[0],
|
24
|
-
(@errors[args[0]] || []) + [args[1]].flatten
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def error_status(err_st)
|
30
|
-
@status = err_st
|
31
|
-
end
|
32
|
-
|
33
|
-
def merge(error_store)
|
34
|
-
@errors = @errors.merge(error_store.errors) do |_key, this_val, other_val|
|
35
|
-
this_val + other_val
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,27 +0,0 @@
|
|
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/steps/aide.rb
DELETED
@@ -1,37 +0,0 @@
|
|
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
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'base_step'
|
4
|
-
|
5
|
-
module Decouplio
|
6
|
-
module Steps
|
7
|
-
class Doby < Decouplio::Steps::BaseStep
|
8
|
-
def initialize(name:, doby_class:, doby_options:, on_success_type:, on_failure_type:)
|
9
|
-
super()
|
10
|
-
@name = name
|
11
|
-
@doby_class = doby_class
|
12
|
-
@doby_options = doby_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 = @doby_class.call(
|
20
|
-
ctx: instance.ctx,
|
21
|
-
error_store: instance.error_store,
|
22
|
-
**@doby_options
|
23
|
-
)
|
24
|
-
resolve(result: result, instance: instance)
|
25
|
-
end
|
26
|
-
|
27
|
-
def resolve(result:, instance:)
|
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
|
-
)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|