trailblazer-activity-dsl-linear 0.5.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/CHANGES.md +52 -0
  4. data/Gemfile +3 -1
  5. data/README.md +9 -17
  6. data/lib/trailblazer/activity/dsl/linear/feature/merge.rb +36 -0
  7. data/lib/trailblazer/activity/dsl/linear/feature/patch.rb +40 -0
  8. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb +281 -0
  9. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/inherit.rb +38 -0
  10. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb +298 -0
  11. data/lib/trailblazer/activity/dsl/linear/helper/path.rb +106 -0
  12. data/lib/trailblazer/activity/dsl/linear/helper.rb +54 -128
  13. data/lib/trailblazer/activity/dsl/linear/normalizer/terminus.rb +92 -0
  14. data/lib/trailblazer/activity/dsl/linear/normalizer.rb +194 -77
  15. data/lib/trailblazer/activity/dsl/linear/sequence/builder.rb +47 -0
  16. data/lib/trailblazer/activity/dsl/linear/sequence/compiler.rb +72 -0
  17. data/lib/trailblazer/activity/dsl/linear/sequence/search.rb +58 -0
  18. data/lib/trailblazer/activity/dsl/linear/sequence.rb +34 -0
  19. data/lib/trailblazer/activity/dsl/linear/strategy.rb +116 -71
  20. data/lib/trailblazer/activity/dsl/linear/version.rb +1 -1
  21. data/lib/trailblazer/activity/dsl/linear.rb +21 -177
  22. data/lib/trailblazer/activity/fast_track.rb +42 -53
  23. data/lib/trailblazer/activity/path.rb +52 -127
  24. data/lib/trailblazer/activity/railway.rb +48 -68
  25. data/trailblazer-activity-dsl-linear.gemspec +3 -2
  26. metadata +41 -13
  27. data/lib/trailblazer/activity/dsl/linear/compiler.rb +0 -70
  28. data/lib/trailblazer/activity/dsl/linear/state.rb +0 -63
  29. data/lib/trailblazer/activity/dsl/linear/variable_mapping.rb +0 -240
@@ -1,48 +1,27 @@
1
1
  module Trailblazer
2
2
  class Activity
3
3
  # {Strategy} that helps building simple linear activities.
4
- class Path
4
+ class Path < DSL::Linear::Strategy
5
5
  # Functions that help creating a path-specific sequence.
6
6
  module DSL
7
7
  Linear = Activity::DSL::Linear
8
8
 
9
9
  module_function
10
10
 
11
- def normalizer
12
- TaskWrap::Pipeline.new(normalizer_steps.to_a)
13
- end
11
+ def Normalizer
12
+ # Retrieve the base normalizer from {linear/normalizer.rb} and add processing steps.
13
+ dsl_normalizer = Linear::Normalizer.Normalizer()
14
14
 
15
- # Return {Path::Normalizer} sequence.
16
- private def normalizer_steps
17
- {
18
- "path.outputs" => Linear::Normalizer.Task(method(:merge_path_outputs)),
19
- "path.connections" => Linear::Normalizer.Task(method(:merge_path_connections)),
20
- "path.sequence_insert" => Linear::Normalizer.Task(method(:normalize_sequence_insert)),
21
- "path.normalize_duplications" => Linear::Normalizer.Task(method(:normalize_duplications)),
22
- "path.magnetic_to" => Linear::Normalizer.Task(method(:normalize_magnetic_to)),
23
- "path.wirings" => Linear::Normalizer.Task(Linear::Normalizer.method(:compile_wirings)),
24
- }
25
- end
26
-
27
- def start_sequence(track_name:)
28
- start_default = Activity::Start.new(semantic: :default)
29
- start_event = Linear::Sequence.create_row(task: start_default, id: "Start.default", magnetic_to: nil, wirings: [Linear::Search::Forward(unary_outputs[:success], track_name)])
30
- _sequence = Linear::Sequence[start_event]
31
- end
32
-
33
- # DISCUSS: still not sure this should sit here.
34
- # Pseudo-DSL that prepends {steps} to {sequence}.
35
- def prepend_to_path(sequence, steps, insertion_method=Linear::Insert.method(:Prepend), insert_id="End.success") # FIXME: where do we need you?
36
- new_rows = steps.collect do |id, task|
37
- Linear::Sequence.create_row(
38
- task: task,
39
- magnetic_to: :success,
40
- wirings: [Linear::Search::Forward(unary_outputs[:success], :success)],
41
- id: id,
42
- )
43
- end
44
-
45
- insertion_method.(sequence, new_rows, insert_id)
15
+ Linear::Normalizer.prepend_to(
16
+ dsl_normalizer,
17
+ # "activity.wirings",
18
+ "activity.normalize_outputs_from_dsl",
19
+ {
20
+ "path.outputs" => Linear::Normalizer.Task(method(:merge_path_outputs)),
21
+ "path.connections" => Linear::Normalizer.Task(method(:merge_path_connections)),
22
+ "path.magnetic_to" => Linear::Normalizer.Task(method(:normalize_magnetic_to)),
23
+ }
24
+ )
46
25
  end
