yaso 1.3.0 → 1.3.2
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/.ruby-version +1 -1
- data/Gemfile.lock +2 -1
- data/benchmark/Gemfile +12 -1
- data/benchmark/index.rb +4 -0
- data/benchmark/step/benchmark.rb +2 -0
- data/benchmark/step/decouplio.rb +11 -11
- data/benchmark/step/dry_transaction.rb +113 -0
- data/benchmark/step/trailblazer.rb +1 -1
- data/docker-compose.yml +2 -8
- data/lib/yaso/logic/failure.rb +2 -1
- data/lib/yaso/logic/pass.rb +2 -1
- data/lib/yaso/logic/step.rb +7 -1
- data/lib/yaso/logic/step_builder.rb +1 -3
- data/lib/yaso/logic/switch.rb +7 -1
- data/lib/yaso/logic/wrap.rb +7 -1
- data/lib/yaso/service.rb +1 -3
- data/lib/yaso/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb519a1032563c51304fc6d3d456317966964555f0e93f3589197c3d1b215aeb
|
|
4
|
+
data.tar.gz: d2959131be6cfad72331c0104419e031f8d6cbf4b42ec2b559c318acc41f5756
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5afe8940444e11435fd6d263a42beeaafa782cbb21956d7d74e45883a09d2de3a23bf2c2883ef0c562a2c06de8366921b90f022dc23ef7def9903fb5ba2a78b2
|
|
7
|
+
data.tar.gz: 2305191823546b18b088289c738d5b1e2a6c0f7b2152e826271aee66a444c8d6ab7e605639eac43ee38b8682b6272f80611d3270ad631d212d3ccc8237aca08c
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.1.
|
|
1
|
+
3.1.3
|
data/Gemfile.lock
CHANGED
data/benchmark/Gemfile
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
4
|
|
|
5
5
|
gem 'benchmark-ips', '~> 2.10.0'
|
|
6
|
+
|
|
7
|
+
DRY_CONTAINER = {
|
|
8
|
+
'2.5' => '~> 0.7.2',
|
|
9
|
+
'2.6' => '~> 0.9.0'
|
|
10
|
+
}.freeze
|
|
11
|
+
gem 'dry-container', DRY_CONTAINER.fetch(RUBY_VERSION.match(/\A\d+\.\d+/)[0], '~> 0.11.0')
|
|
12
|
+
DRY_TRANSACTION = {
|
|
13
|
+
'2.5' => '~> 0.13.2',
|
|
14
|
+
'2.6' => '~> 0.13.3'
|
|
15
|
+
}.freeze
|
|
16
|
+
gem 'dry-transaction', DRY_TRANSACTION.fetch(RUBY_VERSION.match(/\A\d+\.\d+/)[0], '~> 0.15.0')
|
|
6
17
|
gem 'interactor', '~> 3.1.2'
|
|
7
18
|
gem 'kalibera', '~> 0.1.2'
|
|
8
19
|
gem 'simple_command', RUBY_VERSION.include?('2.5') ? '~> 0.2.0' : '~> 1.0.1'
|
|
@@ -11,4 +22,4 @@ gem 'yaso', path: '..'
|
|
|
11
22
|
|
|
12
23
|
gem 'active_interaction', %w[2.5 2.6].any? { |version| RUBY_VERSION.include?(version) } ? '~> 4.1.0' : '~> 5.1.0'
|
|
13
24
|
|
|
14
|
-
RUBY_VERSION.include?('2.5') || gem('decouplio', '~> 1.0.
|
|
25
|
+
RUBY_VERSION.include?('2.5') || gem('decouplio', '~> 1.0.0rc')
|
data/benchmark/index.rb
CHANGED
|
@@ -9,6 +9,9 @@ require 'active_interaction'
|
|
|
9
9
|
require 'trailblazer'
|
|
10
10
|
require 'simple_command'
|
|
11
11
|
require 'yaso'
|
|
12
|
+
require 'dry/container'
|
|
13
|
+
require 'dry/transaction'
|
|
14
|
+
require 'dry/transaction/operation'
|
|
12
15
|
|
|
13
16
|
require_relative 'shared/yaso_service'
|
|
14
17
|
RUBY_VERSION.include?('2.5') || require_relative('shared/decouplio_service')
|
|
@@ -26,4 +29,5 @@ require_relative 'step/simple_command'
|
|
|
26
29
|
require_relative 'step/interactor'
|
|
27
30
|
require_relative 'step/active_interaction'
|
|
28
31
|
require_relative 'step/trailblazer'
|
|
32
|
+
require_relative 'step/dry_transaction'
|
|
29
33
|
require_relative 'step/benchmark'
|
data/benchmark/step/benchmark.rb
CHANGED
|
@@ -13,6 +13,7 @@ Benchmark.ips do |x|
|
|
|
13
13
|
x.report('Interactor') { InteractorStepsService.call }
|
|
14
14
|
x.report('ActiveInteraction') { ActiveInteractionStepsService.run }
|
|
15
15
|
x.report('Trailblazer') { TrailblazerStepsService.call }
|
|
16
|
+
x.report('DryTransaction') { DryTransactionStepsService.new.call({}) }
|
|
16
17
|
|
|
17
18
|
x.compare!
|
|
18
19
|
end
|
|
@@ -28,6 +29,7 @@ Benchmark.ips do |x|
|
|
|
28
29
|
x.report('Interactor') { InteractorCallablesService.call }
|
|
29
30
|
x.report('ActiveInteraction') { ActiveInteractionCallablesService.run }
|
|
30
31
|
x.report('Trailblazer') { TrailblazerCallablesService.call }
|
|
32
|
+
x.report('DryTransaction') { DryTransactionCallablesService.new.call({}) }
|
|
31
33
|
|
|
32
34
|
x.compare!
|
|
33
35
|
end
|
data/benchmark/step/decouplio.rb
CHANGED
|
@@ -14,49 +14,49 @@ class DecouplioStepsService < DecouplioService
|
|
|
14
14
|
step :ten
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def one
|
|
17
|
+
def one
|
|
18
18
|
ctx[:one] = true
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def two
|
|
21
|
+
def two
|
|
22
22
|
ctx[:two] = true
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def three
|
|
25
|
+
def three
|
|
26
26
|
ctx[:three] = true
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def four
|
|
29
|
+
def four
|
|
30
30
|
ctx[:four] = true
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def five
|
|
33
|
+
def five
|
|
34
34
|
ctx[:five] = true
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def six
|
|
37
|
+
def six
|
|
38
38
|
ctx[:six] = true
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def seven
|
|
41
|
+
def seven
|
|
42
42
|
ctx[:seven] = true
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def eight
|
|
45
|
+
def eight
|
|
46
46
|
ctx[:eight] = true
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
def nine
|
|
49
|
+
def nine
|
|
50
50
|
ctx[:nine] = true
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def ten
|
|
53
|
+
def ten
|
|
54
54
|
ctx[:ten] = true
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
class DecouplioCallableStep
|
|
59
|
-
def self.call(ctx
|
|
59
|
+
def self.call(ctx, _, key:, value:, **)
|
|
60
60
|
ctx[key] = value
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class DryTransactionStepsService
|
|
4
|
+
include Dry::Transaction
|
|
5
|
+
|
|
6
|
+
step :one
|
|
7
|
+
step :two
|
|
8
|
+
step :three
|
|
9
|
+
step :four
|
|
10
|
+
step :five
|
|
11
|
+
step :six
|
|
12
|
+
step :seven
|
|
13
|
+
step :eight
|
|
14
|
+
step :nine
|
|
15
|
+
step :ten
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def one(ctx)
|
|
20
|
+
ctx[:one] = true
|
|
21
|
+
Success(ctx)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def two(ctx)
|
|
25
|
+
ctx[:two] = true
|
|
26
|
+
Success(ctx)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def three(ctx)
|
|
30
|
+
ctx[:three] = true
|
|
31
|
+
Success(ctx)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def four(ctx)
|
|
35
|
+
ctx[:four] = true
|
|
36
|
+
Success(ctx)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def five(ctx)
|
|
40
|
+
ctx[:five] = true
|
|
41
|
+
Success(ctx)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def six(ctx)
|
|
45
|
+
ctx[:six] = true
|
|
46
|
+
Success(ctx)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def seven(ctx)
|
|
50
|
+
ctx[:seven] = true
|
|
51
|
+
Success(ctx)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def eight(ctx)
|
|
55
|
+
ctx[:eight] = true
|
|
56
|
+
Success(ctx)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def nine(ctx)
|
|
60
|
+
ctx[:nine] = true
|
|
61
|
+
Success(ctx)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def ten(ctx)
|
|
65
|
+
ctx[:ten] = true
|
|
66
|
+
Success(ctx)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class DryTansactionCallable
|
|
71
|
+
include Dry::Transaction::Operation
|
|
72
|
+
|
|
73
|
+
def initialize(key)
|
|
74
|
+
@key = key
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def call(ctx)
|
|
78
|
+
ctx[@key] = true
|
|
79
|
+
Success(ctx)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class DryTransactionContainer
|
|
84
|
+
extend Dry::Container::Mixin
|
|
85
|
+
|
|
86
|
+
namespace :callable do
|
|
87
|
+
register(:one) { DryTansactionCallable.new(:one) }
|
|
88
|
+
register(:two) { DryTansactionCallable.new(:two) }
|
|
89
|
+
register(:three) { DryTansactionCallable.new(:three) }
|
|
90
|
+
register(:four) { DryTansactionCallable.new(:four) }
|
|
91
|
+
register(:five) { DryTansactionCallable.new(:five) }
|
|
92
|
+
register(:six) { DryTansactionCallable.new(:six) }
|
|
93
|
+
register(:seven) { DryTansactionCallable.new(:seven) }
|
|
94
|
+
register(:eight) { DryTansactionCallable.new(:eight) }
|
|
95
|
+
register(:nine) { DryTansactionCallable.new(:nine) }
|
|
96
|
+
register(:ten) { DryTansactionCallable.new(:ten) }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class DryTransactionCallablesService
|
|
101
|
+
include Dry::Transaction(container: DryTransactionContainer)
|
|
102
|
+
|
|
103
|
+
step :one, with: :'callable.one'
|
|
104
|
+
step :two, with: :'callable.two'
|
|
105
|
+
step :three, with: :'callable.three'
|
|
106
|
+
step :four, with: :'callable.four'
|
|
107
|
+
step :five, with: :'callable.five'
|
|
108
|
+
step :six, with: :'callable.six'
|
|
109
|
+
step :seven, with: :'callable.seven'
|
|
110
|
+
step :eight, with: :'callable.eight'
|
|
111
|
+
step :nine, with: :'callable.nine'
|
|
112
|
+
step :ten, with: :'callable.ten'
|
|
113
|
+
end
|
|
@@ -64,7 +64,7 @@ module TrailblazerMacro
|
|
|
64
64
|
ctx[:"result.#{id}"] = Trailblazer::Operation::Result.new(false, {})
|
|
65
65
|
false
|
|
66
66
|
end
|
|
67
|
-
task = Trailblazer::Activity::
|
|
67
|
+
task = Trailblazer::Activity::Circuit::TaskAdapter.for_step(step)
|
|
68
68
|
{ task: task, id: id }
|
|
69
69
|
end
|
|
70
70
|
# rubocop:enable Naming/MethodName
|
data/docker-compose.yml
CHANGED
data/lib/yaso/logic/failure.rb
CHANGED
data/lib/yaso/logic/pass.rb
CHANGED
data/lib/yaso/logic/step.rb
CHANGED
|
@@ -4,7 +4,13 @@ module Yaso
|
|
|
4
4
|
module Logic
|
|
5
5
|
class Step < Base
|
|
6
6
|
def call(context, instance)
|
|
7
|
-
|
|
7
|
+
instance.success = true
|
|
8
|
+
if @invocable.call(context, instance)
|
|
9
|
+
@next_step
|
|
10
|
+
else
|
|
11
|
+
instance.success = false
|
|
12
|
+
@failure
|
|
13
|
+
end
|
|
8
14
|
end
|
|
9
15
|
end
|
|
10
16
|
end
|
|
@@ -54,9 +54,7 @@ module Yaso
|
|
|
54
54
|
wrapper_class.define_singleton_method(:call) do |context, instance|
|
|
55
55
|
@entry ||= service_class.flow.call(service_class, steps)
|
|
56
56
|
step = @entry
|
|
57
|
-
|
|
58
|
-
step, success = step.call(context, instance) while step
|
|
59
|
-
instance.success = success
|
|
57
|
+
step = step.call(context, instance) while step
|
|
60
58
|
instance
|
|
61
59
|
end
|
|
62
60
|
end
|
data/lib/yaso/logic/switch.rb
CHANGED
|
@@ -4,8 +4,14 @@ module Yaso
|
|
|
4
4
|
module Logic
|
|
5
5
|
class Switch < Base
|
|
6
6
|
def call(context, instance)
|
|
7
|
+
instance.success = true
|
|
7
8
|
switch_case = @invocable.call(context, instance) || raise(UnhandledSwitchCaseError, instance.class)
|
|
8
|
-
Invocable.call(switch_case).last.call(context, instance)
|
|
9
|
+
if Invocable.call(switch_case).last.call(context, instance)
|
|
10
|
+
@next_step
|
|
11
|
+
else
|
|
12
|
+
instance.success = false
|
|
13
|
+
@failure
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
end
|
|
11
17
|
end
|
data/lib/yaso/logic/wrap.rb
CHANGED
|
@@ -9,8 +9,14 @@ module Yaso
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def call(context, instance)
|
|
12
|
+
instance.success = true
|
|
12
13
|
result = @invocable.call(context, instance) { @wrapper.call(context, instance).success? }
|
|
13
|
-
result
|
|
14
|
+
if result
|
|
15
|
+
@next_step
|
|
16
|
+
else
|
|
17
|
+
instance.success = false
|
|
18
|
+
@failure
|
|
19
|
+
end
|
|
14
20
|
end
|
|
15
21
|
end
|
|
16
22
|
end
|
data/lib/yaso/service.rb
CHANGED
|
@@ -40,9 +40,7 @@ module Yaso
|
|
|
40
40
|
@entry ||= flow.call(self, steps)
|
|
41
41
|
step = @entry
|
|
42
42
|
instance = new(context)
|
|
43
|
-
|
|
44
|
-
step, success = step.call(context, instance) while step
|
|
45
|
-
instance.success = success
|
|
43
|
+
step = step.call(context, instance) while step
|
|
46
44
|
instance
|
|
47
45
|
end
|
|
48
46
|
|
data/lib/yaso/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yaso
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Artem Shevchenko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffaker
|
|
@@ -203,6 +203,7 @@ files:
|
|
|
203
203
|
- benchmark/step/active_interaction.rb
|
|
204
204
|
- benchmark/step/benchmark.rb
|
|
205
205
|
- benchmark/step/decouplio.rb
|
|
206
|
+
- benchmark/step/dry_transaction.rb
|
|
206
207
|
- benchmark/step/interactor.rb
|
|
207
208
|
- benchmark/step/pure.rb
|
|
208
209
|
- benchmark/step/simple_command.rb
|
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
250
251
|
- !ruby/object:Gem::Version
|
|
251
252
|
version: '0'
|
|
252
253
|
requirements: []
|
|
253
|
-
rubygems_version: 3.3.
|
|
254
|
+
rubygems_version: 3.3.26
|
|
254
255
|
signing_key:
|
|
255
256
|
specification_version: 4
|
|
256
257
|
summary: Yet Another Service Object
|