yaso 1.3.2 → 1.4.0
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 +18 -25
- data/.ruby-version +1 -1
- data/.simplecov +2 -4
- data/.tool-versions +1 -0
- data/Gemfile +21 -3
- data/README.md +12 -8
- data/Rakefile +3 -5
- data/benchmark/Gemfile +12 -21
- data/benchmark/gemfiles/ruby_2/Gemfile +1 -0
- data/benchmark/gemfiles/ruby_3/Gemfile +1 -0
- data/benchmark/index.rb +31 -30
- data/benchmark/shared/active_interaction_service.rb +0 -2
- data/benchmark/shared/callable_step.rb +0 -2
- data/benchmark/shared/decouplio_service.rb +0 -2
- data/benchmark/shared/interactor_service.rb +0 -2
- data/benchmark/shared/pure_service.rb +0 -2
- data/benchmark/shared/simple_command_service.rb +0 -2
- data/benchmark/shared/simple_logic_step_service.rb +2 -0
- data/benchmark/shared/trailblazer_service.rb +0 -2
- data/benchmark/shared/yaso_service.rb +0 -2
- data/benchmark/step/active_interaction.rb +0 -2
- data/benchmark/step/benchmark.rb +22 -21
- data/benchmark/step/decouplio.rb +1 -3
- data/benchmark/step/dry_transaction.rb +10 -12
- data/benchmark/step/interactor.rb +9 -11
- data/benchmark/step/pure.rb +0 -2
- data/benchmark/step/simple_command.rb +0 -2
- data/benchmark/step/simple_logic_step.rb +71 -0
- data/benchmark/step/trailblazer.rb +1 -3
- data/benchmark/step/yaso.rb +0 -2
- data/docker-compose.yml +2 -0
- data/gemfiles/ruby_2/Gemfile +8 -0
- data/gemfiles/ruby_3/Gemfile +8 -0
- data/gemfiles/ruby_3_0/Gemfile +8 -0
- data/lib/yaso/errors.rb +0 -2
- data/lib/yaso/{logic → flows}/classic.rb +6 -8
- data/lib/yaso/{logic → flows}/rollback.rb +7 -9
- data/lib/yaso/flows.rb +11 -0
- data/lib/yaso/invocable.rb +16 -14
- data/lib/yaso/service.rb +2 -4
- data/lib/yaso/step_builder.rb +63 -0
- data/lib/yaso/stepable.rb +1 -3
- data/lib/yaso/{logic → steps}/base.rb +1 -3
- data/lib/yaso/{logic → steps}/failure.rb +1 -3
- data/lib/yaso/{logic → steps}/pass.rb +1 -3
- data/lib/yaso/{logic → steps}/step.rb +1 -3
- data/lib/yaso/{logic → steps}/switch.rb +1 -3
- data/lib/yaso/{logic → steps}/wrap.rb +1 -3
- data/lib/yaso/steps.rb +11 -0
- data/lib/yaso/version.rb +1 -3
- data/lib/yaso.rb +8 -8
- metadata +28 -187
- data/Gemfile.lock +0 -83
- data/lib/yaso/logic/step_builder.rb +0 -63
- data/lib/yaso/logic.rb +0 -20
data/Gemfile.lock
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
yaso (1.3.2)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
ast (2.4.2)
|
|
10
|
-
coderay (1.1.3)
|
|
11
|
-
diff-lcs (1.5.0)
|
|
12
|
-
docile (1.4.0)
|
|
13
|
-
ffaker (2.21.0)
|
|
14
|
-
lefthook (1.0.5)
|
|
15
|
-
method_source (1.0.0)
|
|
16
|
-
parallel (1.22.1)
|
|
17
|
-
parser (3.1.2.1)
|
|
18
|
-
ast (~> 2.4.1)
|
|
19
|
-
pry (0.14.1)
|
|
20
|
-
coderay (~> 1.1)
|
|
21
|
-
method_source (~> 1.0)
|
|
22
|
-
rainbow (3.1.1)
|
|
23
|
-
rake (13.0.6)
|
|
24
|
-
regexp_parser (2.5.0)
|
|
25
|
-
rexml (3.2.5)
|
|
26
|
-
rspec (3.11.0)
|
|
27
|
-
rspec-core (~> 3.11.0)
|
|
28
|
-
rspec-expectations (~> 3.11.0)
|
|
29
|
-
rspec-mocks (~> 3.11.0)
|
|
30
|
-
rspec-core (3.11.0)
|
|
31
|
-
rspec-support (~> 3.11.0)
|
|
32
|
-
rspec-expectations (3.11.1)
|
|
33
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
|
-
rspec-support (~> 3.11.0)
|
|
35
|
-
rspec-mocks (3.11.1)
|
|
36
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
-
rspec-support (~> 3.11.0)
|
|
38
|
-
rspec-support (3.11.1)
|
|
39
|
-
rubocop (1.28.2)
|
|
40
|
-
parallel (~> 1.10)
|
|
41
|
-
parser (>= 3.1.0.0)
|
|
42
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
43
|
-
regexp_parser (>= 1.8, < 3.0)
|
|
44
|
-
rexml
|
|
45
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
|
46
|
-
ruby-progressbar (~> 1.7)
|
|
47
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
|
48
|
-
rubocop-ast (1.17.0)
|
|
49
|
-
parser (>= 3.1.1.0)
|
|
50
|
-
rubocop-performance (1.13.3)
|
|
51
|
-
rubocop (>= 1.7.0, < 2.0)
|
|
52
|
-
rubocop-ast (>= 0.4.0)
|
|
53
|
-
rubocop-rspec (2.10.0)
|
|
54
|
-
rubocop (~> 1.19)
|
|
55
|
-
ruby-progressbar (1.11.0)
|
|
56
|
-
simplecov (0.21.2)
|
|
57
|
-
docile (~> 1.1)
|
|
58
|
-
simplecov-html (~> 0.11)
|
|
59
|
-
simplecov_json_formatter (~> 0.1)
|
|
60
|
-
simplecov-html (0.12.3)
|
|
61
|
-
simplecov_json_formatter (0.1.4)
|
|
62
|
-
unicode-display_width (2.3.0)
|
|
63
|
-
|
|
64
|
-
PLATFORMS
|
|
65
|
-
x86_64-darwin-21
|
|
66
|
-
x86_64-darwin-22
|
|
67
|
-
x86_64-linux
|
|
68
|
-
|
|
69
|
-
DEPENDENCIES
|
|
70
|
-
ffaker (~> 2.21.0)
|
|
71
|
-
lefthook (~> 1.0.5)
|
|
72
|
-
pry (~> 0.14.1)
|
|
73
|
-
rake (~> 13.0.6)
|
|
74
|
-
rspec (~> 3.11.0)
|
|
75
|
-
rubocop (>= 1.28.2, < 1.29.0)
|
|
76
|
-
rubocop-ast (>= 1.17.0, < 1.18.0)
|
|
77
|
-
rubocop-performance (>= 1.13.3, < 1.14.0)
|
|
78
|
-
rubocop-rspec (>= 2.10.0, < 2.11.0)
|
|
79
|
-
simplecov (~> 0.21.2)
|
|
80
|
-
yaso!
|
|
81
|
-
|
|
82
|
-
BUNDLED WITH
|
|
83
|
-
2.3.19
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Yaso
|
|
4
|
-
module Logic
|
|
5
|
-
class StepBuilder
|
|
6
|
-
CATEGORIES = {
|
|
7
|
-
step: Step,
|
|
8
|
-
pass: Pass,
|
|
9
|
-
failure: Failure,
|
|
10
|
-
wrap: Wrap,
|
|
11
|
-
switch: Switch
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
def initialize(klass)
|
|
15
|
-
@klass = klass
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def call(object:, category:, block:, **opts)
|
|
19
|
-
logic_class = CATEGORIES[category]
|
|
20
|
-
invocable_type, invocable = Invocable.call(object, with_block: logic_class == Wrap, **opts)
|
|
21
|
-
if invocable_type == Invocable::METHOD
|
|
22
|
-
opts[:name] = logic_class == Switch ? build_switch(object, **opts, &block) : build_method(object, &block)
|
|
23
|
-
end
|
|
24
|
-
opts[:wrapper] = build_wrapper(&block) if logic_class == Wrap
|
|
25
|
-
logic_class.new(invocable: invocable, **opts)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
def build_switch(object, options:, **, &block)
|
|
31
|
-
if block.nil?
|
|
32
|
-
key = options[:key]
|
|
33
|
-
cases = options[:cases]
|
|
34
|
-
block = ->(ctx, **) { cases[ctx[key]] }
|
|
35
|
-
end
|
|
36
|
-
build_method(object, &block)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def build_method(name, &block)
|
|
40
|
-
return name if @klass.method_defined?(name)
|
|
41
|
-
raise StepIsNotImplementedError.new(@klass, name) unless block
|
|
42
|
-
|
|
43
|
-
@klass.define_method(name, &block)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def build_wrapper(&block)
|
|
47
|
-
wrapper_class = Class.new { extend Stepable }
|
|
48
|
-
build_wrapper_methods(wrapper_class, @klass)
|
|
49
|
-
wrapper_class.instance_exec(&block)
|
|
50
|
-
wrapper_class
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def build_wrapper_methods(wrapper_class, service_class)
|
|
54
|
-
wrapper_class.define_singleton_method(:call) do |context, instance|
|
|
55
|
-
@entry ||= service_class.flow.call(service_class, steps)
|
|
56
|
-
step = @entry
|
|
57
|
-
step = step.call(context, instance) while step
|
|
58
|
-
instance
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
data/lib/yaso/logic.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'logic/base'
|
|
4
|
-
require_relative 'logic/step'
|
|
5
|
-
require_relative 'logic/pass'
|
|
6
|
-
require_relative 'logic/failure'
|
|
7
|
-
require_relative 'logic/wrap'
|
|
8
|
-
require_relative 'logic/switch'
|
|
9
|
-
require_relative 'logic/step_builder'
|
|
10
|
-
require_relative 'logic/classic'
|
|
11
|
-
require_relative 'logic/rollback'
|
|
12
|
-
|
|
13
|
-
module Yaso
|
|
14
|
-
module Logic
|
|
15
|
-
FLOWS = {
|
|
16
|
-
classic: Logic::Classic,
|
|
17
|
-
rollback: Logic::Rollback
|
|
18
|
-
}.freeze
|
|
19
|
-
end
|
|
20
|
-
end
|