47
26
 
48
27
  def unary_outputs
@@ -50,7 +29,7 @@ module Trailblazer
50
29
  end
51
30
 
52
31
  def unary_connections(track_name: :success)
53
- {success: [Linear::Search.method(:Forward), track_name]}
32
+ {success: [Linear::Sequence::Search.method(:Forward), track_name]}
54
33
  end
55
34
 
56
35
  def merge_path_outputs(ctx, outputs: nil, **)
@@ -61,124 +40,70 @@ module Trailblazer
61
40
  ctx[:connections] = connections || unary_connections(track_name: track_name)
62
41
  end
63
42
 
64
- # Processes {:before,:after,:replace,:delete} options and
65
- # defaults to {before: "End.success"} which, yeah.
66
- def normalize_sequence_insert(ctx, end_id:, **)
67
- insertion = ctx.keys & sequence_insert_options.keys
68
- insertion = insertion[0] || :before
69
- target = ctx[insertion] || end_id
70
-
71
- insertion_method = sequence_insert_options[insertion]
72
-
73
- ctx[:sequence_insert] = [Linear::Insert.method(insertion_method), target]
74
- end
75
-
76
- # @private
77
- def sequence_insert_options
78
- {
79
- :before => :Prepend,
80
- :after => :Append,
81
- :replace => :Replace,
82
- :delete => :Delete,
83
- }
43
+ def normalize_magnetic_to(ctx, track_name:, **) # TODO: merge with Railway.merge_magnetic_to
44
+ ctx[:magnetic_to] = ctx.key?(:magnetic_to) ? ctx[:magnetic_to] : track_name # FIXME: can we be magnetic_to {nil}?
84
45
  end
85
46
 
86
- def normalize_duplications(ctx, replace: false, **)
87
- return if replace
88
-
89
- raise_on_duplicate_id(ctx, **ctx)
90
- clone_duplicate_activity(ctx, **ctx) # DISCUSS: mutates {ctx}.
91
- end
47
+ # This is slow and should be done only once at compile-time,
48
+ # DISCUSS: maybe make this a function?
49
+ # These are the normalizers for an {Activity}, to be injected into a State.
50
+ Normalizers = Linear::Normalizer::Normalizers.new(
51
+ step: Normalizer(), # here, we extend the generic FastTrack::step_normalizer with the Activity-specific DSL
52
+ terminus: Linear::Normalizer::Terminus.Normalizer(),
53
+ )
92
54
 
93
- def raise_on_duplicate_id(ctx, id:, sequence:, **)
94
- raise "ID #{id} is already taken. Please specify an `:id`." if sequence.find { |row| row[3][:id] == id }
95
- end
55
+ # pp Normalizers
96
56
 
97
- def clone_duplicate_activity(ctx, task:, sequence:, **)
98
- return unless task.is_a?(Class)
57
+ # DISCUSS: following methods are not part of Normalizer
99
58
 
100
- ctx[:task] = task.clone if sequence.find { |row| row[1] == task }
59
+ def append_terminus(sequence, task, normalizers:, **options)
60
+ _sequence = Linear::Sequence::Builder.update_sequence_for(:terminus, task, options, normalizers: normalizers, sequence: sequence, normalizer_options: {})
101
61
  end
