decouplio 1.0.0alpha3 → 1.0.0alpha4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +11 -1
- data/.rubocop.yml +3 -0
- data/README.md +2 -17
- data/decouplio.gemspec +4 -4
- data/lib/decouplio/action.rb +12 -0
- data/lib/decouplio/composer.rb +21 -3
- data/lib/decouplio/const/error_messages.rb +9 -0
- data/lib/decouplio/errors/execution_error.rb +20 -0
- data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +27 -0
- data/lib/decouplio/options_validator.rb +45 -10
- data/lib/decouplio/steps/base_resq.rb +13 -3
- data/lib/decouplio/version.rb +1 -1
- metadata +14 -40
- data/docs/_config.yml +0 -1
- data/docs/aide.rb +0 -59
- data/docs/benchmarks.md +0 -1
- data/docs/context.md +0 -74
- data/docs/context.rb +0 -62
- data/docs/doby.rb +0 -38
- data/docs/doby_aide.md +0 -208
- data/docs/error_store.md +0 -347
- data/docs/error_store.rb +0 -202
- data/docs/fail.md +0 -1159
- data/docs/fail.rb +0 -859
- data/docs/index.md +0 -25
- data/docs/inner_action.md +0 -63
- data/docs/inner_action.rb +0 -43
- data/docs/logic_block.md +0 -29
- data/docs/octo.md +0 -326
- data/docs/octo.rb +0 -164
- data/docs/pass.md +0 -309
- data/docs/pass.rb +0 -213
- data/docs/quick_start.md +0 -71
- data/docs/quick_start.rb +0 -38
- data/docs/resq.md +0 -263
- data/docs/resq.rb +0 -176
- data/docs/step.md +0 -885
- data/docs/step.rb +0 -627
- data/docs/step_as_a_service.md +0 -123
- data/docs/step_as_a_service.rb +0 -77
- data/docs/wrap.md +0 -240
- data/docs/wrap.rb +0 -137
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 837f903aec27c7a95ab61c92f4072e040fa4c2dfc74ebcafe0f740428b3cce59
|
4
|
+
data.tar.gz: faeef52b5bc5f8f1abdd419c13cd7871576c86a23e9d5d00c8aa9ab12a150b05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df71fc94709fc03625e36281d5458043616200153deee80fb5e2013900d85f8412a0adb30ce1516a90633e4ecef8aa9ff37d7ff5b7cdfc1aca1b2179aee7e0c
|
7
|
+
data.tar.gz: b39a6be930ed5ce6adf0257537fd5b99392259d889fc236457ed4d9b6f5e69a868648cf2a945f064be25d6978d8ad158001554d0b24da2e32cd92c1fe39a217c
|
data/.circleci/config.yml
CHANGED
@@ -3,7 +3,7 @@ version: 2.1
|
|
3
3
|
executors:
|
4
4
|
test_executor:
|
5
5
|
docker:
|
6
|
-
- image:
|
6
|
+
- image: cimg/ruby:${RUBY_VERSION}
|
7
7
|
working_directory: ~/decouplio
|
8
8
|
|
9
9
|
jobs:
|
@@ -51,3 +51,13 @@ workflows:
|
|
51
51
|
name: 'ruby 3.0.3'
|
52
52
|
ruby_version: 3.0.3
|
53
53
|
bundler_version: 2.2.32
|
54
|
+
# TODO: Currently rspec-mocks has some issue, or maybe decouplio has an issue
|
55
|
+
# needs to be investigated
|
56
|
+
# 3 specs are failing
|
57
|
+
# rspec ./spec/resq_spec.rb:174
|
58
|
+
# rspec ./spec/resq_spec.rb:286
|
59
|
+
# rspec ./spec/resq_spec.rb:398
|
60
|
+
# - build:
|
61
|
+
# name: 'ruby 3.1.2'
|
62
|
+
# ruby_version: 3.1.2
|
63
|
+
# bundler_version: 2.2.32
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -25,26 +25,11 @@ Or install it by yourself:
|
|
25
25
|
- 2.7
|
26
26
|
- 3.0
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
- [Quick start](https://github.com/differencialx/decouplio/blob/master/docs/quick_start.md)
|
31
|
-
- [Logic block](https://github.com/differencialx/decouplio/blob/master/docs/logic_block.md)
|
32
|
-
- [Context](https://github.com/differencialx/decouplio/blob/master/docs/context.md)
|
33
|
-
- [Step](https://github.com/differencialx/decouplio/blob/master/docs/step.md)
|
34
|
-
- [Fail](https://github.com/differencialx/decouplio/blob/master/docs/fail.md)
|
35
|
-
- [Pass](https://github.com/differencialx/decouplio/blob/master/docs/pass.md)
|
36
|
-
- [Octo](https://github.com/differencialx/decouplio/blob/master/docs/octo.md)
|
37
|
-
- [Wrap](https://github.com/differencialx/decouplio/blob/master/docs/wrap.md)
|
38
|
-
- [Resq](https://github.com/differencialx/decouplio/blob/master/docs/resq.md)
|
39
|
-
- [Inner action](https://github.com/differencialx/decouplio/blob/master/docs/inner_action.md)
|
40
|
-
- [Doby/Aide](https://github.com/differencialx/decouplio/blob/master/docs/doby_aide.md)
|
41
|
-
- [Step as a service](https://github.com/differencialx/decouplio/blob/master/docs/step_as_a_service.md)
|
42
|
-
- [Error store](https://github.com/differencialx/decouplio/blob/master/docs/error_store.md)
|
43
|
-
- [Benchmarks](https://github.com/differencialx/decouplio/blob/master/docs/benchmarks.md)
|
28
|
+
### [Documentation is HERE](https://differencialx.github.io/decouplio.github.io/)
|
44
29
|
|
45
30
|
## Contributing
|
46
31
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/differencialx/decouplio.
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/differencialx/decouplio/issues.
|
48
33
|
|
49
34
|
More detailed description for contribution process will be added later.
|
50
35
|
|
data/decouplio.gemspec
CHANGED
@@ -12,13 +12,13 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'Gem for business logic encapsulation'
|
14
14
|
spec.description = "Decouplio is a zero dependency, thread safe and framework agnostic gem designed to encapsulate application business logic. It's reverse engineered through TDD and inspired by such frameworks and gems like Trailblazer, Interactor."
|
15
|
-
spec.homepage = 'https://github.com/differencialx/decouplio'
|
15
|
+
spec.homepage = 'https://github.com/differencialx/decouplio/blob/master/docs'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
if spec.respond_to?(:metadata)
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
-
spec.metadata['source_code_uri'] = 'https://github.com/differencialx/decouplio'
|
21
|
-
spec.metadata['changelog_uri'] = 'https://github.com/differencialx/decouplio/CHANGELOG.md'
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/differencialx/decouplio/blob/master/docs'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/differencialx/decouplio/blob/master/docs/CHANGELOG.md'
|
22
22
|
else
|
23
23
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
24
|
'public gem pushes.'
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'bundler', '~> 2'
|
35
35
|
spec.add_development_dependency 'pry-byebug'
|
36
36
|
spec.add_development_dependency 'rake', '>= 12.3.2'
|
37
|
-
spec.add_development_dependency 'rspec', '
|
37
|
+
spec.add_development_dependency 'rspec', '3.10'
|
38
38
|
spec.add_development_dependency 'rubocop'
|
39
39
|
spec.add_development_dependency 'rubocop-rspec'
|
40
40
|
end
|
data/lib/decouplio/action.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative 'default_error_handler'
|
|
7
7
|
require_relative 'errors/logic_redefinition_error'
|
8
8
|
require_relative 'errors/logic_is_not_defined_error'
|
9
9
|
require_relative 'errors/error_store_error'
|
10
|
+
require_relative 'errors/execution_error'
|
10
11
|
require_relative 'const/results'
|
11
12
|
|
12
13
|
module Decouplio
|
@@ -99,6 +100,17 @@ module Decouplio
|
|
99
100
|
instance
|
100
101
|
end
|
101
102
|
|
103
|
+
def call!(**params)
|
104
|
+
instance = call(**params)
|
105
|
+
if instance.failure?
|
106
|
+
raise Decouplio::Errors::ExecutionError.new(
|
107
|
+
action: instance
|
108
|
+
)
|
109
|
+
else
|
110
|
+
instance
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
102
114
|
private
|
103
115
|
|
104
116
|
def inherited(child_class)
|
data/lib/decouplio/composer.rb
CHANGED
@@ -205,14 +205,16 @@ module Decouplio
|
|
205
205
|
def create_resq_pass(stp, flow)
|
206
206
|
Decouplio::Steps::ResqPass.new(
|
207
207
|
handler_hash: stp[:handler_hash],
|
208
|
-
step_to_resq: create_step_instance(stp[:step_to_resq], flow)
|
208
|
+
step_to_resq: create_step_instance(stp[:step_to_resq], flow),
|
209
|
+
on_error_type: error_type(flow, stp)
|
209
210
|
)
|
210
211
|
end
|
211
212
|
|
212
213
|
def create_resq_fail(stp, flow)
|
213
214
|
Decouplio::Steps::ResqFail.new(
|
214
215
|
handler_hash: stp[:handler_hash],
|
215
|
-
step_to_resq: create_step_instance(stp[:step_to_resq], flow)
|
216
|
+
step_to_resq: create_step_instance(stp[:step_to_resq], flow),
|
217
|
+
on_error_type: error_type(flow, stp)
|
216
218
|
)
|
217
219
|
end
|
218
220
|
|
@@ -467,7 +469,22 @@ module Decouplio
|
|
467
469
|
step_id = stp.dig(:flow, Decouplio::Const::Results::FAIL)
|
468
470
|
if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_failure]
|
469
471
|
Decouplio::Const::Results::STEP_PASS
|
470
|
-
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:
|
472
|
+
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_failure]
|
473
|
+
Decouplio::Const::Results::STEP_FAIL
|
474
|
+
else
|
475
|
+
Decouplio::Const::Types::FAIL_FLOW.include?(
|
476
|
+
flow[step_id]&.[](:type)
|
477
|
+
)
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def error_type(flow, stp)
|
482
|
+
return :finish_him if [:on_error].include?(finish_him(stp))
|
483
|
+
|
484
|
+
step_id = stp.dig(:flow, Decouplio::Const::Results::ERROR)
|
485
|
+
if step_id.nil? && Decouplio::Const::Results::STEP_PASS == stp[:on_error]
|
486
|
+
Decouplio::Const::Results::STEP_PASS
|
487
|
+
elsif step_id.nil? && Decouplio::Const::Results::STEP_FAIL == stp[:on_error]
|
471
488
|
Decouplio::Const::Results::STEP_FAIL
|
472
489
|
else
|
473
490
|
Decouplio::Const::Types::FAIL_FLOW.include?(
|
@@ -576,6 +593,7 @@ module Decouplio
|
|
576
593
|
options_for_resq = stp[:step_to_resq].slice(
|
577
594
|
:on_success,
|
578
595
|
:on_failure,
|
596
|
+
:on_error,
|
579
597
|
:finish_him,
|
580
598
|
:if,
|
581
599
|
:unless
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../const/error_messages'
|
4
|
+
|
5
|
+
module Decouplio
|
6
|
+
module Errors
|
7
|
+
class ExecutionError < StandardError
|
8
|
+
attr_reader :action
|
9
|
+
|
10
|
+
def initialize(action:)
|
11
|
+
@action = action
|
12
|
+
super(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def message
|
16
|
+
Decouplio::Const::ErrorMessages::EXECUTION_ERROR
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_error'
|
4
|
+
require_relative '../const/validations/pass'
|
5
|
+
require_relative '../const/validations/common'
|
6
|
+
|
7
|
+
module Decouplio
|
8
|
+
module Errors
|
9
|
+
class StepIsNotDefinedForPassError < Decouplio::Errors::BaseError
|
10
|
+
def template
|
11
|
+
Decouplio::Const::Validations::Pass::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::Pass::ALLOWED_OPTIONS_MESSAGE,
|
22
|
+
Decouplio::Const::Validations::Pass::MANUAL_URL
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -21,6 +21,7 @@ require_relative 'errors/resq_handler_method_error'
|
|
21
21
|
require_relative 'errors/step_finish_him_error'
|
22
22
|
require_relative 'errors/step_is_not_defined_for_step_error'
|
23
23
|
require_relative 'errors/step_is_not_defined_for_fail_error'
|
24
|
+
require_relative 'errors/step_is_not_defined_for_pass_error'
|
24
25
|
require_relative 'errors/step_is_not_defined_for_wrap_error'
|
25
26
|
require_relative 'errors/step_is_not_defined_for_aide_error'
|
26
27
|
require_relative 'errors/step_is_not_defined_for_doby_error'
|
@@ -70,7 +71,7 @@ module Decouplio
|
|
70
71
|
when Decouplio::Const::Types::FAIL_TYPE
|
71
72
|
validate_fail(options: filtered_options, step_names: step_names)
|
72
73
|
when Decouplio::Const::Types::PASS_TYPE
|
73
|
-
validate_pass(options: filtered_options)
|
74
|
+
validate_pass(options: filtered_options, step_names: step_names)
|
74
75
|
when Decouplio::Const::Types::OCTO_TYPE
|
75
76
|
validate_octo(options: filtered_options, hash_case: options[:hash_case])
|
76
77
|
when Decouplio::Const::Types::WRAP_TYPE
|
@@ -86,7 +87,7 @@ module Decouplio
|
|
86
87
|
when Decouplio::Const::Types::ACTION_TYPE_PASS
|
87
88
|
validate_action(action_class: options[:action], type: Decouplio::Const::Types::PASS_TYPE)
|
88
89
|
validate_error_store(parent_action_class: @action_class, child_action_class: options[:action])
|
89
|
-
validate_pass(options: filtered_options)
|
90
|
+
validate_pass(options: filtered_options, step_names: step_names)
|
90
91
|
when Decouplio::Const::Types::RESQ_TYPE_STEP,
|
91
92
|
Decouplio::Const::Types::RESQ_TYPE_FAIL,
|
92
93
|
Decouplio::Const::Types::RESQ_TYPE_PASS
|
@@ -122,7 +123,8 @@ module Decouplio
|
|
122
123
|
check_fail_finish_him(options: options)
|
123
124
|
end
|
124
125
|
|
125
|
-
def validate_pass(options:)
|
126
|
+
def validate_pass(options:, step_names:)
|
127
|
+
check_step_presence_for_pass(options: options, step_names: step_names)
|
126
128
|
check_pass_extra_keys(options: options)
|
127
129
|
check_pass_finish_him(options: options)
|
128
130
|
end
|
@@ -174,7 +176,8 @@ module Decouplio
|
|
174
176
|
|
175
177
|
def check_step_presence_for_step(options:, step_names:)
|
176
178
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
177
|
-
next if %i[on_success on_failure].include?(option_key) &&
|
179
|
+
next if %i[on_success on_failure on_error].include?(option_key) &&
|
180
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
178
181
|
|
179
182
|
next if step_names.keys.include?(option_value)
|
180
183
|
|
@@ -185,9 +188,24 @@ module Decouplio
|
|
185
188
|
end
|
186
189
|
end
|
187
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
|
+
|
188
205
|
def check_step_presence_for_doby(options:, step_names:)
|
189
206
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
190
|
-
next if %i[on_success on_failure].include?(option_key) &&
|
207
|
+
next if %i[on_success on_failure on_error].include?(option_key) &&
|
208
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
191
209
|
|
192
210
|
next if step_names.keys.include?(option_value)
|
193
211
|
|
@@ -200,7 +218,8 @@ module Decouplio
|
|
200
218
|
|
201
219
|
def check_step_presence_for_aide(options:, step_names:)
|
202
220
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
203
|
-
next if %i[on_success on_failure].include?(option_key) &&
|
221
|
+
next if %i[on_success on_failure on_error].include?(option_key) &&
|
222
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
204
223
|
|
205
224
|
next if step_names.keys.include?(option_value)
|
206
225
|
|
@@ -213,7 +232,8 @@ module Decouplio
|
|
213
232
|
|
214
233
|
def check_step_presence_for_fail(options:, step_names:)
|
215
234
|
options.slice(*STEP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
216
|
-
next if %i[on_success on_failure].include?(option_key) &&
|
235
|
+
next if %i[on_success on_failure on_error].include?(option_key) &&
|
236
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
217
237
|
|
218
238
|
next if step_names.keys.include?(option_value)
|
219
239
|
|
@@ -226,7 +246,8 @@ module Decouplio
|
|
226
246
|
|
227
247
|
def check_step_presence_for_wrap(options:, step_names:)
|
228
248
|
options.slice(*WRAP_CHECK_STEP_PRESENCE).each do |option_key, option_value|
|
229
|
-
next if %i[on_success on_failure].include?(option_key) &&
|
249
|
+
next if %i[on_success on_failure on_error].include?(option_key) &&
|
250
|
+
STEP_ALLOWED_ON_S_ON_F_VALUES.include?(option_value)
|
230
251
|
|
231
252
|
next if step_names.keys.include?(option_value)
|
232
253
|
|
@@ -555,12 +576,14 @@ module Decouplio
|
|
555
576
|
STEP_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
556
577
|
on_success
|
557
578
|
on_failure
|
579
|
+
on_error
|
558
580
|
if
|
559
581
|
unless
|
560
582
|
].freeze
|
561
583
|
STEP_CHECK_STEP_PRESENCE = %i[
|
562
584
|
on_success
|
563
585
|
on_failure
|
586
|
+
on_error
|
564
587
|
].freeze
|
565
588
|
STEP_ALLOWED_ON_S_ON_F_VALUES = [
|
566
589
|
Decouplio::Const::Results::STEP_PASS,
|
@@ -570,6 +593,7 @@ module Decouplio
|
|
570
593
|
STEP_ALLOWED_OPTIONS = %i[
|
571
594
|
on_success
|
572
595
|
on_failure
|
596
|
+
on_error
|
573
597
|
finish_him
|
574
598
|
if
|
575
599
|
unless
|
@@ -578,6 +602,7 @@ module Decouplio
|
|
578
602
|
ALLOWED_STEP_FINISH_HIM_VALUES = %i[
|
579
603
|
on_success
|
580
604
|
on_failure
|
605
|
+
on_error
|
581
606
|
].freeze
|
582
607
|
|
583
608
|
# *************************************************
|
@@ -591,12 +616,13 @@ module Decouplio
|
|
591
616
|
FAIL_ALLOWED_OPTIONS = %i[
|
592
617
|
on_success
|
593
618
|
on_failure
|
619
|
+
on_error
|
594
620
|
finish_him
|
595
621
|
if
|
596
622
|
unless
|
597
623
|
action
|
598
624
|
].freeze
|
599
|
-
ALLOWED_FAIL_FINISH_HIM_VALUES = [true, :on_success, :on_failure].freeze
|
625
|
+
ALLOWED_FAIL_FINISH_HIM_VALUES = [true, :on_success, :on_failure, :on_error].freeze
|
600
626
|
|
601
627
|
# *************************************************
|
602
628
|
# PASS
|
@@ -607,13 +633,17 @@ module Decouplio
|
|
607
633
|
if
|
608
634
|
unless
|
609
635
|
action
|
636
|
+
on_error
|
610
637
|
].freeze
|
611
638
|
|
612
639
|
PASS_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
613
640
|
if
|
614
641
|
unless
|
615
642
|
].freeze
|
616
|
-
|
643
|
+
PASS_CHECK_STEP_PRESENCE = %i[
|
644
|
+
on_error
|
645
|
+
].freeze
|
646
|
+
ALLOWED_PASS_FINISH_HIM_VALUES = [true, :on_error].freeze
|
617
647
|
|
618
648
|
# *************************************************
|
619
649
|
# OCTO
|
@@ -641,16 +671,19 @@ module Decouplio
|
|
641
671
|
WRAP_CHECK_METHOD_EXISTENCE_OPTIONS = %i[
|
642
672
|
on_success
|
643
673
|
on_failure
|
674
|
+
on_error
|
644
675
|
if
|
645
676
|
unless
|
646
677
|
].freeze
|
647
678
|
WRAP_CHECK_STEP_PRESENCE = %i[
|
648
679
|
on_success
|
649
680
|
on_failure
|
681
|
+
on_error
|
650
682
|
].freeze
|
651
683
|
WRAP_ALLOWED_OPTIONS = %i[
|
652
684
|
on_success
|
653
685
|
on_failure
|
686
|
+
on_error
|
654
687
|
finish_him
|
655
688
|
if
|
656
689
|
unless
|
@@ -661,6 +694,7 @@ module Decouplio
|
|
661
694
|
ALLOWED_WRAP_FINISH_HIM_VALUES = %i[
|
662
695
|
on_success
|
663
696
|
on_failure
|
697
|
+
on_error
|
664
698
|
].freeze
|
665
699
|
|
666
700
|
# *************************************************
|
@@ -670,6 +704,7 @@ module Decouplio
|
|
670
704
|
RESQ_NOT_ALLOWED_OPTIONS = %i[
|
671
705
|
on_success
|
672
706
|
on_failure
|
707
|
+
on_error
|
673
708
|
finish_him
|
674
709
|
if
|
675
710
|
unless
|
@@ -5,10 +5,11 @@ require_relative 'base_step'
|
|
5
5
|
module Decouplio
|
6
6
|
module Steps
|
7
7
|
class BaseResq < BaseStep
|
8
|
-
def initialize(handler_hash:, step_to_resq:)
|
8
|
+
def initialize(handler_hash:, step_to_resq:, on_error_type:)
|
9
9
|
super()
|
10
10
|
@handler_hash = handler_hash
|
11
11
|
@step_to_resq = step_to_resq
|
12
|
+
@on_error_type = on_error_type
|
12
13
|
end
|
13
14
|
|
14
15
|
def process(instance:)
|
@@ -21,8 +22,17 @@ module Decouplio
|
|
21
22
|
instance.append_railway_flow(handler_method)
|
22
23
|
instance.public_send(handler_method, e, **instance.ctx)
|
23
24
|
|
24
|
-
|
25
|
-
Decouplio::Const::Results::
|
25
|
+
case @on_error_type
|
26
|
+
when Decouplio::Const::Results::PASS, Decouplio::Const::Results::STEP_PASS
|
27
|
+
instance.pass_action
|
28
|
+
Decouplio::Const::Results::ERROR
|
29
|
+
when Decouplio::Const::Results::FINISH_HIM
|
30
|
+
instance.fail_action
|
31
|
+
Decouplio::Const::Results::FINISH_HIM
|
32
|
+
else
|
33
|
+
instance.fail_action
|
34
|
+
Decouplio::Const::Results::ERROR
|
35
|
+
end
|
26
36
|
else
|
27
37
|
result
|
28
38
|
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.0alpha4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Bal
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,40 +126,12 @@ files:
|
|
126
126
|
- bin/setup
|
127
127
|
- decouplio.gemspec
|
128
128
|
- docker-compose.yml
|
129
|
-
- docs/_config.yml
|
130
|
-
- docs/aide.rb
|
131
|
-
- docs/benchmarks.md
|
132
|
-
- docs/context.md
|
133
|
-
- docs/context.rb
|
134
|
-
- docs/doby.rb
|
135
|
-
- docs/doby_aide.md
|
136
|
-
- docs/error_store.md
|
137
|
-
- docs/error_store.rb
|
138
|
-
- docs/fail.md
|
139
|
-
- docs/fail.rb
|
140
|
-
- docs/index.md
|
141
|
-
- docs/inner_action.md
|
142
|
-
- docs/inner_action.rb
|
143
|
-
- docs/logic_block.md
|
144
|
-
- docs/octo.md
|
145
|
-
- docs/octo.rb
|
146
|
-
- docs/pass.md
|
147
|
-
- docs/pass.rb
|
148
|
-
- docs/quick_start.md
|
149
|
-
- docs/quick_start.rb
|
150
|
-
- docs/resq.md
|
151
|
-
- docs/resq.rb
|
152
|
-
- docs/step.md
|
153
|
-
- docs/step.rb
|
154
|
-
- docs/step_as_a_service.md
|
155
|
-
- docs/step_as_a_service.rb
|
156
|
-
- docs/wrap.md
|
157
|
-
- docs/wrap.rb
|
158
129
|
- lib/decouplio.rb
|
159
130
|
- lib/decouplio/action.rb
|
160
131
|
- lib/decouplio/composer.rb
|
161
132
|
- lib/decouplio/const/colors.rb
|
162
133
|
- lib/decouplio/const/doby_aide_options.rb
|
134
|
+
- lib/decouplio/const/error_messages.rb
|
163
135
|
- lib/decouplio/const/reserved_methods.rb
|
164
136
|
- lib/decouplio/const/results.rb
|
165
137
|
- lib/decouplio/const/types.rb
|
@@ -184,6 +156,7 @@ files:
|
|
184
156
|
- lib/decouplio/errors/doby_controversial_keys_error.rb
|
185
157
|
- lib/decouplio/errors/doby_finish_him_error.rb
|
186
158
|
- lib/decouplio/errors/error_store_error.rb
|
159
|
+
- lib/decouplio/errors/execution_error.rb
|
187
160
|
- lib/decouplio/errors/extra_key_for_fail_error.rb
|
188
161
|
- lib/decouplio/errors/extra_key_for_octo_error.rb
|
189
162
|
- lib/decouplio/errors/extra_key_for_pass_error.rb
|
@@ -214,6 +187,7 @@ files:
|
|
214
187
|
- lib/decouplio/errors/step_is_not_defined_for_aide_error.rb
|
215
188
|
- lib/decouplio/errors/step_is_not_defined_for_doby_error.rb
|
216
189
|
- lib/decouplio/errors/step_is_not_defined_for_fail_error.rb
|
190
|
+
- lib/decouplio/errors/step_is_not_defined_for_pass_error.rb
|
217
191
|
- lib/decouplio/errors/step_is_not_defined_for_step_error.rb
|
218
192
|
- lib/decouplio/errors/step_is_not_defined_for_wrap_error.rb
|
219
193
|
- lib/decouplio/errors/step_name_error.rb
|
@@ -252,13 +226,13 @@ files:
|
|
252
226
|
- lib/decouplio/steps/wrap.rb
|
253
227
|
- lib/decouplio/validators/condition.rb
|
254
228
|
- lib/decouplio/version.rb
|
255
|
-
homepage: https://github.com/differencialx/decouplio
|
229
|
+
homepage: https://github.com/differencialx/decouplio/blob/master/docs
|
256
230
|
licenses:
|
257
231
|
- MIT
|
258
232
|
metadata:
|
259
|
-
homepage_uri: https://github.com/differencialx/decouplio
|
260
|
-
source_code_uri: https://github.com/differencialx/decouplio
|
261
|
-
changelog_uri: https://github.com/differencialx/decouplio/CHANGELOG.md
|
233
|
+
homepage_uri: https://github.com/differencialx/decouplio/blob/master/docs
|
234
|
+
source_code_uri: https://github.com/differencialx/decouplio/blob/master/docs
|
235
|
+
changelog_uri: https://github.com/differencialx/decouplio/blob/master/docs/CHANGELOG.md
|
262
236
|
post_install_message:
|
263
237
|
rdoc_options: []
|
264
238
|
require_paths:
|
@@ -274,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
248
|
- !ruby/object:Gem::Version
|
275
249
|
version: 1.3.1
|
276
250
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
251
|
+
rubygems_version: 3.2.33
|
278
252
|
signing_key:
|
279
253
|
specification_version: 4
|
280
254
|
summary: Gem for business logic encapsulation
|
data/docs/_config.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
theme: jekyll-theme-cayman
|
data/docs/aide.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require_relative '../lib/decouplio'
|
2
|
-
|
3
|
-
class SemanticAide
|
4
|
-
def self.call(ctx:, error_store:, semantic:, error_message:)
|
5
|
-
ctx[:semantic] = semantic
|
6
|
-
error_store.add_error(semantic, error_message)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class SomeAction < Decouplio::Action
|
11
|
-
logic do
|
12
|
-
step :step_one
|
13
|
-
aide SemanticAide, semantic: :bad_request, error_message: 'Bad request'
|
14
|
-
step :step_two
|
15
|
-
end
|
16
|
-
|
17
|
-
def step_one(step_one_param:, **)
|
18
|
-
ctx[:step_one] = step_one_param
|
19
|
-
end
|
20
|
-
|
21
|
-
def step_two(**)
|
22
|
-
ctx[:step_two] = 'Success'
|
23
|
-
end
|
24
|
-
|
25
|
-
def fail_one(**)
|
26
|
-
ctx[:fail_one] = 'Failure'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
success_action = SomeAction.call(step_one_param: true)
|
31
|
-
failure_action = SomeAction.call(step_one_param: false)
|
32
|
-
|
33
|
-
success_action # =>
|
34
|
-
# Result: success
|
35
|
-
|
36
|
-
# Railway Flow:
|
37
|
-
# step_one -> step_two
|
38
|
-
|
39
|
-
# Context:
|
40
|
-
# :step_one_param => true
|
41
|
-
# :step_one => true
|
42
|
-
# :step_two => "Success"
|
43
|
-
|
44
|
-
# Errors:
|
45
|
-
# None
|
46
|
-
|
47
|
-
failure_action # =>
|
48
|
-
# Result: failure
|
49
|
-
|
50
|
-
# Railway Flow:
|
51
|
-
# step_one -> SemanticAide
|
52
|
-
|
53
|
-
# Context:
|
54
|
-
# :step_one_param => false
|
55
|
-
# :step_one => false
|
56
|
-
# :semantic => :bad_request
|
57
|
-
|
58
|
-
# Errors:
|
59
|
-
# :bad_request => ["Bad request"]
|
data/docs/benchmarks.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
## Benchmarks
|