trailblazer-activity 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +101 -0
  3. data/.rubocop.yml +4 -13
  4. data/.rubocop_todo.yml +474 -476
  5. data/.travis.yml +3 -2
  6. data/CHANGES.md +10 -0
  7. data/Gemfile +5 -4
  8. data/README.md +2 -0
  9. data/Rakefile +1 -1
  10. data/lib/trailblazer/activity.rb +29 -92
  11. data/lib/trailblazer/activity/circuit.rb +74 -0
  12. data/lib/trailblazer/activity/config.rb +4 -6
  13. data/lib/trailblazer/activity/introspect.rb +33 -129
  14. data/lib/trailblazer/activity/present.rb +14 -39
  15. data/lib/trailblazer/activity/schema.rb +13 -0
  16. data/lib/trailblazer/activity/schema/implementation.rb +10 -0
  17. data/lib/trailblazer/activity/schema/intermediate.rb +94 -0
  18. data/lib/trailblazer/activity/structures.rb +43 -43
  19. data/lib/trailblazer/activity/task_wrap.rb +29 -16
  20. data/lib/trailblazer/activity/task_wrap/call_task.rb +4 -4
  21. data/lib/trailblazer/activity/task_wrap/inject.rb +37 -0
  22. data/lib/trailblazer/activity/task_wrap/pipeline.rb +55 -0
  23. data/lib/trailblazer/activity/task_wrap/runner.rb +10 -19
  24. data/lib/trailblazer/activity/task_wrap/variable_mapping.rb +25 -97
  25. data/lib/trailblazer/activity/testing.rb +64 -22
  26. data/lib/trailblazer/activity/trace.rb +88 -41
  27. data/lib/trailblazer/activity/version.rb +4 -2
  28. data/trailblazer-activity.gemspec +5 -9
  29. metadata +18 -55
  30. data/lib/trailblazer/activity/dsl/add_task.rb +0 -22
  31. data/lib/trailblazer/activity/dsl/helper.rb +0 -68
  32. data/lib/trailblazer/activity/dsl/magnetic.rb +0 -36
  33. data/lib/trailblazer/activity/dsl/magnetic/builder.rb +0 -101
  34. data/lib/trailblazer/activity/dsl/magnetic/builder/default_normalizer.rb +0 -26
  35. data/lib/trailblazer/activity/dsl/magnetic/builder/fast_track.rb +0 -118
  36. data/lib/trailblazer/activity/dsl/magnetic/builder/normalizer.rb +0 -113
  37. data/lib/trailblazer/activity/dsl/magnetic/builder/path.rb +0 -105
  38. data/lib/trailblazer/activity/dsl/magnetic/builder/railway.rb +0 -97
  39. data/lib/trailblazer/activity/dsl/magnetic/builder/state.rb +0 -58
  40. data/lib/trailblazer/activity/dsl/magnetic/finalizer.rb +0 -51
  41. data/lib/trailblazer/activity/dsl/magnetic/generate.rb +0 -62
  42. data/lib/trailblazer/activity/dsl/magnetic/merge.rb +0 -16
  43. data/lib/trailblazer/activity/dsl/magnetic/process_options.rb +0 -76
  44. data/lib/trailblazer/activity/dsl/magnetic/structure/alterations.rb +0 -44
  45. data/lib/trailblazer/activity/dsl/magnetic/structure/plus_poles.rb +0 -85
  46. data/lib/trailblazer/activity/dsl/magnetic/structure/polarization.rb +0 -23
  47. data/lib/trailblazer/activity/dsl/record.rb +0 -11
  48. data/lib/trailblazer/activity/dsl/schema/dependencies.rb +0 -46
  49. data/lib/trailblazer/activity/dsl/schema/sequence.rb +0 -46
  50. data/lib/trailblazer/activity/dsl/strategy/build_state.rb +0 -32
  51. data/lib/trailblazer/activity/dsl/strategy/fast_track.rb +0 -24
  52. data/lib/trailblazer/activity/dsl/strategy/path.rb +0 -26
  53. data/lib/trailblazer/activity/dsl/strategy/plan.rb +0 -36
  54. data/lib/trailblazer/activity/dsl/strategy/railway.rb +0 -23
  55. data/lib/trailblazer/activity/interface.rb +0 -16
  56. data/lib/trailblazer/activity/task_wrap/merge.rb +0 -23
  57. data/lib/trailblazer/activity/task_wrap/trace.rb +0 -44
  58. data/lib/trailblazer/circuit.rb +0 -71