102
62
 
103
- def normalize_magnetic_to(ctx, track_name:, **) # TODO: merge with Railway.merge_magnetic_to
104
- ctx[:magnetic_to] = ctx.key?(:magnetic_to) ? ctx[:magnetic_to] : track_name # FIXME: can we be magnetic_to {nil}?
63
+ # @private
64
+ def start_sequence(track_name:)
65
+ Linear::Strategy::DSL.start_sequence(wirings: [Linear::Sequence::Search::Forward(unary_outputs[:success], track_name)])
105
66
  end
106
67
 
107
68
  # Returns an initial two-step sequence with {Start.default > End.success}.
108
69
  def initial_sequence(track_name:, end_task:, end_id:)
109
- # TODO: this could be an Activity itself but maybe a bit too much for now.
110
70
  sequence = start_sequence(track_name: track_name)
111
- sequence = append_end(sequence, task: end_task, magnetic_to: track_name, id: end_id, append_to: "Start.default")
71
+ sequence = append_terminus(sequence, end_task, id: end_id, magnetic_to: track_name, normalizers: Normalizers, append_to: "Start.default")
112
72
  end
113
73
 
114
- def append_end(sequence, **options)
115
- sequence = Linear::DSL.insert_task(sequence, **append_end_options(**options))
116
- end
117
-
118
- def append_end_options(task:, magnetic_to:, id:, append_to: "End.success")
119
- end_args = {sequence_insert: [Linear::Insert.method(:Append), append_to], stop_event: true}
74
+ def OptionsForSequenceBuilder(normalizers:, track_name: :success, end_task: Activity::End.new(semantic: :success), end_id: "End.success", **options)
75
+ # DISCUSS: instead of calling a separate {initial_sequence} method we could make DSL strategies
76
+ # use the actual DSL to build up the initial_sequence, somewhere outside? Maybe using {:adds}?
77
+ initial_sequence = initial_sequence(track_name: track_name, end_task: end_task, end_id: end_id)
120
78
 
121
79
  {
122
- task: task,
123
- magnetic_to: magnetic_to,
124
- id: id,
125
- wirings: [
126
- Linear::Search::Noop(
127
- Activity::Output.new(task, task.to_h[:semantic]), # DISCUSS: do we really want to transport the semantic "in" the object?
128
- # magnetic_to
129
- )],
130
- # outputs: {magnetic_to => },
131
- # connections: {magnetic_to => [Linear::Search.method(:Noop)]},
132
- **end_args
133
- }
134
- end
135
-
136
- # This is slow and should be done only once at compile-time,
137
- # DISCUSS: maybe make this a function?
138
- # These are the normalizers for an {Activity}, to be injected into a State.
139
- Normalizers = Linear::State::Normalizer.new(
140
- step: Linear::Normalizer.activity_normalizer(Path::DSL.normalizer), # here, we extend the generic FastTrack::step_normalizer with the Activity-specific DSL
141
- )
142
-
143
- # pp Normalizers
144
-
145
- def self.OptionsForState(normalizers: Normalizers, track_name: :success, end_task: Activity::End.new(semantic: :success), end_id: "End.success", **options)
146
- initial_sequence = Path::DSL.initial_sequence(track_name: track_name, end_task: end_task, end_id: end_id) # DISCUSS: the standard initial_seq could be cached.
147
-
148
- {
149
- normalizers: normalizers,
150
- initial_sequence: initial_sequence,
151
-
80
+ sequence: initial_sequence,
81
+ normalizers: normalizers,
152
82
  track_name: track_name,
153
83
  end_id: end_id,
154
84
  step_interface_builder: Activity::TaskBuilder.method(:Binary), # DISCUSS: this is currently the only option we want to pass on in Path() ?
155
- adds: [],
85
+ adds: [], # DISCUSS: needed?
156
86
  **options
157
87
  }
158
88
  end
159
-
160
- # Implements the actual API ({#step} and friends).
161
- # This can be used later to create faster DSLs where the activity is compiled only once, a la
162
- # Path() do ... end
163
- class State < Linear::State
164
- def step(*args)
165
- _seq = Linear::Strategy.task_for!(self, :step, *args) # mutate @state
166
- end
167
- end
168
-
169
89
  end # DSL
