decouplio 1.0.0alpha7 → 1.0.0rc

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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +313 -15
  3. data/decouplio.gemspec +8 -2
  4. data/lib/decouplio/action.rb +34 -74
  5. data/lib/decouplio/action_state_printer.rb +34 -0
  6. data/lib/decouplio/const/flows.rb +59 -0
  7. data/lib/decouplio/const/reserved_methods.rb +6 -13
  8. data/lib/decouplio/const/types.rb +1 -165
  9. data/lib/decouplio/const/validations/common.rb +10 -0
  10. data/lib/decouplio/const/validations/octo.rb +16 -0
  11. data/lib/decouplio/const/validations/resq.rb +12 -1
  12. data/lib/decouplio/ctx.rb +13 -0
  13. data/lib/decouplio/default_meta_store.rb +37 -0
  14. data/lib/decouplio/errors/action_class_error.rb +0 -3
  15. data/lib/decouplio/errors/base_error.rb +0 -3
  16. data/lib/decouplio/errors/execution_error.rb +0 -2
  17. data/lib/decouplio/errors/extra_key_for_pass_error.rb +0 -3
  18. data/lib/decouplio/errors/fail_can_not_be_first_step_error.rb +0 -3
  19. data/lib/decouplio/errors/fail_controversial_keys_error.rb +0 -3
  20. data/lib/decouplio/errors/fail_finish_him_error.rb +0 -3
  21. data/lib/decouplio/errors/invalid_error_class_error.rb +0 -3
  22. data/lib/decouplio/errors/invalid_options_for_resq_step.rb +18 -0
  23. data/lib/decouplio/errors/invalid_wrap_name_error.rb +0 -3
  24. data/lib/decouplio/errors/logic_is_not_defined_error.rb +0 -3
  25. data/lib/decouplio/errors/logic_redefinition_error.rb +0 -3
  26. data/lib/decouplio/errors/octo_block_is_not_defined_error.rb +0 -3
  27. data/lib/decouplio/errors/octo_case_is_not_defined_error.rb +19 -0
  28. data/lib/decouplio/errors/octo_controversial_keys_error.rb +0 -3
  29. data/lib/decouplio/errors/{error_store_error.rb → octo_finish_him_is_not_allowed_error.rb} +2 -4
  30. data/lib/decouplio/errors/options_validation_error.rb +13 -1
  31. data/lib/decouplio/errors/palp_block_is_not_defined_error.rb +0 -3
  32. data/lib/decouplio/errors/palp_validation_error.rb +0 -3
  33. data/lib/decouplio/errors/pass_controversial_keys_error.rb +0 -3
  34. data/lib/decouplio/errors/pass_finish_him_error.rb +0 -3
  35. data/lib/decouplio/errors/required_options_is_missing_for_octo_error.rb +0 -3
  36. data/lib/decouplio/errors/resq_definition_error.rb +0 -3
  37. data/lib/decouplio/errors/resq_error_class_error.rb +0 -3
  38. data/lib/decouplio/errors/resq_handler_method_error.rb +0 -3
  39. data/lib/decouplio/errors/step_controversial_keys_error.rb +0 -3
  40. data/lib/decouplio/errors/step_definition_error.rb +17 -0
  41. data/lib/decouplio/errors/step_finish_him_error.rb +0 -3
  42. data/lib/decouplio/errors/step_is_not_defined_for_fail_error.rb +0 -3
  43. data/lib/decouplio/errors/step_is_not_defined_for_pass_error.rb +0 -4
  44. data/lib/decouplio/errors/step_is_not_defined_for_step_error.rb +0 -4
  45. data/lib/decouplio/errors/step_is_not_defined_for_wrap_error.rb +0 -3
  46. data/lib/decouplio/errors/step_name_error.rb +0 -3
  47. data/lib/decouplio/errors/wrap_block_is_not_defined_error.rb +0 -3
  48. data/lib/decouplio/errors/wrap_controversial_keys_error.rb +0 -3
  49. data/lib/decouplio/errors/wrap_finish_him_error.rb +0 -3
  50. data/lib/decouplio/errors/wrap_klass_method_error.rb +0 -3
  51. data/lib/decouplio/graph.rb +9 -0
  52. data/lib/decouplio/logic_dsl.rb +337 -107
  53. data/lib/decouplio/new_flow.rb +283 -0
  54. data/lib/decouplio/octo_hash_case.rb +20 -5
  55. data/lib/decouplio/octo_options_validator.rb +10 -64
  56. data/lib/decouplio/step_validator.rb +200 -0
  57. data/lib/decouplio/steps/base_condition.rb +21 -0
  58. data/lib/decouplio/steps/base_if_condition.rb +11 -0
  59. data/lib/decouplio/steps/base_inner_action.rb +42 -0
  60. data/lib/decouplio/steps/base_octo.rb +26 -0
  61. data/lib/decouplio/steps/base_resq.rb +25 -28
  62. data/lib/decouplio/steps/base_resq_with_mapping.rb +34 -0
  63. data/lib/decouplio/steps/base_service_step.rb +39 -0
  64. data/lib/decouplio/steps/base_step.rb +33 -6
  65. data/lib/decouplio/steps/base_unless_condition.rb +11 -0
  66. data/lib/decouplio/steps/base_wrap.rb +27 -0
  67. data/lib/decouplio/steps/fail.rb +1 -28
  68. data/lib/decouplio/steps/if_condition_fail.rb +1 -21
  69. data/lib/decouplio/steps/if_condition_pass.rb +1 -19
  70. data/lib/decouplio/steps/inner_action_fail.rb +1 -33
  71. data/lib/decouplio/steps/inner_action_pass.rb +12 -30
  72. data/lib/decouplio/steps/inner_action_step.rb +1 -33
  73. data/lib/decouplio/steps/octo_by_key.rb +31 -0
  74. data/lib/decouplio/steps/octo_by_method.rb +31 -0
  75. data/lib/decouplio/steps/pass.rb +5 -26
  76. data/lib/decouplio/steps/resq_fail.rb +0 -2
  77. data/lib/decouplio/steps/resq_pass.rb +1 -3
  78. data/lib/decouplio/steps/resq_with_mapping_fail.rb +8 -0
  79. data/lib/decouplio/steps/resq_with_mapping_pass.rb +8 -0
  80. data/lib/decouplio/steps/service_as_fail.rb +8 -0
  81. data/lib/decouplio/steps/service_as_pass.rb +16 -0
  82. data/lib/decouplio/steps/service_as_step.rb +8 -0
  83. data/lib/decouplio/steps/step.rb +0 -24
  84. data/lib/decouplio/steps/unless_condition_fail.rb +1 -21
  85. data/lib/decouplio/steps/unless_condition_pass.rb +1 -19
  86. data/lib/decouplio/steps/wrap.rb +25 -37
  87. data/lib/decouplio/steps/wrap_with_class.rb +43 -0
  88. data/lib/decouplio/steps/wrap_with_class_method.rb +45 -0
  89. data/lib/decouplio/utils/prepare_resq_mappings.rb +17 -0
  90. data/lib/decouplio/version.rb +1 -1
  91. data/lib/decouplio.rb +93 -0
  92. metadata +32 -55
  93. data/.circleci/config.yml +0 -63
  94. data/.dockerignore +0 -12
  95. data/.gitignore +0 -13
  96. data/.rspec +0 -3
  97. data/.rubocop.yml +0 -116
  98. data/.rubocop_todo.yml +0 -147
  99. data/.ruby-version +0 -1
  100. data/.vscode/settings.json +0 -3
  101. data/Dockerfile +0 -12
  102. data/Gemfile +0 -8
  103. data/benchmarks/.ruby-version +0 -1
  104. data/benchmarks/Dockerfile +0 -12
  105. data/benchmarks/Gemfile +0 -12
  106. data/benchmarks/multi_step_benchmark.rb +0 -336
  107. data/benchmarks/single_step_benchmark.rb +0 -159
  108. data/bin/console +0 -15
  109. data/bin/setup +0 -8
  110. data/docker-compose.yml +0 -29
  111. data/lib/decouplio/composer.rb +0 -691
  112. data/lib/decouplio/const/colors.rb +0 -25
  113. data/lib/decouplio/const/doby_aide_options.rb +0 -16
  114. data/lib/decouplio/const/results.rb +0 -15
  115. data/lib/decouplio/const/step_options.rb +0 -16
  116. data/lib/decouplio/const/validations/aide.rb +0 -38
  117. data/lib/decouplio/const/validations/doby.rb +0 -36
  118. data/lib/decouplio/default_error_handler.rb +0 -39
  119. data/lib/decouplio/errors/aide_can_not_be_first_step_error.rb +0 -18
  120. data/lib/decouplio/errors/aide_controversial_keys_error.rb +0 -26
  121. data/lib/decouplio/errors/aide_finish_him_error.rb +0 -26
  122. data/lib/decouplio/errors/doby_controversial_keys_error.rb +0 -26
  123. data/lib/decouplio/errors/doby_finish_him_error.rb +0 -26
  124. data/lib/decouplio/errors/extra_key_for_fail_error.rb +0 -26
  125. data/lib/decouplio/errors/extra_key_for_octo_error.rb +0 -26
  126. data/lib/decouplio/errors/extra_key_for_resq_error.rb +0 -29
  127. data/lib/decouplio/errors/extra_key_for_step_error.rb +0 -23
  128. data/lib/decouplio/errors/extra_key_for_wrap_error.rb +0 -23
  129. data/lib/decouplio/errors/palp_is_not_defined_error.rb +0 -26
  130. data/lib/decouplio/errors/step_is_not_defined_for_aide_error.rb +0 -26
  131. data/lib/decouplio/errors/step_is_not_defined_for_doby_error.rb +0 -27
  132. data/lib/decouplio/flow.rb +0 -17
  133. data/lib/decouplio/options_validator.rb +0 -716
  134. data/lib/decouplio/processor.rb +0 -20
  135. data/lib/decouplio/steps/aide.rb +0 -37
  136. data/lib/decouplio/steps/doby.rb +0 -37
  137. data/lib/decouplio/steps/octo.rb +0 -27
  138. data/lib/decouplio/steps/service_fail.rb +0 -41
  139. data/lib/decouplio/steps/service_pass.rb +0 -41
  140. data/lib/decouplio/steps/service_step.rb +0 -41
  141. data/lib/decouplio/steps/shared/fail_resolver.rb +0 -40
  142. data/lib/decouplio/steps/shared/step_resolver.rb +0 -43
  143. data/lib/decouplio/validators/condition.rb +0 -59
