decouplio 1.0.0alpha5 → 1.0.0alpha7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/decouplio.gemspec +1 -1
- data/lib/decouplio/action.rb +1 -3
- data/lib/decouplio/composer.rb +3 -0
- data/lib/decouplio/const/step_options.rb +16 -0
- data/lib/decouplio/default_error_handler.rb +21 -6
- data/lib/decouplio/logic_dsl.rb +52 -3
- data/lib/decouplio/options_validator.rb +1 -0
- data/lib/decouplio/steps/service_fail.rb +4 -2
- data/lib/decouplio/steps/service_pass.rb +4 -2
- data/lib/decouplio/steps/service_step.rb +4 -2
- data/lib/decouplio/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b142d4fd94ec689714987c59946aab6c14d7d857a4aa11e55c624c5f7975e622
|
4
|
+
data.tar.gz: fc96e94c4d3358fda4eca1e80bfaeb7021a444bc5d9d1ff41b2b1b5f2283dbda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc456438780d78c73280883a8b780148568e0a3ac5a2d21162575c73be6a7401378d6a37367aa31f28878226a274a27803da6ecf2b8b2e976b04b536829f3c1
|
7
|
+
data.tar.gz: 760d3c4a61d0985b4b49633f3c010107a5833e241ac133613439f9f9f031417e022af02ccef23e77681db22d6fdaeb3d186a18d46237bcd216a22dc0388f77eb
|
data/decouplio.gemspec
CHANGED
@@ -12,7 +12,7 @@ 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.
|
15
|
+
spec.homepage = 'https://differencialx.github.io/decouplio.github.io/'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
if spec.respond_to?(:metadata)
|
data/lib/decouplio/action.rb
CHANGED
@@ -12,10 +12,8 @@ require_relative 'const/results'
|
|
12
12
|
|
13
13
|
module Decouplio
|
14
14
|
class Action
|
15
|
-
PREVIOUS_STEP_INDEX = -2
|
16
|
-
|
17
15
|
extend Forwardable
|
18
|
-
def_delegators :@error_store, :errors, :add_error
|
16
|
+
def_delegators :@error_store, :errors, :add_error, :error_status
|
19
17
|
attr_reader :railway_flow, :ctx, :error_store
|
20
18
|
|
21
19
|
def initialize(
|
data/lib/decouplio/composer.rb
CHANGED
@@ -249,6 +249,7 @@ module Decouplio
|
|
249
249
|
Decouplio::Steps::ServiceStep.new(
|
250
250
|
name: stp[:name],
|
251
251
|
service: stp[:service],
|
252
|
+
args: stp[:_args],
|
252
253
|
on_success_type: success_type(flow, stp),
|
253
254
|
on_failure_type: failure_type(flow, stp)
|
254
255
|
)
|
@@ -258,6 +259,7 @@ module Decouplio
|
|
258
259
|
Decouplio::Steps::ServiceFail.new(
|
259
260
|
name: stp[:name],
|
260
261
|
service: stp[:service],
|
262
|
+
args: stp[:_args],
|
261
263
|
on_success_type: success_type(flow, stp),
|
262
264
|
on_failure_type: failure_type(flow, stp)
|
263
265
|
)
|
@@ -267,6 +269,7 @@ module Decouplio
|
|
267
269
|
Decouplio::Steps::ServicePass.new(
|
268
270
|
name: stp[:name],
|
269
271
|
service: stp[:service],
|
272
|
+
args: stp[:_args],
|
270
273
|
on_success_type: success_type(flow, stp),
|
271
274
|
on_failure_type: failure_type(flow, stp)
|
272
275
|
)
|
@@ -2,17 +2,32 @@
|
|
2
2
|
|
3
3
|
module Decouplio
|
4
4
|
class DefaultErrorHandler
|
5
|
-
attr_reader :errors
|
5
|
+
attr_reader :errors, :status
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@errors = {}
|
9
|
+
@status = nil
|
9
10
|
end
|
10
11
|
|
11
|
-
def add_error(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
16
31
|
end
|
17
32
|
|
18
33
|
def merge(error_store)
|
data/lib/decouplio/logic_dsl.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'flow'
|
4
4
|
require_relative 'const/types'
|
5
5
|
require_relative 'const/doby_aide_options'
|
6
|
+
require_relative 'const/step_options'
|
6
7
|
require_relative 'octo_hash_case'
|
7
8
|
require_relative 'errors/options_validation_error'
|
8
9
|
require_relative 'errors/palp_validation_error'
|
@@ -30,17 +31,61 @@ module Decouplio
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def step(stp, **options)
|
33
|
-
|
34
|
+
if stp.is_a?(Class) && !(stp < Decouplio::Action)
|
35
|
+
step_options = {}
|
36
|
+
|
37
|
+
options.each_key do |key|
|
38
|
+
step_options[key] = options.delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key)
|
39
|
+
end
|
40
|
+
|
41
|
+
@steps << {
|
42
|
+
type: Decouplio::Const::Types::STEP_TYPE,
|
43
|
+
name: stp,
|
44
|
+
_args: options,
|
45
|
+
**step_options
|
46
|
+
}
|
47
|
+
else
|
48
|
+
@steps << options.merge(type: Decouplio::Const::Types::STEP_TYPE, name: stp)
|
49
|
+
end
|
34
50
|
end
|
35
51
|
|
36
52
|
def fail(stp, **options)
|
37
53
|
raise Decouplio::Errors::FailCanNotBeFirstStepError if @steps.empty?
|
38
54
|
|
39
|
-
|
55
|
+
if stp.is_a?(Class) && !(stp < Decouplio::Action)
|
56
|
+
step_options = {}
|
57
|
+
options.each_key do |key|
|
58
|
+
step_options[key] = options.delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key)
|
59
|
+
end
|
60
|
+
|
61
|
+
@steps << {
|
62
|
+
type: Decouplio::Const::Types::FAIL_TYPE,
|
63
|
+
name: stp,
|
64
|
+
_args: options,
|
65
|
+
**step_options
|
66
|
+
}
|
67
|
+
else
|
68
|
+
@steps << options.merge(type: Decouplio::Const::Types::FAIL_TYPE, name: stp)
|
69
|
+
end
|
40
70
|
end
|
41
71
|
|
42
72
|
def pass(stp, **options)
|
43
|
-
|
73
|
+
if stp.is_a?(Class) && !(stp < Decouplio::Action)
|
74
|
+
step_options = {}
|
75
|
+
|
76
|
+
options.each_key do |key|
|
77
|
+
step_options[key] = options.delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key)
|
78
|
+
end
|
79
|
+
|
80
|
+
@steps << {
|
81
|
+
type: Decouplio::Const::Types::PASS_TYPE,
|
82
|
+
name: stp,
|
83
|
+
_args: options,
|
84
|
+
**step_options
|
85
|
+
}
|
86
|
+
else
|
87
|
+
@steps << options.merge(type: Decouplio::Const::Types::PASS_TYPE, name: stp)
|
88
|
+
end
|
44
89
|
end
|
45
90
|
|
46
91
|
def octo(octo_name, **options, &block)
|
@@ -86,6 +131,9 @@ module Decouplio
|
|
86
131
|
end
|
87
132
|
|
88
133
|
def doby(doby_class, **options)
|
134
|
+
warn(
|
135
|
+
'DEPRECATION WARNING: "doby" step type will be deprecated at alpha8 version. Use "step" or "pass" instead.'
|
136
|
+
)
|
89
137
|
step_options = {}
|
90
138
|
options.each_key do |key|
|
91
139
|
step_options[key] = options.delete(key) if Decouplio::Const::DobyAideOptions::ALLOWED.include?(key)
|
@@ -102,6 +150,7 @@ module Decouplio
|
|
102
150
|
end
|
103
151
|
|
104
152
|
def aide(aide_class, **options)
|
153
|
+
warn('DEPRECATION WARNING: "aide" step type will be deprecated at alpha8 version. Use "fail" instead.')
|
105
154
|
raise Decouplio::Errors::AideCanNotBeFirstStepError if @steps.empty?
|
106
155
|
|
107
156
|
step_options = {}
|
@@ -6,10 +6,11 @@ require_relative 'shared/fail_resolver'
|
|
6
6
|
module Decouplio
|
7
7
|
module Steps
|
8
8
|
class ServiceFail < Decouplio::Steps::BaseStep
|
9
|
-
def initialize(name:, service:, on_success_type:, on_failure_type:)
|
9
|
+
def initialize(name:, service:, args:, on_success_type:, on_failure_type:)
|
10
10
|
super()
|
11
11
|
@name = name
|
12
12
|
@service = service
|
13
|
+
@args = args
|
13
14
|
@on_success_type = on_success_type
|
14
15
|
@on_failure_type = on_failure_type
|
15
16
|
end
|
@@ -18,7 +19,8 @@ module Decouplio
|
|
18
19
|
instance.append_railway_flow(@name)
|
19
20
|
result = @service.call(
|
20
21
|
ctx: instance.ctx,
|
21
|
-
error_store: instance.error_store
|
22
|
+
error_store: instance.error_store,
|
23
|
+
**@args
|
22
24
|
)
|
23
25
|
|
24
26
|
resolve(result: result, instance: instance)
|
@@ -5,10 +5,11 @@ require_relative 'base_step'
|
|
5
5
|
module Decouplio
|
6
6
|
module Steps
|
7
7
|
class ServicePass < Decouplio::Steps::BaseStep
|
8
|
-
def initialize(name:, service:, on_success_type:, on_failure_type:)
|
8
|
+
def initialize(name:, service:, args:, on_success_type:, on_failure_type:)
|
9
9
|
super()
|
10
10
|
@name = name
|
11
11
|
@service = service
|
12
|
+
@args = args
|
12
13
|
@on_success_type = on_success_type
|
13
14
|
@on_failure_type = on_failure_type
|
14
15
|
end
|
@@ -17,7 +18,8 @@ module Decouplio
|
|
17
18
|
instance.append_railway_flow(@name)
|
18
19
|
@service.call(
|
19
20
|
ctx: instance.ctx,
|
20
|
-
error_store: instance.error_store
|
21
|
+
error_store: instance.error_store,
|
22
|
+
**@args
|
21
23
|
)
|
22
24
|
|
23
25
|
resolve(instance: instance)
|
@@ -6,10 +6,11 @@ require_relative 'shared/step_resolver'
|
|
6
6
|
module Decouplio
|
7
7
|
module Steps
|
8
8
|
class ServiceStep < Decouplio::Steps::BaseStep
|
9
|
-
def initialize(name:, service:, on_success_type:, on_failure_type:)
|
9
|
+
def initialize(name:, service:, args:, on_success_type:, on_failure_type:)
|
10
10
|
super()
|
11
11
|
@name = name
|
12
12
|
@service = service
|
13
|
+
@args = args
|
13
14
|
@on_success_type = on_success_type
|
14
15
|
@on_failure_type = on_failure_type
|
15
16
|
end
|
@@ -18,7 +19,8 @@ module Decouplio
|
|
18
19
|
instance.append_railway_flow(@name)
|
19
20
|
result = @service.call(
|
20
21
|
ctx: instance.ctx,
|
21
|
-
error_store: instance.error_store
|
22
|
+
error_store: instance.error_store,
|
23
|
+
**@args
|
22
24
|
)
|
23
25
|
|
24
26
|
resolve(result: result, instance: instance)
|
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.0alpha7
|
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-07-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/decouplio/const/error_messages.rb
|
135
135
|
- lib/decouplio/const/reserved_methods.rb
|
136
136
|
- lib/decouplio/const/results.rb
|
137
|
+
- lib/decouplio/const/step_options.rb
|
137
138
|
- lib/decouplio/const/types.rb
|
138
139
|
- lib/decouplio/const/validations/action_option_class.rb
|
139
140
|
- lib/decouplio/const/validations/aide.rb
|
@@ -226,11 +227,11 @@ files:
|
|
226
227
|
- lib/decouplio/steps/wrap.rb
|
227
228
|
- lib/decouplio/validators/condition.rb
|
228
229
|
- lib/decouplio/version.rb
|
229
|
-
homepage: https://github.
|
230
|
+
homepage: https://differencialx.github.io/decouplio.github.io/
|
230
231
|
licenses:
|
231
232
|
- MIT
|
232
233
|
metadata:
|
233
|
-
homepage_uri: https://github.
|
234
|
+
homepage_uri: https://differencialx.github.io/decouplio.github.io/
|
234
235
|
source_code_uri: https://github.com/differencialx/decouplio/blob/master/docs
|
235
236
|
changelog_uri: https://github.com/differencialx/decouplio/blob/master/docs/CHANGELOG.md
|
236
237
|
post_install_message:
|