170
90
 
171
- include DSL::Linear::Helper
172
- extend DSL::Linear::Strategy
173
-
174
- initialize!(Path::DSL::State.new(**DSL.OptionsForState()))
91
+ compile_strategy!(DSL, normalizers: DSL::Normalizers) # sets :normalizer, normalizer_options, sequence and activity
175
92
  end # Path
176
93
 
177
- def self.Path(**options)
178
- Class.new(Path) do
179
- initialize!(Path::DSL::State.new(**Path::DSL.OptionsForState(**options)))
180
- end
94
+ def self.Path(**options, &block)
95
+ Activity::DSL::Linear::Strategy::DSL.Build(Path, **options, &block)
181
96
  end
182
97
  end
183
98
  end
184
99
 
100
+ =begin
101
+ class Operation
102
+ def self.subclassed(track_name:) # FIXME: it should be run in SubOperation context.
103
+ # initialize code here
104
+ end
105
+
106
+ end
107
+
108
+ SubOperation = Class.new(Operation, track_name: :green)
109
+ =end
@@ -1,43 +1,50 @@
1
1
  module Trailblazer
2
- # Implementation module that can be passed to `Activity[]`.
3
2
  class Activity
4
- class Railway
3
+ class Railway < DSL::Linear::Strategy
4
+
5
5
  module DSL
6
6
  Linear = Activity::DSL::Linear
7
7
 
8
8
  module_function
9
9
 
10
- def normalizer
11
- step_options(Activity::Path::DSL.normalizer)
12
- end
10
+ def Normalizer
11
+ path_normalizer = Path::DSL.Normalizer()
13
12
 
14
- # Change some parts of the "normal" {normalizer} pipeline.
15
- # TODO: make this easier, even at this step.
13
+ Linear::Normalizer.prepend_to(
14
+ path_normalizer,
15
+ "activity.wirings",
16
+ {
17
+ "railway.outputs" => Linear::Normalizer.Task(method(:normalize_path_outputs)),
18
+ "railway.connections" => Linear::Normalizer.Task(method(:normalize_path_connections)),
19
+ },
20
+ )
21
+ end
16
22
 