data/.rubocop.yml DELETED
@@ -1,116 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- require: rubocop-rspec
4
-
5
- AllCops:
6
- NewCops: enable
7
- SuggestExtensions: false
8
- Exclude:
9
- - 'decouplio.gemspec'
10
- - vendor/**/*
11
- - docs/**/*
12
-
13
- Style/Documentation:
14
- Enabled: false
15
-
16
- Style/SignalException:
17
- Enabled: false
18
-
19
- Layout/LineLength:
20
- Max: 120
21
-
22
- Lint/Void:
23
- Exclude:
24
- - spec/support/matchers/error_matcher.rb
25
-
26
- Lint/UnusedBlockArgument:
27
- Exclude:
28
- - spec/support/matchers/error_matcher.rb
29
- - spec/support/matchers/decouplio_action_matcher.rb
30
-
31
- Lint/NestedMethodDefinition:
32
- Exclude:
33
- - spec/**/*
34
-
35
- Lint/UnreachableCode:
36
- Exclude:
37
- - spec/**/*
38
-
39
- Style/FrozenStringLiteralComment:
40
- Enabled: true
41
-
42
- Metrics/BlockLength:
43
- IgnoredMethods: ['describe','context', 'lambda', 'logic', 'define', 'it', 'let']
44
-
45
- Metrics/ModuleLength:
46
- Exclude:
47
- - lib/decouplio/const/types.rb
48
- - spec/**/*
49
-
50
- Lint/NonLocalExitFromIterator:
51
- Exclude:
52
- - spec/support/matchers/error_matcher.rb
53
-
54
- Metrics/MethodLength:
55
- Exclude:
56
- - spec/**/*
57
-
58
- RSpec/DescribeClass:
59
- Enabled: false
60
-
61
- RSpec/NestedGroups:
62
- Max: 10
63
-
64
- Lint/EmptyBlock:
65
- Exclude:
66
- - spec/action_logic_block_spec.rb
67
- - spec/fail_spec.rb
68
- - spec/palp_block_spec.rb
69
- - spec/wrap_block_spec.rb
70
- - spec/support/cases/octo_cases_palps.rb
71
-
72
- Lint/ConstantDefinitionInBlock:
73
- Exclude:
74
- - spec/action_logic_block_spec.rb
75
- - spec/fail_spec.rb
76
- - spec/palp_block_spec.rb
77
- - spec/wrap_block_spec.rb
78
- - spec/error_store_for_inner_step_spec.rb
79
-
80
- RSpec/LeakyConstantDeclaration:
81
- Exclude:
82
- - spec/action_logic_block_spec.rb
83
- - spec/fail_spec.rb
84
- - spec/palp_block_spec.rb
85
- - 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
-
97
- RSpec/MultipleExpectations:
98
- Enabled: false
99
-
100
- RSpec/MultipleMemoizedHelpers:
101
- Exclude:
102
- - spec/**/*
103
-
104
- Naming/PredicateName:
105
- Exclude:
106
- - lib/decouplio/step.rb
107
-
108
- Naming/MethodParameterName:
109
- Exclude:
110
- - spec/support/cases/**/*
111
-
112
- Naming/RescuedExceptionsVariableName:
113
- Enabled: false
114
-
115
- Layout/LineContinuationSpacing:
116
- Enabled: false
data/.rubocop_todo.yml DELETED
@@ -1,147 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2022-04-06 20:52:30 UTC using RuboCop version 1.26.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 4
10
- Lint/MissingSuper:
11
- Exclude:
12
- - 'lib/decouplio/action.rb'
13
- - 'lib/decouplio/errors/undefined_step_method_error.rb'
14
- - 'lib/decouplio/logic_dsl.rb'
15
- - 'lib/decouplio/strategy_hash_case.rb'
16
-
17
- # Offense count: 1
18
- # This cop supports safe auto-correction (--auto-correct).
19
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
20
- Lint/UnusedMethodArgument:
21
- Exclude:
22
- - 'lib/decouplio/action.rb'
23
-
24
- # Offense count: 4
25
- # This cop supports unsafe auto-correction (--auto-correct-all).
26
- Lint/UselessSetterCall:
27
- Exclude:
28
- - 'benchmarks/benchmark_active_interaction_vs_decouplio.rb'
29
- - 'benchmarks/benchmark_mutations_vs_decouplio.rb'
30
- - 'benchmarks/benchmarks.rb'
31
-
32
- # Offense count: 30
33
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
34
- Metrics/AbcSize:
35
- Max: 111
36
-
37
- # Offense count: 2
38
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
39
- # IgnoredMethods: refine
40
- Metrics/BlockLength:
41
- Max: 42
42
-
43
- # Offense count: 4
44
- # Configuration parameters: CountComments, CountAsOne.
45
- Metrics/ClassLength:
46
- Max: 798
47
-
48
- # Offense count: 7
49
- # Configuration parameters: IgnoredMethods.
50
- Metrics/CyclomaticComplexity:
51
- Max: 25
52
-
53
- # Offense count: 46
54
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
55
- Metrics/MethodLength:
56
- Max: 44
57
-
58
- # Offense count: 3
59
- # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
60
- Metrics/ParameterLists:
61
- Max: 15
62
-
63
- # Offense count: 7
64
- # Configuration parameters: IgnoredMethods.
65
- Metrics/PerceivedComplexity:
66
- Max: 27
67
-
68
- # Offense count: 81
69
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
70
- # SupportedStyles: snake_case, normalcase, non_integer
71
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
72
- Naming/VariableNumber:
73
- Exclude:
74
- - 'spec/resq_spec.rb'
75
- - 'spec/octo_palps_spec.rb'
76
- - 'spec/strategy_step_spec.rb'
77
- - 'spec/support/cases/resq_cases.rb'
78
- - 'spec/support/cases/strategy_cases_palps.rb'
79
- - 'spec/support/cases/strategy_cases_steps.rb'
80
-
81
- # Offense count: 139
82
- # Configuration parameters: AllowSubject.
83
- RSpec/MultipleMemoizedHelpers:
84
- Max: 15
85
-
86
- # Offense count: 3
87
- # This cop supports safe auto-correction (--auto-correct).
88
- # Configuration parameters: EnforcedStyle.
89
- # SupportedStyles: empty, nil, both
90
- Style/EmptyElse:
91
- Exclude:
92
- - 'lib/decouplio/action.rb'
93
- - 'lib/decouplio/logic_dsl.rb'
94
-
95
- # Offense count: 18
96
- # Configuration parameters: MinBodyLength.
97
- Style/GuardClause:
98
- Exclude:
99
- - 'lib/decouplio/logic_composer.rb'
100
- - 'lib/decouplio/options_validator.rb'
101
-
102
- # Offense count: 1
103
- # This cop supports unsafe auto-correction (--auto-correct-all).
104
- Style/HashTransformValues:
105
- Exclude:
106
- - 'lib/decouplio/logic_composer.rb'
107
-
108
- # Offense count: 7
109
- # This cop supports safe auto-correction (--auto-correct).
110
- Style/KeywordParametersOrder:
111
- Exclude:
112
- - 'lib/decouplio/action.rb'
113
- - 'lib/decouplio/step.rb'
114
-
115
- # Offense count: 2
116
- # This cop supports unsafe auto-correction (--auto-correct-all).
117
- Style/MapToHash:
118
- Exclude:
119
- - 'lib/decouplio/logic_composer.rb'
120
- - 'lib/decouplio/logic_container.rb'
121
-
122
- # Offense count: 5
123
- # This cop supports unsafe auto-correction (--auto-correct-all).
124
- Style/SingleArgumentDig:
125
- Exclude:
126
- - 'lib/decouplio/options_validator.rb'
127
-
128
- # Offense count: 4
129
- # This cop supports unsafe auto-correction (--auto-correct-all).
130
- Style/SlicingWithRange:
131
- Exclude:
132
- - 'lib/decouplio/logic_composer.rb'
133
-
134
- # Offense count: 1
135
- # This cop supports unsafe auto-correction (--auto-correct-all).
136
- # Configuration parameters: Mode.
137
- Style/StringConcatenation:
138
- Exclude:
139
- - 'spec/spec_helper.rb'
140
-
141
- # Offense count: 1
142
- # This cop supports unsafe auto-correction (--auto-correct-all).
143
- # Configuration parameters: AllowMethodsWithArguments, IgnoredMethods.
144
- # IgnoredMethods: respond_to, define_method
145
- Style/SymbolProc:
146
- Exclude:
147
- - 'lib/decouplio/logic_composer.rb'
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.7.6
@@ -1,3 +0,0 @@
1
- {
2
- "editor.tabSize": 2
3
- }
data/Dockerfile DELETED
@@ -1,12 +0,0 @@
1
- ARG RUBY_VERSION=2.7.0
2
-
3
- FROM ruby:${RUBY_VERSION}-slim
4
-
5
- RUN apt-get update
6
- RUN apt-get install -y git make gcc
7
-
8
- COPY . /decouplio
9
-
10
- WORKDIR /decouplio
11
-
12
- RUN bundle check || bundle install
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in decouplio.gemspec
8
- gemspec
@@ -1 +0,0 @@
1
- 2.7.0
@@ -1,12 +0,0 @@
1
- ARG RUBY_VERSION=2.7.0
2
-
3
- FROM ruby:${RUBY_VERSION}-slim
4
-
5
- RUN apt-get update
6
- RUN apt-get install -y git make gcc
7
-
8
- COPY . /decouplio
9
-
10
- WORKDIR /decouplio/benchmarks
11
-
12
- RUN bundle check || bundle install
data/benchmarks/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'active_interaction', '~> 4.1'
6
- gem 'benchmark-ips'
7
- gem 'decouplio'
8
- gem 'interactor', '~> 3.0'
9
- gem 'mutations'
10
- gem 'pry-byebug'
11
- gem 'ruby-prof'
12
- gem 'trailblazer', '~> 2.1'
@@ -1,336 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_interaction'
4
- require 'interactor'
5
- require 'mutations'
6
- require 'trailblazer'
7
- require 'decouplio'
8
- require 'benchmark/ips'
9
-
10
- class RegularServiceTest
11
- attr_accessor :ctx, :param1
12
-
13
- def self.call(param1:)
14
- new(param1: param1).call
15
- end
16
-
17
- def initialize(param1:)
18
- @param1 = param1
19
- @ctx = {}
20
- end
21
-
22
- def call
23
- step_one
24
- step_two
25
- step_three
26
- step_four
27
- step_five
28
- step_six
29
- step_seven
30
- step_eight
31
- step_nine
32
- self
33
- end
34
-
35
- def step_one
36
- ctx[:step_one] = param1
37
- end
38
-
39
- def step_two
40
- ctx[:step_two] = ctx[:step_one]
41
- end
42
-
43
- def step_three
44
- ctx[:step_three] = ctx[:step_two]
45
- end
46
-
47
- def step_four
48
- ctx[:step_four] = ctx[:step_three]
49
- end
50
-
51
- def step_five
52
- ctx[:step_five] = ctx[:step_four]
53
- end
54
-
55
- def step_six
56
- ctx[:step_six] = ctx[:step_five]
57
- end
58
-
59
- def step_seven
60
- ctx[:step_seven] = ctx[:step_six]
61
- end
62
-
63
- def step_eight
64
- ctx[:step_eight] = ctx[:step_seven]
65
- end
66
-
67
- def step_nine
68
- ctx[:step_nine] = ctx[:step_eight]
69
- end
70
- end
71
-
72
- class DecouplioTestSeveralSteps < Decouplio::Action
73
- logic do
74
- step :step_one
75
- step :step_two
76
- step :step_three
77
- step :step_four
78
- step :step_five
79
- step :step_six
80
- step :step_seven
81
- step :step_eight
82
- step :step_nine
83
- end
84
-
85
- def step_one(param1:, **)
86
- ctx[:step_one] = param1
87
- end
88
-
89
- def step_two(step_one:, **)
90
- ctx[:step_two] = step_one
91
- end
92
-
93
- def step_three(step_two:, **)
94
- ctx[:step_three] = step_two
95
- end
96
-
97
- def step_four(step_three:, **)
98
- ctx[:step_four] = step_three
99
- end
100
-
101
- def step_five(step_four:, **)
102
- ctx[:step_five] = step_four
103
- end
104
-
105
- def step_six(step_five:, **)
106
- ctx[:step_six] = step_five
107
- end
108
-
109
- def step_seven(step_six:, **)
110
- ctx[:step_seven] = step_six
111
- end
112
-
113
- def step_eight(step_seven:, **)
114
- ctx[:step_eight] = step_seven
115
- end
116
-
117
- def step_nine(step_eight:, **)
118
- ctx[:step_nine] = step_eight
119
- end
120
- end
121
-
122
- class StepOne
123
- include Interactor
124
-
125
- def call
126
- context.step_one = context.param1
127
- end
128
- end
129
-
130
- class StepTwo
131
- include Interactor
132
-
133
- def call
134
- context.step_two = context.step_one
135
- end
136
- end
137
-
138
- class StepThree
139
- include Interactor
140
-
141
- def call
142
- context.step_three = context.step_two
143
- end
144
- end
145
-
146
- class StepFour
147
- include Interactor
148
-
149
- def call
150
- context.step_four = context.step_three
151
- end
152
- end
153
-
154
- class StepFive
155
- include Interactor
156
-
157
- def call
158
- context.step_five = context.step_four
159
- end
160
- end
161
-
162
- class StepSix
163
- include Interactor
164
-
165
- def call
166
- context.step_six = context.step_five
167
- end
168
- end
169
-
170
- class StepSeven
171
- include Interactor
172
-
173
- def call
174
- context.step_seven = context.step_six
175
- end
176
- end
177
-
178
- class StepEight
179
- include Interactor
180
-
181
- def call
182
- context.step_eight = context.step_seven
183
- end
184
- end
185
-
186
- class StepNine
187
- include Interactor
188
-
189
- def call
190
- context.step_nine = context.step_eight
191
- end
192
- end
193
-
194
- class InteractorTestOrganizer
195
- include Interactor::Organizer
196
-
197
- organize StepOne,
198
- StepTwo,
199
- StepThree,
200
- StepFour,
201
- StepFive,
202
- StepSix,
203
- StepSeven,
204
- StepEight,
205
- StepNine
206
- end
207
-
208
- class TrailblazerTestSeveralSteps < Trailblazer::Activity::Railway
209
- step :step_one
210
- step :step_two
211
- step :step_three
212
- step :step_four
213
- step :step_five
214
- step :step_six
215
- step :step_seven
216
- step :step_eight
217
- step :step_nine
218
-
219
- def step_one(ctx, param1:, **)
220
- ctx[:step_one] = param1
221
- end
222
-
223
- def step_two(ctx, step_one:, **)
224
- ctx[:step_two] = step_one
225
- end
226
-
227
- def step_three(ctx, step_two:, **)
228
- ctx[:step_three] = step_two
229
- end
230
-
231
- def step_four(ctx, step_three:, **)
232
- ctx[:step_four] = step_three
233
- end
234
-
235
- def step_five(ctx, step_four:, **)
236
- ctx[:step_five] = step_four
237
- end
238
-
239
- def step_six(ctx, step_five:, **)
240
- ctx[:step_six] = step_five
241
- end
242
-
243
- def step_seven(ctx, step_six:, **)
244
- ctx[:step_seven] = step_six
245
- end
246
-
247
- def step_eight(ctx, step_seven:, **)
248
- ctx[:step_eight] = step_seven
249
- end
250
-
251
- def step_nine(ctx, step_eight:, **)
252
- ctx[:step_nine] = step_eight
253
- end
254
- end
255
-
256
- class DecouplioStepOne
257
- def self.call(ctx:, **)
258
- ctx[:step_one] = ctx[:param1]
259
- end
260
- end
261
-
262
- class DecouplioStepTwo
263
- def self.call(ctx:, **)
264
- ctx[:step_two] = ctx[:step_one]
265
- end
266
- end
267
-
268
- class DecouplioStepThree
269
- def self.call(ctx:, **)
270
- ctx[:step_three] = ctx[:step_two]
271
- end
272
- end
273
-
274
- class DecouplioStepFour
275
- def self.call(ctx:, **)
276
- ctx[:step_four] = ctx[:step_three]
277
- end
278
- end
279
-
280
- class DecouplioStepFive
281
- def self.call(ctx:, **)
282
- ctx[:step_five] = ctx[:step_four]
283
- end
284
- end
285
-
286
- class DecouplioStepSix
287
- def self.call(ctx:, **)
288
- ctx[:step_six] = ctx[:step_five]
289
- end
290
- end
291
-
292
- class DecouplioStepSeven
293
- def self.call(ctx:, **)
294
- ctx[:step_seven] = ctx[:step_six]
295
- end
296
- end
297
-
298
- class DecouplioStepEight
299
- def self.call(ctx:, **)
300
- ctx[:step_eight] = ctx[:step_seven]
301
- end
302
- end
303
-
304
- class DecouplioStepNine
305
- def self.call(ctx:, **)
306
- ctx[:step_nine] = ctx[:step_eight]
307
- end
308
- end
309
-
310
- class DecouplioServiceStepsTest < Decouplio::Action
311
- logic do
312
- step DecouplioStepOne
313
- step DecouplioStepTwo
314
- step DecouplioStepThree
315
- step DecouplioStepFour
316
- step DecouplioStepFive
317
- step DecouplioStepSix
318
- step DecouplioStepSeven
319
- step DecouplioStepEight
320
- step DecouplioStepNine
321
- end
322
- end
323
-
324
- iteration_count = 100_00
325
-
326
- Benchmark.ips do |x|
327
- x.report('RegularService') { iteration_count.times { RegularServiceTest.call(param1: 'param1') } }
328
- x.report('Decouplio several steps') { iteration_count.times { DecouplioTestSeveralSteps.call(param1: 'param1') } }
329
- x.report('Decouplio service steps') { iteration_count.times { DecouplioServiceStepsTest.call(param1: 'param1') } }
330
- x.report('Trailblazer several steps') { iteration_count.times { TrailblazerTestSeveralSteps.call(param1: 'param1') } }
331
- x.report('Interactor several interactions with organizer') do
332
- iteration_count.times { InteractorTestOrganizer.call(param1: 'param1') }
333
- end
334
-
335
- x.compare!
336
- end