@@ -1,5 +1,7 @@
1
1
  module Trailblazer
2
- class Activity < Module
3
- VERSION = "0.7.1"
2
+ module Version
3
+ module Activity
4
+ VERSION = "0.8.0"
5
+ end
4
6
  end
5
7
  end
@@ -4,29 +4,25 @@ require 'trailblazer/activity/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "trailblazer-activity"
7
- spec.version = Trailblazer::Activity::VERSION
7
+ spec.version = Trailblazer::Version::Activity::VERSION
8
8
  spec.authors = ["Nick Sutterer"]
9
9
  spec.email = ["apotonick@gmail.com"]
10
10
 
11
- spec.summary = %q{Define and run any desired circuit of business logic.}
12
- spec.description = %q{Define and run any desired circuit of business logic. Used in Trailblazer's Operation to implement the railway.}
11
+ spec.summary = %q{Runtime code for Trailblazer activities.}
13
12
  spec.homepage = "http://trailblazer.to"
14
13
  spec.licenses = ["MIT"]
15
14
 
16
15
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
16
+ f.match(%r{^(test)/})
18
17
  end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
18
  spec.require_paths = ["lib"]
22
19
 
23
20
  spec.add_dependency "hirb"
24
21
  spec.add_dependency "trailblazer-context"
25
22
 
26
- spec.add_development_dependency "bundler", "~> 1.14"
27
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler"
28
24
  spec.add_development_dependency "minitest", "~> 5.0"
29
- spec.add_development_dependency "trailblazer-test"
25
+ spec.add_development_dependency "rake"
30
26
 
31
27
  spec.required_ruby_version = '>= 2.1.0'
32
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2019-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hirb
@@ -42,30 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.14'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.14'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: '10.0'
47
+ version: '0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - "~>"
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: '10.0'
54
+ version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: minitest
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +67,7 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '5.0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: trailblazer-test
70
+ name: rake
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -94,8 +80,7 @@ dependencies:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
- description: Define and run any desired circuit of business logic. Used in Trailblazer's
98
- Operation to implement the railway.
83
+ description:
99
84
  email:
100
85
  - apotonick@gmail.com
101
86
  executables: []
@@ -103,6 +88,7 @@ extensions: []
103
88
  extra_rdoc_files: []
104
89
  files:
105
90
  - ".gitignore"
91
+ - ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
106
92
  - ".rubocop.yml"
107
93
  - ".rubocop_todo.yml"
108
94
  - ".travis.yml"
@@ -113,47 +99,24 @@ files:
113
99
  - Rakefile
114
100
  - lib/trailblazer-activity.rb
115
101
  - lib/trailblazer/activity.rb
102
+ - lib/trailblazer/activity/circuit.rb
116
103
  - lib/trailblazer/activity/config.rb
117
- - lib/trailblazer/activity/dsl/add_task.rb
118
- - lib/trailblazer/activity/dsl/helper.rb
119
- - lib/trailblazer/activity/dsl/magnetic.rb
120
- - lib/trailblazer/activity/dsl/magnetic/builder.rb
121
- - lib/trailblazer/activity/dsl/magnetic/builder/default_normalizer.rb
122
- - lib/trailblazer/activity/dsl/magnetic/builder/fast_track.rb
123
- - lib/trailblazer/activity/dsl/magnetic/builder/normalizer.rb
124
- - lib/trailblazer/activity/dsl/magnetic/builder/path.rb
125
- - lib/trailblazer/activity/dsl/magnetic/builder/railway.rb
126
- - lib/trailblazer/activity/dsl/magnetic/builder/state.rb
127
- - lib/trailblazer/activity/dsl/magnetic/finalizer.rb
128
- - lib/trailblazer/activity/dsl/magnetic/generate.rb
129
- - lib/trailblazer/activity/dsl/magnetic/merge.rb
130
- - lib/trailblazer/activity/dsl/magnetic/process_options.rb
131
- - lib/trailblazer/activity/dsl/magnetic/structure/alterations.rb
132
- - lib/trailblazer/activity/dsl/magnetic/structure/plus_poles.rb
133
- - lib/trailblazer/activity/dsl/magnetic/structure/polarization.rb
134
- - lib/trailblazer/activity/dsl/record.rb
135
- - lib/trailblazer/activity/dsl/schema/dependencies.rb
136
- - lib/trailblazer/activity/dsl/schema/sequence.rb
137
- - lib/trailblazer/activity/dsl/strategy/build_state.rb
138
- - lib/trailblazer/activity/dsl/strategy/fast_track.rb
139
- - lib/trailblazer/activity/dsl/strategy/path.rb
140
- - lib/trailblazer/activity/dsl/strategy/plan.rb
141
- - lib/trailblazer/activity/dsl/strategy/railway.rb
142
- - lib/trailblazer/activity/interface.rb
143
104
  - lib/trailblazer/activity/introspect.rb
144
105
  - lib/trailblazer/activity/present.rb
106
+ - lib/trailblazer/activity/schema.rb
107
+ - lib/trailblazer/activity/schema/implementation.rb
108
+ - lib/trailblazer/activity/schema/intermediate.rb
145
109
  - lib/trailblazer/activity/structures.rb
146
110
  - lib/trailblazer/activity/task_builder.rb
147
111
  - lib/trailblazer/activity/task_wrap.rb
148
112
  - lib/trailblazer/activity/task_wrap/call_task.rb
149
- - lib/trailblazer/activity/task_wrap/merge.rb
113
+ - lib/trailblazer/activity/task_wrap/inject.rb
114
+ - lib/trailblazer/activity/task_wrap/pipeline.rb
150
115
  - lib/trailblazer/activity/task_wrap/runner.rb
151
- - lib/trailblazer/activity/task_wrap/trace.rb
152
116
  - lib/trailblazer/activity/task_wrap/variable_mapping.rb
153
117
  - lib/trailblazer/activity/testing.rb
154
118
  - lib/trailblazer/activity/trace.rb
155
119
  - lib/trailblazer/activity/version.rb
156
- - lib/trailblazer/circuit.rb
157
120
  - trailblazer-activity.gemspec
158
121
  homepage: http://trailblazer.to
159
122
  licenses:
@@ -175,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
138
  version: '0'
176
139
  requirements: []
177
140
  rubyforge_project:
178
- rubygems_version: 2.7.3
141
+ rubygems_version: 2.7.6
179
142
  signing_key:
180
143
  specification_version: 4
181
- summary: Define and run any desired circuit of business logic.
144
+ summary: Runtime code for Trailblazer activities.
182
145
  test_files: []
@@ -1,22 +0,0 @@
1
- class Trailblazer::Activity < Module
2
- module DSL
3
- module AddTask
4
- def add_task!(strategy, polarizer, name, task, options, &block)
5
- # The beautiful thing about State.add is it doesn't mutate anything.
6
- # We're changing state here, on the outside, by overriding the ivars.
7
- # That in turn means, the only mutated entity is this module.
8
-
9
- _builder, adds, circuit, outputs, returned_options = Magnetic::Builder::State.add( self[:builder], self[:adds], strategy, polarizer, task, options, &block ) # this could be an extension itself.
10
-
11
- self[:adds] = adds
12
- self[:circuit] = circuit
13
- self[:outputs] = outputs
14
-
15
- _, local_options, connections, sequence_options, extension_options = returned_options
16
-
17
- # {Extension API} call all extensions.
18
- extension_options.keys.collect { |ext| ext.( self, *returned_options, original_dsl_args: [name, task, options, block] ) }
19
- end
20
- end
21
- end
22
- end
@@ -1,68 +0,0 @@
1
- module Trailblazer
2
- module Activity::DSL
3
- # Create a new method (e.g. Activity::step) that delegates to its builder, recompiles
4
- # the circuit, etc. Method comes in a module so it can be overridden via modules.
5
- #
6
- # This approach assumes you maintain a {#add_task!} method.
7
- def self.def_dsl(_name, strategy, polarizer)
8
- Module.new do
9
- define_method(_name) do |task, options={}, &block|
10
- builder, adds, circuit, outputs, options = add_task!(strategy, polarizer, _name, task, options, &block)
11
- end
12
- end
13
- end
14
-
15
- # @api private
16
- OutputSemantic = Struct.new(:value)
17
- Track = Struct.new(:color)
18
- Extension = Struct.new(:callable) do
19
- def call(*args, &block)
20
- callable.(*args, &block)
21
- end
22
- end
23
-
24
- # Shortcut functions for the DSL. These have no state.
25
- module_function
26
-
27
- # Output( Left, :failure )
28
- # Output( :failure ) #=> Output::Semantic
29
- def Output(signal, semantic=nil)
30
- return OutputSemantic.new(signal) if semantic.nil?
31
-
32
- Activity.Output(signal, semantic)
33
- end
34
-
35
- def End(semantic)
36
- Activity.End(semantic)
37
- end
38
-
39
- def Track(color)
40
- Track.new(color).freeze
41
- end
42
-
43
- def Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options)
44
- options = options.merge(track_color: track_color, end_semantic: end_semantic)
45
-
46
- # Build an anonymous class which will be where the block is evaluated in.
47
- # We use the same normalizer here, so DSL calls in the inner block have the same behavior.
48
- path = Module.new do
49
- extend Activity::Path( options.merge( normalizer: normalizer ) )
50
- end
51
-
52
- # this block is called in DSL::ProcessTuples. This could be improved somehow.
53
- ->(block) {
54
- path.instance_exec(&block)
55
-
56
- [ track_color, path ]
57
- }
58
- end
59
-
60
- # Computes the :outputs options for {activity}
61
- def Subprocess(activity)
62
- {
63
- task: activity,
64
- outputs: activity.outputs
65
- }
66
- end
67
- end
68
- end
@@ -1,36 +0,0 @@
1
- module Trailblazer
2
- class Activity < Module # all code related to the magnetic building of a circuit hash lives in this namespace.
3
- module Magnetic
4
- # PlusPole "radiates" a color that MinusPoles are attracted to.
5
- #
6
- # This datastructure is produced by the DSL and sits in an ADDS.
7
- PlusPole = Struct.new(:output, :color) do
8
- private :output
9
-
10
- def signal
11
- output.signal
12
- end
13
- end # PlusPole
14
- end
15
- end
16
- end
17
-
18
- require "trailblazer/activity/dsl/magnetic/process_options"
19
- require "trailblazer/activity/dsl/magnetic/structure/plus_poles"
20
- require "trailblazer/activity/dsl/magnetic/structure/polarization"
21
- require "trailblazer/activity/dsl/magnetic/structure/alterations"
22
-
23
- require "trailblazer/activity/dsl/magnetic"
24
- require "trailblazer/activity/dsl/magnetic/builder"
25
- # require "trailblazer/activity/dsl/magnetic/builder/dsl_helper"
26
- # require "trailblazer/activity/dsl/magnetic/dsl_helper"
27
-
28
- require "trailblazer/option"
29
- require "trailblazer/activity/task_builder"
30
- require "trailblazer/activity/dsl/magnetic/builder/default_normalizer"
31
- require "trailblazer/activity/dsl/magnetic/builder/path"
32
- require "trailblazer/activity/dsl/magnetic/builder/railway"
33
- require "trailblazer/activity/dsl/magnetic/builder/fast_track" # TODO: move to Operation gem.
34
-
35
- require "trailblazer/activity/dsl/magnetic/generate"
36
- require "trailblazer/activity/dsl/magnetic/finalizer"
@@ -1,101 +0,0 @@
1
- module Trailblazer
2
- module Activity::Magnetic
3
-
4
- # TODO: move?
5
- module Options
6
- # Produce two hashes, one "local" options with DSL-specific options such as `:fast_track`,
7
- # one with generic DSL options, for example tuples like `Right=>Output(:failure)`.
8
- def self.normalize(options, local_keys)
9
- local, foreign = {}, {}
10
- options.each { |k,v| local_keys.include?(k) ? local[k] = v : foreign[k] = v }
11
-
12
- return foreign, local
13
- end
14
- end
15
-
16
- # Called from Path/Railway/FastTrack, creates the specific {Builder} instance.
17
- def self.Builder(implementation, normalizer, builder_options={})
18
- builder = implementation.new(normalizer, builder_options.freeze).freeze # e.g. Path.new(...)
19
-
20
- return builder, implementation.InitialAdds(builder_options)
21
- end
22
-
23
- class Builder
24
- def initialize(normalizer, builder_options)
25
- @normalizer, @builder_options = normalizer, builder_options
26
- end
27
-
28
- def self.merge(activity_adds, merged_adds)
29
- merged_adds = merged_adds[2..-1] || []
30
-
31
- activity_adds + merged_adds
32
- end
33
-
34
- # DSL method to create a Path within an activity which is embedded.
35
- #
36
- # Output(:success) => Path() {}
37
- def Path(*args)
38
- Activity::DSL.Path(@normalizer, *args)
39
- end
40
-
41
- # Public top-level entry point.
42
- def insert(strategy, polarizer, task, options, &block)
43
- normalizer = options[:normalizer] || @normalizer # DISCUSS: do this at a deeper point?
44
-
45
- task, local_options, connection_options, sequence_options, extension_options = normalizer.(task, options)
46
-
47
- polarizations = strategy.send(polarizer, @builder_options) # Railway.StepPolarizations( @builder_options )
48
-
49
- insert_element( polarizations, task, local_options, connection_options, sequence_options, extension_options, &block )
50
- end
51
-
52
- private
53
-
54
- # Internal top-level entry point to add task(s) and connections.
55
- # High level interface for DSL calls like ::task or ::step.
56
- def insert_element(polarizations, task, local_options, connection_options, sequence_options, extension_options, &block)
57
- adds, *returned_options = Builder.adds_for(polarizations, task, local_options, connection_options, sequence_options, extension_options, &block)
58
- end
59
-
60
- # @return Adds
61
- def self.adds_for(polarizations, task, local_options, connection_options, sequence_options, extension_options, &block)
62
- # go through all wiring options such as Output()=>:color.
63
- polarizations_from_user_options, additional_adds = process_dsl_options(connection_options, local_options, &block)
64
-
65
- polarizations = polarizations + polarizations_from_user_options
66
-
67
- result = adds(task, polarizations, local_options, sequence_options, local_options)
68
-
69
- return result + (local_options[:adds] || []) + additional_adds, task, local_options, connection_options, sequence_options, extension_options
70
- end
71
-
72
- def self.process_dsl_options(options, id:nil, plus_poles:, **, &block)
73
- DSL::ProcessOptions.(id, options, plus_poles, &block)
74
- end
75
-
76
- # Low-level interface for DSL calls (e.g. Start, where "you know what you're doing")
77
- # @private
78
- def self.adds(task, polarizations, options, sequence_options, magnetic_to:nil, id:nil, plus_poles:, **) # DISCUSS: no :id ?
79
- magnetic_to, plus_poles = PlusPoles.apply_polarizations(
80
- polarizations,
81
- magnetic_to,
82
- plus_poles,
83
- options
84
- )
85
-
86
- Add( id, task, magnetic_to, plus_poles,
87
- options, #{ fast_track: true },
88
- sequence_options #{ group: :main }
89
- )
90
- end
91
-
92
- def self.Add(id, task, magnetic_to, plus_poles, options, sequence_options)
93
- [
94
- [ :add, [id, [ magnetic_to, task, plus_poles ], sequence_options] ],
95
- ]
96
- end
97
- end # Builder
98
- end
99
- end
100
-
101
-
@@ -1,26 +0,0 @@
1
- module Trailblazer
2
- module Activity::Magnetic
3
- # This normalizer only processes basic input and is meant for bootstrapping.
4
- #
5
- # task Callable, id: "success", before: "another"
6
- class DefaultNormalizer
7
- # Declarative::Variables
8
- def self.build(plus_poles:, **options)
9
- return new(plus_poles: plus_poles), options
10
- end
11
-
12
- def initialize(**default_options)
13
- @default_options = default_options
14
- end
15
-
16
- # Processes the user arguments from the DSL
17
- def call(task, options)
18
- local_options = @default_options.merge(options) # here, we merge default :plus_poles.
19
-
20
- local_options, sequence_options = Options.normalize( local_options, Activity::Schema::Dependencies.sequence_keywords )
21
-
22
- return task, local_options, {}, sequence_options, {}
23
- end
24
- end
25
- end
26
- end
@@ -1,118 +0,0 @@
1
- # TODO: move me to Operation.
2
- module Trailblazer
3
- module Activity::Magnetic
4
- class Builder
5
-
6
- class FastTrack < Builder
7
- def self.for(normalizer, builder_options={}) # Build the Builder.
8
- Activity::Magnetic::Builder(
9
- FastTrack,
10
- normalizer,
11
- { track_color: :success, end_semantic: :success, failure_color: :failure }.merge( builder_options )
12
- )
13
- end
14
-
15
- def self.StepPolarizations(**options)
16
- [
17
- *Railway.StepPolarizations(options),
18
- StepPolarization.new(options)
19
- ]
20
- end
21
-
22
- def self.FailPolarizations(**options)
23
- [
24
- *Railway.FailPolarizations(options),
25
- FailPolarization.new(options)
26
- ]
27
- end
28
-
29
- def self.PassPolarizations(**options)
30
- [
31
- *Railway.PassPolarizations(options),
32
- PassPolarization.new(options)
33
- ]
34
- end
35
-
36
- # pass_fast: true simply means: color my :success Output with :pass_fast color
37
- class StepPolarization < Railway::StepPolarization
38
- def call(magnetic_to, plus_poles, options)
39
- plus_poles = plus_poles.reconnect( :success => :pass_fast ) if options[:pass_fast]
40
- plus_poles = plus_poles.reconnect( :failure => :fail_fast ) if options[:fail_fast]
41
-
42
- # add fast track outputs if :fast_track
43
- plus_poles = plus_poles.reverse_merge(
44
- Activity.Output(Activity::FastTrack::FailFast, :fail_fast) => :fail_fast,
45
- Activity.Output(Activity::FastTrack::PassFast, :pass_fast) => :pass_fast
46
- ) if options[:fast_track]
47
-
48
- [
49
- magnetic_to,
50
- plus_poles
51
- ]
52
- end
53
- end
54
-
55
- class FailPolarization < Railway::StepPolarization
56
- def call(magnetic_to, plus_poles, options)
57
- plus_poles = plus_poles.reconnect( :failure => :fail_fast, :success => :fail_fast ) if options[:fail_fast]
58
- plus_poles = plus_poles.reverse_merge( Activity.Output(Activity::FastTrack::FailFast, :fail_fast) => :fail_fast, Activity.Output(Activity::FastTrack::PassFast, :pass_fast) => :pass_fast ) if options[:fast_track]
59
-
60
- [
61
- magnetic_to,
62
- plus_poles
63
- ]
64
- end
65
- end
66
-
67
- class PassPolarization < Railway::StepPolarization
68
- def call(magnetic_to, plus_poles, options)
69
- plus_poles = plus_poles.reconnect( :success => :pass_fast, :failure => :pass_fast ) if options[:pass_fast]
70
- plus_poles = plus_poles.reverse_merge( Activity.Output(Activity::FastTrack::FailFast, :fail_fast) => :fail_fast, Activity.Output(Activity::FastTrack::PassFast, :pass_fast) => :pass_fast ) if options[:fast_track]
71
-
72
- [
73
- magnetic_to,
74
- plus_poles
75
- ]
76
- end
77
- end
78
-
79
- def self.default_plus_poles(*args)
80
- Railway.default_plus_poles(*args)
81
- end
82
-
83
- # Adds the End.fail_fast and End.pass_fast end to the Railway sequence.
84
- def self.InitialAdds(pass_fast_end: Activity.End(:pass_fast), fail_fast_end: Activity.End(:fail_fast), **builder_options)
85
- path_adds = Railway.InitialAdds(**builder_options)
86
-
87
- ends =
88
- adds(
89
- pass_fast_end,
90
-
91
- Path::EndEventPolarizations(builder_options),
92
-
93
- {},
94
- { group: :end },
95
-
96
- id: "End.pass_fast",
97
- magnetic_to: [:pass_fast],
98
- plus_poles: {},
99
- )+
100
- adds(
101
- fail_fast_end,
102
-
103
- Path::EndEventPolarizations(builder_options),
104
-
105
- {},
106
- { group: :end },
107
-
108
- magnetic_to: [:fail_fast],
109
- id: "End.fail_fast",
110
- plus_poles: {},
111
- )
112
-
113
- path_adds + ends
114
- end
115
- end
116
- end
117
- end
118
- end