17
- def normalizer_for_fail
18
- pipeline = TaskWrap::Pipeline.prepend(
19
- normalizer,
20
- "path.wirings",
23
+ # Change some parts of the step-{Normalizer} pipeline.
24
+ # We're bound to using a very primitive Pipeline API, remember, we don't have
25
+ # a DSL at this point!
26
+ def NormalizerForFail
27
+ pipeline = Linear::Normalizer.prepend_to(
28
+ Normalizer(),
29
+ "activity.wirings",
21
30
  {
22
31
  "railway.magnetic_to.fail" => Linear::Normalizer.Task(Fail.method(:merge_magnetic_to)),
23
32
  }
24
33
  )
25
34
 
26
- pipeline = TaskWrap::Pipeline.prepend(
35
+ pipeline = Linear::Normalizer.replace(
27
36
  pipeline,
28
37
  "path.connections",
29
- {
30
- "railway.connections.fail.success_to_failure" => Linear::Normalizer.Task(Fail.method(:connect_success_to_failure)),
31
- },
32
- replace: 1 # replace {"path.connections"}
38
+ ["railway.connections.fail.success_to_failure", Linear::Normalizer.Task(Fail.method(:connect_success_to_failure))],
33
39
  )
34
40
  end
35
41
 
36
- def normalizer_for_pass
37
- pipeline = TaskWrap::Pipeline.insert_after(
38
- normalizer,
39
- "path.connections",
40
- ["railway.connections.pass.failure_to_success", Linear::Normalizer.Task(Pass.method(:connect_failure_to_success))],
42
+ def NormalizerForPass
43
+ Linear::Normalizer.prepend_to(
44
+ Normalizer(),
45
+ "activity.normalize_outputs_from_dsl",
46
+ # "path.connections",
47
+ {"railway.connections.pass.failure_to_success" => Linear::Normalizer.Task(Pass.method(:connect_failure_to_success))}.to_a
41
48
  )
42
49
  end
43
50
 
@@ -49,7 +56,7 @@ module Trailblazer
49
56
  end
50
57
 
51
58
  def connect_success_to_failure(ctx, connections: nil, **)
52
- ctx[:connections] = connections || {success: [Linear::Search.method(:Forward), :failure]}
59
+ ctx[:connections] = connections || {success: [Linear::Sequence::Search.method(:Forward), :failure]}
53
60
  end
54
61
  end
55
62
 
@@ -57,22 +64,10 @@ module Trailblazer
57
64
  module_function
58
65
 
59
66
  def connect_failure_to_success(ctx, connections:, **)
60
- ctx[:connections] = connections.merge({failure: [Linear::Search.method(:Forward), :success]})
67
+ ctx[:connections] = connections.merge({failure: [Linear::Sequence::Search.method(:Forward), :success]})
61
68
  end
62
69
  end
63
70
 
64
- # Add {Railway} steps to normalizer path.
65
- def step_options(pipeline)
66
- TaskWrap::Pipeline.prepend(
67
- pipeline,
68
- "path.wirings",
69
- {
70
- "railway.outputs" => Linear::Normalizer.Task(method(:normalize_path_outputs)),
71
- "railway.connections" => Linear::Normalizer.Task(method(:normalize_path_connections)),
72
- },
73
- )
74
- end
75
-
76
71
  # Add {:failure} output to {:outputs}.
77
72
  # TODO: assert that failure_outputs doesn't override existing {:outputs}
78
73
  def normalize_path_outputs(ctx, outputs:, **)
@@ -88,65 +83,50 @@ module Trailblazer
88
83
  def failure_outputs
89
84
  {failure: Activity::Output(Activity::Left, :failure)}
90
85
  end
86
+
91
87
  def failure_connections
92
- {failure: [Linear::Search.method(:Forward), :failure]}
88
+ {failure: [Linear::Sequence::Search.method(:Forward), :failure]}
93
89
  end
94
90
 
95
- def initial_sequence(failure_end:, initial_sequence:, **path_options)
96
- # TODO: this could be an Activity itself but maybe a bit too much for now.
97
- _seq = Path::DSL.append_end(initial_sequence, task: failure_end, magnetic_to: :failure, id: "End.failure")
91
+ def initial_sequence(failure_end:, sequence:, **path_options)
92
+ _seq = Path::DSL.append_terminus(sequence, failure_end, magnetic_to: :failure, id: "End.failure", normalizers: Normalizers)
98
93
  end
99
94
 
100
- class State < Path::DSL::State
101
- def fail(*args)
102
- _seq = Linear::Strategy.task_for!(self, :fail, *args) # mutate @state
103
- end
104
-
105
- def pass(*args)
106
- _seq = Linear::Strategy.task_for!(self, :pass, *args) # mutate @state
107
- end
108
- end # Instance
109
-
110
- Normalizers = Linear::State::Normalizer.new(
111
- step: Linear::Normalizer.activity_normalizer( Railway::DSL.normalizer ), # here, we extend the generic FastTrack::step_normalizer with the Activity-specific DSL
112
- fail: Linear::Normalizer.activity_normalizer( Railway::DSL.normalizer_for_fail ),
113
- pass: Linear::Normalizer.activity_normalizer( Railway::DSL.normalizer_for_pass ),
95
+ Normalizers = Linear::Normalizer::Normalizers.new(
96
+ step: Railway::DSL.Normalizer(),
97
+ fail: Railway::DSL.NormalizerForFail(),
98
+ pass: Railway::DSL.NormalizerForPass(),
99
+ terminus: Linear::Normalizer::Terminus.Normalizer(),
114
100
  )
115
101
 
116
- def self.OptionsForState(normalizers: Normalizers, failure_end: Activity::End.new(semantic: :failure), **options)
117
- options = Path::DSL.OptionsForState(**options).
118
- merge(normalizers: normalizers, failure_end: failure_end)
102
+ def self.OptionsForSequenceBuilder(failure_end: Activity::End.new(semantic: :failure), **options)
103
+ options = Path::DSL.OptionsForSequenceBuilder(**options).
104
+ merge(failure_end: failure_end)
119
105
 
120
106
  initial_sequence = Railway::DSL.initial_sequence(failure_end: failure_end, **options)
121
107
 
122
108
  {
123
109
  **options,
124
- initial_sequence: initial_sequence,
110
+ sequence: initial_sequence,
125
111
  }
126
112
  end
127
-
128
113
  end # DSL
129
114
 
130
115
  class << self
131
- private def fail(*args, &block)
116
+ def fail(*args, &block)
132
117
  recompile_activity_for(:fail, *args, &block)
133
118
  end
134
119
 
135
- private def pass(*args, &block)
120
+ def pass(*args, &block)
136
121
  recompile_activity_for(:pass, *args, &block)
137
122
  end
138
123
  end
139
124
 
140
- include DSL::Linear::Helper
141
- extend DSL::Linear::Strategy
142
-
143
- initialize!(Railway::DSL::State.new(**DSL.OptionsForState()))
125
+ compile_strategy!(DSL, normalizers: DSL::Normalizers)
144
126
  end # Railway
145
127
 
146
- def self.Railway(options)
147
- Class.new(Railway) do
148
- initialize!(Railway::DSL::State.new(**Railway::DSL.OptionsForState(**options)))
149
- end
128
+ def self.Railway(**options, &block)
129
+ Activity::DSL::Linear::Strategy::DSL.Build(Railway, **options, &block)
150
130
  end
151
131
  end
152
132
  end
@@ -19,12 +19,13 @@ Gem::Specification.new do |spec|
19
19
  end
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "trailblazer-activity", ">= 0.13.0", "< 1.0.0"
22
+ spec.add_dependency "trailblazer-activity", ">= 0.14.0.beta1", "< 0.15.0"
23
+ spec.add_dependency "trailblazer-declarative", ">= 0.0.1", "< 0.1.0"
23
24
 
24
25
  spec.add_development_dependency "bundler"
25
26
  spec.add_development_dependency "minitest", "~> 5.0"
26
27
  spec.add_development_dependency "rake"
27
- spec.add_development_dependency "trailblazer-developer", ">= 0.0.21"
28
+ spec.add_development_dependency "trailblazer-developer", ">= 0.0.24"
28
29
 
29
30
  spec.required_ruby_version = '>= 2.1.0'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity-dsl-linear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity
@@ -16,20 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.0
19
+ version: 0.14.0.beta1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.0
22
+ version: 0.15.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.13.0
29
+ version: 0.14.0.beta1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.0
32
+ version: 0.15.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: trailblazer-declarative
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.1
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.1.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.0.1
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.1.0
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: bundler
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +98,14 @@ dependencies:
78
98
  requirements:
79
99
  - - ">="
80
100
  - !ruby/object:Gem::Version
81
- version: 0.0.21
101
+ version: 0.0.24
82
102
  type: :development
83
103
  prerelease: false
84
104
  version_requirements: !ruby/object:Gem::Requirement
85
105
  requirements:
86
106
  - - ">="
87
107
  - !ruby/object:Gem::Version
88
- version: 0.0.21
108
+ version: 0.0.24
89
109
  description: Simple DSL to define Trailblazer activities with arbitrary wirings.
90
110
  email:
91
111
  - apotonick@gmail.com
@@ -103,12 +123,20 @@ files:
103
123
  - Rakefile
104
124
  - lib/trailblazer-activity-dsl-linear.rb
105
125
  - lib/trailblazer/activity/dsl/linear.rb
106
- - lib/trailblazer/activity/dsl/linear/compiler.rb
126
+ - lib/trailblazer/activity/dsl/linear/feature/merge.rb
127
+ - lib/trailblazer/activity/dsl/linear/feature/patch.rb
128
+ - lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb
129
+ - lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb
130
+ - lib/trailblazer/activity/dsl/linear/feature/variable_mapping/inherit.rb
107
131
  - lib/trailblazer/activity/dsl/linear/helper.rb
132
+ - lib/trailblazer/activity/dsl/linear/helper/path.rb
108
133
  - lib/trailblazer/activity/dsl/linear/normalizer.rb
109
- - lib/trailblazer/activity/dsl/linear/state.rb
134
+ - lib/trailblazer/activity/dsl/linear/normalizer/terminus.rb
135
+ - lib/trailblazer/activity/dsl/linear/sequence.rb
136
+ - lib/trailblazer/activity/dsl/linear/sequence/builder.rb
137
+ - lib/trailblazer/activity/dsl/linear/sequence/compiler.rb
138
+ - lib/trailblazer/activity/dsl/linear/sequence/search.rb
110
139
  - lib/trailblazer/activity/dsl/linear/strategy.rb
111
- - lib/trailblazer/activity/dsl/linear/variable_mapping.rb
112
140
  - lib/trailblazer/activity/dsl/linear/version.rb
113
141
  - lib/trailblazer/activity/fast_track.rb
114
142
  - lib/trailblazer/activity/path.rb
@@ -129,9 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
157
  version: 2.1.0
130
158
  required_rubygems_version: !ruby/object:Gem::Requirement
131
159
  requirements:
132
- - - ">="
160
+ - - ">"
133
161
  - !ruby/object:Gem::Version
134
- version: '0'
162
+ version: 1.3.1
135
163
  requirements: []
136
164
  rubygems_version: 3.2.3
137
165
  signing_key:
@@ -1,70 +0,0 @@
1
- module Trailblazer
2
- class Activity
3
- module DSL
4
- module Linear
5
- # Compile a {Schema} by computing {implementations} and {intermediate} from a {Sequence}.
6
- module Compiler
7
- module_function
8
-
9
- # Default strategy to find out what's a stop event is to inspect the TaskRef's {data[:stop_event]}.
10
- def find_stop_task_ids(intermediate_wiring)
11
- intermediate_wiring.collect { |task_ref, outs| task_ref.data[:stop_event] ? task_ref.id : nil }.compact
12
- end
13
-
14
- # The first task in the wiring is the default start task.
15
- def find_start_task_ids(intermediate_wiring)
16
- [intermediate_wiring.first.first.id]
17
- end
18
-
19
- def call(sequence, find_stops: method(:find_stop_task_ids), find_start: method(:find_start_task_ids))
20
- _implementations, intermediate_wiring =
21
- sequence.inject([[], []]) do |(implementations, intermediates), seq_row|
22
- _magnetic_to, task, connections, data = seq_row
23
- id = data[:id]
24
-
25
- # execute all {Search}s for one sequence row.
26
- connections = find_connections(seq_row, connections, sequence)
27
-
28
- # FIXME: {:extensions} should be initialized
29
- implementations += [[id, Schema::Implementation::Task(task, connections.collect { |output, _| output }, data[:extensions] || []) ]]
30
-
31
- intermediates += [
32
- [
33
- Schema::Intermediate::TaskRef(id, data),
34
- # Compute outputs.
35
- connections.collect { |output, target_id| Schema::Intermediate::Out(output.semantic, target_id) }
36
- ]
37
- ]
38
-
39
- [implementations, intermediates]
40
- end
41
-
42
- start_task_ids = find_start.(intermediate_wiring)
43
- stop_task_refs = find_stops.(intermediate_wiring)
44
-
45
- intermediate = Schema::Intermediate.new(Hash[intermediate_wiring], stop_task_refs, start_task_ids)
46
- implementation = Hash[_implementations]
47
-
48
- Schema::Intermediate.(intermediate, implementation) # implemented in the generic {trailblazer-activity} gem.
49
- end
50
-
51
- # private
52
-
53
- def find_connections(seq_row, strategies, sequence)
54
- strategies.collect do |search|
55
- output, target_seq_row = search.(sequence, seq_row) # invoke the node's "connection search" strategy.
56
-
57
- target_seq_row = sequence[-1] if target_seq_row.nil? # connect to an End if target unknown. # DISCUSS: make this configurable, maybe?
58
-
59
- [
60
- output, # implementation
61
- target_seq_row[3][:id], # intermediate # FIXME. this sucks.
62
- target_seq_row # DISCUSS: needed?
63
- ]
64
- end.compact
65
- end
66
- end # Compiler
67
- end
68
- end
69
- end
70
- end