trailblazer-activity 0.4.3 → 0.5.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/.travis.yml +1 -1
- data/CHANGES.md +6 -0
- data/NOTES +3 -0
- data/lib/trailblazer/activity.rb +17 -15
- data/lib/trailblazer/activity/dsl/add_task.rb +4 -4
- data/lib/trailblazer/activity/dsl/helper.rb +13 -5
- data/lib/trailblazer/activity/dsl/magnetic.rb +36 -0
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder.rb +4 -6
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder/default_normalizer.rb +0 -0
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder/fast_track.rb +2 -14
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder/normalizer.rb +2 -2
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder/path.rb +9 -15
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/builder/railway.rb +1 -13
- data/lib/trailblazer/activity/{state.rb → dsl/magnetic/builder/state.rb} +5 -5
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/finalizer.rb +0 -0
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/generate.rb +0 -0
- data/lib/trailblazer/activity/dsl/magnetic/merge.rb +16 -0
- data/lib/trailblazer/activity/{magnetic/dsl.rb → dsl/magnetic/process_options.rb} +11 -28
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/structure/alterations.rb +0 -0
- data/lib/trailblazer/activity/{magnetic → dsl/magnetic}/structure/plus_poles.rb +2 -9
- data/lib/trailblazer/activity/dsl/magnetic/structure/polarization.rb +23 -0
- data/lib/trailblazer/activity/dsl/record.rb +11 -0
- data/lib/trailblazer/activity/{schema → dsl/schema}/dependencies.rb +0 -0
- data/lib/trailblazer/activity/{schema → dsl/schema}/sequence.rb +0 -0
- data/lib/trailblazer/activity/{implementation → dsl/strategy}/build_state.rb +1 -1
- data/lib/trailblazer/activity/{implementation → dsl/strategy}/fast_track.rb +5 -0
- data/lib/trailblazer/activity/{implementation → dsl/strategy}/path.rb +5 -1
- data/lib/trailblazer/activity/{implementation → dsl/strategy}/plan.rb +0 -0
- data/lib/trailblazer/activity/{implementation → dsl/strategy}/railway.rb +5 -1
- data/lib/trailblazer/activity/{implementation/interface.rb → interface.rb} +0 -0
- data/lib/trailblazer/activity/introspect.rb +3 -1
- data/lib/trailblazer/activity/structures.rb +5 -4
- data/lib/trailblazer/activity/version.rb +1 -1
- metadata +26 -26
- data/NOTES_ +0 -36
- data/lib/trailblazer/activity/magnetic.rb +0 -36
- data/lib/trailblazer/activity/magnetic/merge.rb +0 -18
- data/lib/trailblazer/activity/subprocess.rb +0 -41
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dab847dcaff55b44bfa62dad2a7f8e662458bc082e941dccf1e8f189b87eb6fa
|
|
4
|
+
data.tar.gz: f8c1782081b72b024f5fdc06e49d040825979c3cd825cd2a242270fc100d65c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acd50922b312667f892d6b73d0c39fdb5cfc136f5421af01fdbb0383e065845e332518b02d068a3279b72cc5cbec1e2f6d22c0a9cbaf77abe25af8669b31a0f9
|
|
7
|
+
data.tar.gz: e493008be86cff07f981fb6ab6542b14749f17dc91c542bde511f7cfabe14b8b8b0c1eb91dccc6b714a24d66567846b03fe2dbc6898bd598b48b0dd2d16c5192
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# 0.5.0
|
|
2
|
+
|
|
3
|
+
* Rename `Nested()` to `Subprocess` and move the original one to the `operation` gem.
|
|
4
|
+
* Add merging: `Activity.merge!` now allows to compose an activity by merging another.
|
|
5
|
+
* Enforce using `Output(..) => Track(:success)` instead of just the track color `:success`. This allow having IDs both symbols and strings.
|
|
6
|
+
|
|
1
7
|
# 0.4.3
|
|
2
8
|
|
|
3
9
|
* Make `:outputs` the canonical way to define outputs, and not `:plus_poles`. The latter is computed by the DSL if not passed.
|
data/NOTES
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# 2.2
|
|
2
|
+
* The `Polarizations` classes, e.g. in `FastTrack` could be steps in the normalizer? so we wouldn't need `reverse_merge`.
|
|
3
|
+
|
|
1
4
|
# NOT lowest level. if you need that, use your own proc.
|
|
2
5
|
# TODO: how do we track what goes into the callable?
|
|
3
6
|
# adjust what goes into it (e.g. without direction or with kw args)?
|
data/lib/trailblazer/activity.rb
CHANGED
|
@@ -34,6 +34,8 @@ module Trailblazer
|
|
|
34
34
|
def inspect
|
|
35
35
|
"#<Trailblazer::Activity: {#{name || self[:options][:name]}}>"
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
alias_method :to_s, :inspect
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
|
|
@@ -42,7 +44,7 @@ module Trailblazer
|
|
|
42
44
|
module DSLHelper
|
|
43
45
|
extend Forwardable
|
|
44
46
|
def_delegators :@builder, :Path
|
|
45
|
-
def_delegators DSL::Helper, :Output, :End, :
|
|
47
|
+
def_delegators DSL::Helper, :Output, :End, :Subprocess, :Track
|
|
46
48
|
|
|
47
49
|
def Path(*args, &block)
|
|
48
50
|
self[:builder].Path(*args, &block)
|
|
@@ -69,14 +71,14 @@ module Trailblazer
|
|
|
69
71
|
require "trailblazer/activity/dsl/add_task"
|
|
70
72
|
include DSL::AddTask
|
|
71
73
|
|
|
72
|
-
require "trailblazer/activity/
|
|
74
|
+
require "trailblazer/activity/interface"
|
|
73
75
|
include Activity::Interface # DISCUSS
|
|
74
76
|
|
|
75
77
|
include DSLHelper # DISCUSS
|
|
76
78
|
|
|
77
79
|
include Activity::Inspect # DISCUSS
|
|
78
80
|
|
|
79
|
-
require "trailblazer/activity/magnetic/merge"
|
|
81
|
+
require "trailblazer/activity/dsl/magnetic/merge"
|
|
80
82
|
include Magnetic::Merge # Activity#merge!
|
|
81
83
|
|
|
82
84
|
def call(args, argumenter: [], **circuit_options) # DISCUSS: the argumenter logic might be moved out.
|
|
@@ -92,12 +94,11 @@ require "trailblazer/circuit"
|
|
|
92
94
|
require "trailblazer/activity/structures"
|
|
93
95
|
require "trailblazer/activity/config"
|
|
94
96
|
|
|
95
|
-
require "trailblazer/activity/
|
|
96
|
-
require "trailblazer/activity/
|
|
97
|
-
require "trailblazer/activity/
|
|
98
|
-
require "trailblazer/activity/
|
|
99
|
-
require "trailblazer/activity/
|
|
100
|
-
require "trailblazer/activity/implementation/fast_track"
|
|
97
|
+
require "trailblazer/activity/dsl/strategy/build_state"
|
|
98
|
+
require "trailblazer/activity/dsl/strategy/path"
|
|
99
|
+
require "trailblazer/activity/dsl/strategy/plan"
|
|
100
|
+
require "trailblazer/activity/dsl/strategy/railway"
|
|
101
|
+
require "trailblazer/activity/dsl/strategy/fast_track"
|
|
101
102
|
|
|
102
103
|
require "trailblazer/activity/task_wrap"
|
|
103
104
|
require "trailblazer/activity/task_wrap/call_task"
|
|
@@ -110,11 +111,12 @@ require "trailblazer/activity/present"
|
|
|
110
111
|
|
|
111
112
|
require "trailblazer/activity/introspect"
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
require "trailblazer/activity/
|
|
114
|
+
require "trailblazer/activity/dsl/magnetic/builder/state"
|
|
115
|
+
require "trailblazer/activity/dsl/magnetic" # the "magnetic" DSL
|
|
116
|
+
|
|
117
|
+
require "trailblazer/activity/dsl/schema/sequence"
|
|
118
|
+
require "trailblazer/activity/dsl/schema/dependencies"
|
|
115
119
|
|
|
116
|
-
require "trailblazer/activity/
|
|
117
|
-
require "trailblazer/activity/magnetic" # the "magnetic" DSL
|
|
118
|
-
require "trailblazer/activity/schema/sequence"
|
|
120
|
+
require "trailblazer/activity/dsl/magnetic/builder/normalizer" # DISCUSS: name and location are odd. This one uses Activity ;)
|
|
119
121
|
|
|
120
|
-
require "trailblazer/activity/
|
|
122
|
+
require "trailblazer/activity/dsl/record"
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
class Trailblazer::Activity < Module
|
|
2
2
|
module DSL
|
|
3
3
|
module AddTask
|
|
4
|
-
def add_task!(name, task, options, &block)
|
|
4
|
+
def add_task!(strategy, polarizer, name, task, options, &block)
|
|
5
5
|
# The beautiful thing about State.add is it doesn't mutate anything.
|
|
6
6
|
# We're changing state here, on the outside, by overriding the ivars.
|
|
7
7
|
# That in turn means, the only mutated entity is this module.
|
|
8
8
|
|
|
9
|
-
_builder, adds, circuit, outputs,
|
|
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
10
|
|
|
11
11
|
self[:adds] = adds
|
|
12
12
|
self[:circuit] = circuit
|
|
13
13
|
self[:outputs] = outputs
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
_, local_options = returned_options
|
|
16
16
|
|
|
17
17
|
# {Extension API} call all extensions.
|
|
18
|
-
local_options[:extension].collect { |ext| ext.(self, *options) } if local_options[:extension]
|
|
18
|
+
local_options[:extension].collect { |ext| ext.( self, *returned_options, original_dsl_args: [name, task, options, block] ) } if local_options[:extension]
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -4,14 +4,18 @@ module Trailblazer
|
|
|
4
4
|
# the circuit, etc. Method comes in a module so it can be overridden via modules.
|
|
5
5
|
#
|
|
6
6
|
# This approach assumes you maintain a {#add_task!} method.
|
|
7
|
-
def self.def_dsl(_name)
|
|
7
|
+
def self.def_dsl(_name, strategy, polarizer)
|
|
8
8
|
Module.new do
|
|
9
9
|
define_method(_name) do |task, options={}, &block|
|
|
10
|
-
builder, adds, circuit, outputs, options = add_task!(_name, task, options, &block)
|
|
10
|
+
builder, adds, circuit, outputs, options = add_task!(strategy, polarizer, _name, task, options, &block)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
# @api private
|
|
16
|
+
OutputSemantic = Struct.new(:value)
|
|
17
|
+
Track = Struct.new(:color)
|
|
18
|
+
|
|
15
19
|
# Shortcut functions for the DSL. These have no state.
|
|
16
20
|
module Helper
|
|
17
21
|
module_function
|
|
@@ -19,7 +23,7 @@ module Trailblazer
|
|
|
19
23
|
# Output( Left, :failure )
|
|
20
24
|
# Output( :failure ) #=> Output::Semantic
|
|
21
25
|
def Output(signal, semantic=nil)
|
|
22
|
-
return
|
|
26
|
+
return OutputSemantic.new(signal) if semantic.nil?
|
|
23
27
|
|
|
24
28
|
Activity.Output(signal, semantic)
|
|
25
29
|
end
|
|
@@ -28,8 +32,12 @@ module Trailblazer
|
|
|
28
32
|
Activity.End(semantic)
|
|
29
33
|
end
|
|
30
34
|
|
|
35
|
+
def Track(color)
|
|
36
|
+
Track.new(color).freeze
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
def Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options)
|
|
32
|
-
options
|
|
40
|
+
options = options.merge(track_color: track_color, end_semantic: end_semantic)
|
|
33
41
|
|
|
34
42
|
# Build an anonymous class which will be where the block is evaluated in.
|
|
35
43
|
# We use the same normalizer here, so DSL calls in the inner block have the same behavior.
|
|
@@ -46,7 +54,7 @@ module Trailblazer
|
|
|
46
54
|
end
|
|
47
55
|
|
|
48
56
|
# Computes the :outputs options for {activity}
|
|
49
|
-
def
|
|
57
|
+
def Subprocess(activity)
|
|
50
58
|
{
|
|
51
59
|
task: activity,
|
|
52
60
|
outputs: activity.outputs
|
|
@@ -0,0 +1,36 @@
|
|
|
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,5 +1,3 @@
|
|
|
1
|
-
require "trailblazer/activity/magnetic/finalizer"
|
|
2
|
-
|
|
3
1
|
module Trailblazer
|
|
4
2
|
module Activity::Magnetic
|
|
5
3
|
|
|
@@ -41,21 +39,21 @@ module Trailblazer
|
|
|
41
39
|
end
|
|
42
40
|
|
|
43
41
|
# Public top-level entry point.
|
|
44
|
-
def insert(
|
|
42
|
+
def insert(strategy, polarizer, task, options, &block)
|
|
45
43
|
normalizer = options[:normalizer] || @normalizer # DISCUSS: do this at a deeper point?
|
|
46
44
|
|
|
47
45
|
task, local_options, connection_options, sequence_options = normalizer.(task, options)
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
polarizations = strategy.send(polarizer, @builder_options) # Railway.StepPolarizations( @builder_options )
|
|
50
48
|
|
|
51
|
-
insert_element(
|
|
49
|
+
insert_element( polarizations, task, local_options, connection_options, sequence_options, &block )
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
private
|
|
55
53
|
|
|
56
54
|
# Internal top-level entry point to add task(s) and connections.
|
|
57
55
|
# High level interface for DSL calls like ::task or ::step.
|
|
58
|
-
def insert_element(
|
|
56
|
+
def insert_element(polarizations, task, local_options, connection_options, sequence_options, &block)
|
|
59
57
|
adds, *returned_options = Builder.adds_for(polarizations, task, local_options, connection_options, sequence_options, &block)
|
|
60
58
|
end
|
|
61
59
|
|
|
File without changes
|
|
@@ -88,7 +88,7 @@ module Trailblazer
|
|
|
88
88
|
adds(
|
|
89
89
|
pass_fast_end,
|
|
90
90
|
|
|
91
|
-
Path::
|
|
91
|
+
Path::EndEventPolarizations(builder_options),
|
|
92
92
|
|
|
93
93
|
{},
|
|
94
94
|
{ group: :end },
|
|
@@ -100,7 +100,7 @@ module Trailblazer
|
|
|
100
100
|
adds(
|
|
101
101
|
fail_fast_end,
|
|
102
102
|
|
|
103
|
-
Path::
|
|
103
|
+
Path::EndEventPolarizations(builder_options),
|
|
104
104
|
|
|
105
105
|
{},
|
|
106
106
|
{ group: :end },
|
|
@@ -116,18 +116,6 @@ module Trailblazer
|
|
|
116
116
|
# Direction signals.
|
|
117
117
|
FailFast = Class.new(Activity::Signal)
|
|
118
118
|
PassFast = Class.new(Activity::Signal)
|
|
119
|
-
|
|
120
|
-
def step(task, options={}, &block)
|
|
121
|
-
return FastTrack, FastTrack.StepPolarizations(@builder_options), task, options, block
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def fail(task, options={}, &block)
|
|
125
|
-
return FastTrack, FastTrack.FailPolarizations(@builder_options), task, options, block
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def pass(task, options={}, &block)
|
|
129
|
-
return FastTrack, FastTrack.PassPolarizations(@builder_options), task, options, block
|
|
130
|
-
end
|
|
131
119
|
end
|
|
132
120
|
end
|
|
133
121
|
end
|
|
@@ -54,13 +54,13 @@ module Trailblazer
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# Filter out connections, e.g. `Output(:fail_fast) => :success` and return only the keywords like `:id` or `:replace`.
|
|
57
|
-
def self.extract_dsl_keywords(options, connection_classes = [Activity::Output, DSL::
|
|
57
|
+
def self.extract_dsl_keywords(options, connection_classes = [Activity::Output, Activity::DSL::OutputSemantic])
|
|
58
58
|
options.keys - options.keys.find_all { |k| connection_classes.include?( k.class ) }
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# FIXME; why don't we use the extensions passed into the initializer?
|
|
62
62
|
def self.normalize_extension_option( ctx, local_options:, ** )
|
|
63
|
-
local_options[:extension] = (local_options[:extension]||[]) + [ Activity::Introspect.method(:add_introspection) ] # fixme: this sucks
|
|
63
|
+
local_options[:extension] = (local_options[:extension]||[]) + [ Activity::Introspect.method(:add_introspection), Activity::DSL.method(:record) ] # fixme: this sucks
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Normalizes ctx[:options]
|
|
@@ -14,17 +14,9 @@ module Trailblazer
|
|
|
14
14
|
)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def task(task, options={}, &block)
|
|
18
|
-
polarizations = Path.TaskPolarizations( @builder_options.merge( type: options[:type] ) ) # DISCUSS: handle :type here? Really?
|
|
19
|
-
|
|
20
|
-
return Path, polarizations, task, options, block
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# @private Might be removed.
|
|
24
17
|
def self.default_outputs
|
|
25
18
|
{
|
|
26
|
-
success: Activity.Output(Activity::Right, :success)
|
|
27
|
-
# failure: Activity.Output(Activity::Left, :failure),
|
|
19
|
+
success: Activity.Output(Activity::Right, :success)
|
|
28
20
|
}
|
|
29
21
|
end
|
|
30
22
|
|
|
@@ -48,7 +40,7 @@ module Trailblazer
|
|
|
48
40
|
end_adds = adds(
|
|
49
41
|
track_end,
|
|
50
42
|
|
|
51
|
-
|
|
43
|
+
EndEventPolarizations(builder_options),
|
|
52
44
|
|
|
53
45
|
{}, { group: :end },
|
|
54
46
|
|
|
@@ -60,12 +52,14 @@ module Trailblazer
|
|
|
60
52
|
start_adds + end_adds
|
|
61
53
|
end
|
|
62
54
|
|
|
63
|
-
def self.TaskPolarizations(track_color:,
|
|
64
|
-
return [EndPolarization.new( track_color: track_color )] if type == :End # DISCUSS: should this dispatch be here?
|
|
65
|
-
|
|
55
|
+
def self.TaskPolarizations(track_color:, **)
|
|
66
56
|
[TaskPolarization.new( track_color: track_color )]
|
|
67
57
|
end
|
|
68
58
|
|
|
59
|
+
def self.EndEventPolarizations(track_color:, **)
|
|
60
|
+
[EndEventPolarization.new( track_color: track_color )]
|
|
61
|
+
end
|
|
62
|
+
|
|
69
63
|
class TaskPolarization
|
|
70
64
|
def initialize(track_color:)
|
|
71
65
|
@track_color = track_color
|
|
@@ -79,14 +73,14 @@ module Trailblazer
|
|
|
79
73
|
end
|
|
80
74
|
end # TaskPolarization
|
|
81
75
|
|
|
82
|
-
class
|
|
76
|
+
class EndEventPolarization < TaskPolarization
|
|
83
77
|
def call(magnetic_to, plus_poles, options)
|
|
84
78
|
[
|
|
85
79
|
magnetic_to || [@track_color],
|
|
86
80
|
{}
|
|
87
81
|
]
|
|
88
82
|
end
|
|
89
|
-
end #
|
|
83
|
+
end # EndEventPolarization
|
|
90
84
|
end # Path
|
|
91
85
|
end # Builder
|
|
92
86
|
end
|
|
@@ -10,18 +10,6 @@ module Trailblazer
|
|
|
10
10
|
)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def step(task, options={}, &block)
|
|
14
|
-
return Railway, Railway.StepPolarizations(@builder_options), task, options, block
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def fail(task, options={}, &block)
|
|
18
|
-
return Railway, Railway.FailPolarizations(@builder_options), task, options, block
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def pass(task, options={}, &block)
|
|
22
|
-
return Railway, Railway.PassPolarizations(@builder_options), task, options, block
|
|
23
|
-
end
|
|
24
|
-
|
|
25
13
|
def self.default_outputs
|
|
26
14
|
Path.default_outputs.merge(
|
|
27
15
|
:failure => Activity.Output(Activity::Left, :failure),
|
|
@@ -36,7 +24,7 @@ module Trailblazer
|
|
|
36
24
|
end_adds = adds(
|
|
37
25
|
failure_end,
|
|
38
26
|
|
|
39
|
-
Path::
|
|
27
|
+
Path::EndEventPolarizations(builder_options),
|
|
40
28
|
|
|
41
29
|
{},
|
|
42
30
|
{ group: :end },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Trailblazer
|
|
2
|
-
class Activity
|
|
3
|
-
# Maintain Builder
|
|
2
|
+
class Activity::Magnetic::Builder
|
|
3
|
+
# Maintain Builder instance plus Adds/Process/Outputs as immutable objects.
|
|
4
4
|
module State
|
|
5
5
|
def self.build(builder_class, normalizer, builder_options)
|
|
6
6
|
builder, adds = builder_class.for(normalizer, builder_options) # e.g. Path.for(...) which creates a Builder::Path instance.
|
|
@@ -8,8 +8,8 @@ module Trailblazer
|
|
|
8
8
|
recompile(builder.freeze, adds.freeze)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def self.add(builder, adds,
|
|
12
|
-
new_adds, *returned_options = builder.insert(
|
|
11
|
+
def self.add(builder, adds, strategy, polarizer, *args, &block)
|
|
12
|
+
new_adds, *returned_options = builder.insert(strategy, polarizer, *args, &block) # TODO: move that out of here.
|
|
13
13
|
|
|
14
14
|
adds = adds + new_adds
|
|
15
15
|
|
|
@@ -34,7 +34,7 @@ module Trailblazer
|
|
|
34
34
|
#
|
|
35
35
|
# @return [Process, Hash] The {Process} instance and its outputs hash.
|
|
36
36
|
def self.call(adds)
|
|
37
|
-
circuit, end_events =
|
|
37
|
+
circuit, end_events = Finalizer.(adds)
|
|
38
38
|
outputs = recompile_outputs(end_events)
|
|
39
39
|
|
|
40
40
|
return circuit, outputs
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Trailblazer::Activity < Module
|
|
2
|
+
module Magnetic
|
|
3
|
+
module Merge
|
|
4
|
+
def merge!(merged)
|
|
5
|
+
merged[:record].each do |key, args|
|
|
6
|
+
dsl_method, *args = args
|
|
7
|
+
|
|
8
|
+
return send( dsl_method, args[0], args[1], &args[2] ) if args[2]
|
|
9
|
+
send( dsl_method, args[0], args[1] )
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
self
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
module Trailblazer
|
|
2
2
|
module Activity::Magnetic
|
|
3
3
|
module DSL
|
|
4
|
-
class Polarization
|
|
5
|
-
def initialize( output:raise, color:raise )
|
|
6
|
-
@output, @color = output, color
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def call(magnetic_to, plus_poles, options)
|
|
10
|
-
[
|
|
11
|
-
magnetic_to,
|
|
12
|
-
plus_poles.merge( @output => @color ) # this usually adds a new Output to the task.
|
|
13
|
-
]
|
|
14
|
-
end
|
|
15
|
-
end # Polarization
|
|
16
|
-
|
|
17
4
|
# This module only processes additional "wiring" options from the DSL calls
|
|
18
5
|
# Output(:success) => End("my.new")
|
|
19
6
|
#
|
|
@@ -41,22 +28,16 @@ module Trailblazer
|
|
|
41
28
|
end
|
|
42
29
|
|
|
43
30
|
def process_tuple(id, output, task, plus_poles, &block)
|
|
44
|
-
output = output_for(output, plus_poles) if output.kind_of?(DSL::
|
|
31
|
+
output = output_for(output, plus_poles) if output.kind_of?(Activity::DSL::OutputSemantic)
|
|
45
32
|
|
|
46
33
|
if task.kind_of?(Activity::End)
|
|
34
|
+
# raise %{An end event with semantic `#{task.to_h[:semantic]}` has already been added. Please use an ID reference: `=> "End.#{task.to_h[:semantic]}"`} if
|
|
47
35
|
new_edge = "#{id}-#{output.signal}"
|
|
48
36
|
|
|
49
37
|
[
|
|
50
38
|
Polarization.new( output: output, color: new_edge ),
|
|
51
39
|
[ [:add, [task.to_h[:semantic], [ [new_edge], task, [] ], group: :end]] ]
|
|
52
40
|
]
|
|
53
|
-
elsif task.is_a?(String) # let's say this means an existing step
|
|
54
|
-
new_edge = "#{id}-#{output.signal}-#{task}"
|
|
55
|
-
|
|
56
|
-
[
|
|
57
|
-
Polarization.new( output: output, color: new_edge ),
|
|
58
|
-
[[ :magnetic_to, [ task, [new_edge] ] ]],
|
|
59
|
-
]
|
|
60
41
|
# procs come from DSL calls such as `Path() do ... end`.
|
|
61
42
|
elsif task.is_a?(Proc)
|
|
62
43
|
start_color, activity = task.(block)
|
|
@@ -69,9 +50,16 @@ module Trailblazer
|
|
|
69
50
|
# TODO: we also need to merge all the other states such as debug.
|
|
70
51
|
adds[1..-1] # drop start
|
|
71
52
|
]
|
|
72
|
-
|
|
53
|
+
elsif task.is_a?(Activity::DSL::Track) # An additional plus polarization. Example: Output => :success
|
|
54
|
+
[
|
|
55
|
+
Polarization.new( output: output, color: task.color )
|
|
56
|
+
]
|
|
57
|
+
else # ID: existing step
|
|
58
|
+
new_edge = "#{id}-#{output.signal}-#{task}"
|
|
59
|
+
|
|
73
60
|
[
|
|
74
|
-
Polarization.new( output: output, color:
|
|
61
|
+
Polarization.new( output: output, color: new_edge ),
|
|
62
|
+
[[ :magnetic_to, [ task, [new_edge] ] ]],
|
|
75
63
|
]
|
|
76
64
|
end
|
|
77
65
|
end
|
|
@@ -83,11 +71,6 @@ module Trailblazer
|
|
|
83
71
|
output or raise("Couldn't find existing output for `#{semantic.value.inspect}`.")
|
|
84
72
|
end
|
|
85
73
|
end # OptionsProcessing
|
|
86
|
-
|
|
87
|
-
# DSL datastructures
|
|
88
|
-
module Output
|
|
89
|
-
Semantic = Struct.new(:value)
|
|
90
|
-
end
|
|
91
74
|
end # DSL
|
|
92
75
|
end
|
|
93
76
|
end
|
|
File without changes
|
|
@@ -73,20 +73,13 @@ module Trailblazer
|
|
|
73
73
|
@plus_poles.values.collect { |output, color| PlusPole.new(output, color) }
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# Builds PlusPoles from { semantic => Output }, which, surprisingly, is exactly what Activity::outputs looks like.
|
|
77
|
-
# The plus pole's color is set to the output's semantic.
|
|
78
|
-
def self.from_outputs(outputs)
|
|
79
|
-
ary = outputs.collect { |semantic, output| [ output, semantic ] }
|
|
80
|
-
|
|
81
|
-
new.merge(::Hash[ary])
|
|
82
|
-
end
|
|
83
|
-
|
|
84
76
|
# FIXME: should this be a hash or whatever?
|
|
85
77
|
#
|
|
86
|
-
# @return Hash All {Output}s mapped to their semantic: `{ Output(Right, :success) => :success }`
|
|
78
|
+
# @return Hash All {Output}s mapped to their (guessed) semantic: `{ Output(Right, :success) => :success }`
|
|
87
79
|
def self.initial(outputs)
|
|
88
80
|
new.merge(Hash[ outputs.collect { |semantic, output| [output, semantic] } ])
|
|
89
81
|
end
|
|
90
82
|
end
|
|
91
83
|
end
|
|
92
84
|
end
|
|
85
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Trailblazer
|
|
2
|
+
module Activity::Magnetic
|
|
3
|
+
module DSL
|
|
4
|
+
# Every DSL method creates a set of polarizations that are evaluated and decide about a task's
|
|
5
|
+
# incoming and outgoing connections.
|
|
6
|
+
#
|
|
7
|
+
# @note The API of Polarization might be simplified soon.
|
|
8
|
+
# @api private
|
|
9
|
+
class Polarization
|
|
10
|
+
def initialize( output:raise, color:raise )
|
|
11
|
+
@output, @color = output, color
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def call(magnetic_to, plus_poles, options)
|
|
15
|
+
[
|
|
16
|
+
magnetic_to,
|
|
17
|
+
plus_poles.merge( @output => @color ) # this usually adds a new Output to the task.
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
end # Polarization
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Trailblazer
|
|
2
|
+
class Activity < Module
|
|
3
|
+
module DSL
|
|
4
|
+
# {:extension API}
|
|
5
|
+
# Record each DSL call (like #step) on the activity.
|
|
6
|
+
def self.record(activity, *args, original_dsl_args:)
|
|
7
|
+
activity[:record, original_dsl_args[1]] = original_dsl_args
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
File without changes
|
|
File without changes
|
|
@@ -24,7 +24,7 @@ class Trailblazer::Activity < Module
|
|
|
24
24
|
|
|
25
25
|
# @api private
|
|
26
26
|
def self.build_state(normalizer, builder_class:, builder_options: {}, **options)
|
|
27
|
-
builder, adds, circuit, outputs = State.build(builder_class, normalizer, options.merge(builder_options))
|
|
27
|
+
builder, adds, circuit, outputs = Magnetic::Builder::State.build(builder_class, normalizer, options.merge(builder_options))
|
|
28
28
|
|
|
29
29
|
return builder, adds, circuit, outputs, options
|
|
30
30
|
end
|
|
@@ -8,6 +8,11 @@ class Trailblazer::Activity < Module
|
|
|
8
8
|
def self.config
|
|
9
9
|
Railway.config.merge(
|
|
10
10
|
builder_class: Magnetic::Builder::FastTrack,
|
|
11
|
+
extend: [
|
|
12
|
+
DSL.def_dsl(:step, Magnetic::Builder::FastTrack, :StepPolarizations),
|
|
13
|
+
DSL.def_dsl(:fail, Magnetic::Builder::FastTrack, :FailPolarizations),
|
|
14
|
+
DSL.def_dsl(:pass, Magnetic::Builder::FastTrack, :PassPolarizations)
|
|
15
|
+
],
|
|
11
16
|
)
|
|
12
17
|
end
|
|
13
18
|
end
|
|
@@ -14,7 +14,11 @@ module Trailblazer
|
|
|
14
14
|
default_outputs: Magnetic::Builder::Path.default_outputs,
|
|
15
15
|
extension: [ Introspect.method(:add_introspection) ],
|
|
16
16
|
|
|
17
|
-
extend: [
|
|
17
|
+
extend: [
|
|
18
|
+
DSL.def_dsl(:task, Magnetic::Builder::Path, :TaskPolarizations),
|
|
19
|
+
DSL.def_dsl(:_end, Magnetic::Builder::Path, :EndEventPolarizations),
|
|
20
|
+
DSL.def_dsl(:pass, Magnetic::Builder::Railway, :PassPolarizations),
|
|
21
|
+
],
|
|
18
22
|
}
|
|
19
23
|
end
|
|
20
24
|
end # Path
|
|
File without changes
|
|
@@ -10,7 +10,11 @@ module Trailblazer
|
|
|
10
10
|
Path.config.merge(
|
|
11
11
|
builder_class: Magnetic::Builder::Railway,
|
|
12
12
|
default_outputs: Magnetic::Builder::Railway.default_outputs,
|
|
13
|
-
extend: [
|
|
13
|
+
extend: [
|
|
14
|
+
DSL.def_dsl(:step, Magnetic::Builder::Railway, :StepPolarizations),
|
|
15
|
+
DSL.def_dsl(:fail, Magnetic::Builder::Railway, :FailPolarizations),
|
|
16
|
+
DSL.def_dsl(:pass, Magnetic::Builder::Railway, :PassPolarizations)
|
|
17
|
+
],
|
|
14
18
|
)
|
|
15
19
|
end
|
|
16
20
|
end
|
|
File without changes
|
|
@@ -37,7 +37,9 @@ module Trailblazer
|
|
|
37
37
|
|
|
38
38
|
def self.inspect_task_builder(task)
|
|
39
39
|
proc = task.instance_variable_get(:@user_proc)
|
|
40
|
-
|
|
40
|
+
match = proc.inspect.match(/(\w+)>$/)
|
|
41
|
+
|
|
42
|
+
%{#<TaskBuilder{.#{match[1]}}>}
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
# FIXME: clean up that shit below.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module Trailblazer
|
|
2
|
-
class Activity < Module
|
|
2
|
+
class Activity < Module
|
|
3
|
+
# Generic run-time structures that are built via the DSL.
|
|
4
|
+
|
|
3
5
|
# Builds an {Activity::End} instance.
|
|
4
6
|
def self.End(semantic)
|
|
5
7
|
End.new(semantic: semantic)
|
|
@@ -24,12 +26,11 @@
|
|
|
24
26
|
@options
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
def inspect
|
|
28
|
-
to_s
|
|
29
|
-
end
|
|
30
29
|
def to_s
|
|
31
30
|
%{#<#{self.class.name} #{@options.collect{ |k,v| "#{k}=#{v.inspect}" }.join(" ")}>}
|
|
32
31
|
end
|
|
32
|
+
|
|
33
|
+
alias_method :inspect, :to_s
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
class Start < 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.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hirb
|
|
@@ -109,7 +109,6 @@ files:
|
|
|
109
109
|
- CHANGES.md
|
|
110
110
|
- Gemfile
|
|
111
111
|
- NOTES
|
|
112
|
-
- NOTES_
|
|
113
112
|
- README.md
|
|
114
113
|
- Rakefile
|
|
115
114
|
- inspeccccccccct.rb
|
|
@@ -118,32 +117,33 @@ files:
|
|
|
118
117
|
- lib/trailblazer/activity/config.rb
|
|
119
118
|
- lib/trailblazer/activity/dsl/add_task.rb
|
|
120
119
|
- lib/trailblazer/activity/dsl/helper.rb
|
|
121
|
-
- lib/trailblazer/activity/
|
|
122
|
-
- lib/trailblazer/activity/
|
|
123
|
-
- lib/trailblazer/activity/
|
|
124
|
-
- lib/trailblazer/activity/
|
|
125
|
-
- lib/trailblazer/activity/
|
|
126
|
-
- lib/trailblazer/activity/
|
|
120
|
+
- lib/trailblazer/activity/dsl/magnetic.rb
|
|
121
|
+
- lib/trailblazer/activity/dsl/magnetic/builder.rb
|
|
122
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/default_normalizer.rb
|
|
123
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/fast_track.rb
|
|
124
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/normalizer.rb
|
|
125
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/path.rb
|
|
126
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/railway.rb
|
|
127
|
+
- lib/trailblazer/activity/dsl/magnetic/builder/state.rb
|
|
128
|
+
- lib/trailblazer/activity/dsl/magnetic/finalizer.rb
|
|
129
|
+
- lib/trailblazer/activity/dsl/magnetic/generate.rb
|
|
130
|
+
- lib/trailblazer/activity/dsl/magnetic/merge.rb
|
|
131
|
+
- lib/trailblazer/activity/dsl/magnetic/process_options.rb
|
|
132
|
+
- lib/trailblazer/activity/dsl/magnetic/structure/alterations.rb
|
|
133
|
+
- lib/trailblazer/activity/dsl/magnetic/structure/plus_poles.rb
|
|
134
|
+
- lib/trailblazer/activity/dsl/magnetic/structure/polarization.rb
|
|
135
|
+
- lib/trailblazer/activity/dsl/record.rb
|
|
136
|
+
- lib/trailblazer/activity/dsl/schema/dependencies.rb
|
|
137
|
+
- lib/trailblazer/activity/dsl/schema/sequence.rb
|
|
138
|
+
- lib/trailblazer/activity/dsl/strategy/build_state.rb
|
|
139
|
+
- lib/trailblazer/activity/dsl/strategy/fast_track.rb
|
|
140
|
+
- lib/trailblazer/activity/dsl/strategy/path.rb
|
|
141
|
+
- lib/trailblazer/activity/dsl/strategy/plan.rb
|
|
142
|
+
- lib/trailblazer/activity/dsl/strategy/railway.rb
|
|
143
|
+
- lib/trailblazer/activity/interface.rb
|
|
127
144
|
- lib/trailblazer/activity/introspect.rb
|
|
128
|
-
- lib/trailblazer/activity/magnetic.rb
|
|
129
|
-
- lib/trailblazer/activity/magnetic/builder.rb
|
|
130
|
-
- lib/trailblazer/activity/magnetic/builder/default_normalizer.rb
|
|
131
|
-
- lib/trailblazer/activity/magnetic/builder/fast_track.rb
|
|
132
|
-
- lib/trailblazer/activity/magnetic/builder/normalizer.rb
|
|
133
|
-
- lib/trailblazer/activity/magnetic/builder/path.rb
|
|
134
|
-
- lib/trailblazer/activity/magnetic/builder/railway.rb
|
|
135
|
-
- lib/trailblazer/activity/magnetic/dsl.rb
|
|
136
|
-
- lib/trailblazer/activity/magnetic/finalizer.rb
|
|
137
|
-
- lib/trailblazer/activity/magnetic/generate.rb
|
|
138
|
-
- lib/trailblazer/activity/magnetic/merge.rb
|
|
139
|
-
- lib/trailblazer/activity/magnetic/structure/alterations.rb
|
|
140
|
-
- lib/trailblazer/activity/magnetic/structure/plus_poles.rb
|
|
141
145
|
- lib/trailblazer/activity/present.rb
|
|
142
|
-
- lib/trailblazer/activity/schema/dependencies.rb
|
|
143
|
-
- lib/trailblazer/activity/schema/sequence.rb
|
|
144
|
-
- lib/trailblazer/activity/state.rb
|
|
145
146
|
- lib/trailblazer/activity/structures.rb
|
|
146
|
-
- lib/trailblazer/activity/subprocess.rb
|
|
147
147
|
- lib/trailblazer/activity/task_builder.rb
|
|
148
148
|
- lib/trailblazer/activity/task_wrap.rb
|
|
149
149
|
- lib/trailblazer/activity/task_wrap/call_task.rb
|
data/NOTES_
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# NOT lowest level. if you need that, use your own proc.
|
|
2
|
-
# TODO: how do we track what goes into the callable?
|
|
3
|
-
# adjust what goes into it (e.g. without direction or with kw args)?
|
|
4
|
-
# pre contract -> step -> post contract (are these all just steps, in "mini nested pipe"?)
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# aka "Atom".
|
|
8
|
-
def self.Task(instance: :context, method: :call, id:nil)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# * ingoing contract (could be implemented as a nested pipe with 3 steps. that would allow us
|
|
12
|
-
# to compile it to native ruby method calls later)
|
|
13
|
-
->(direction, options, **flow_options) {
|
|
14
|
-
instance = flow_options[:context] if instance==:context # TODO; implement different :context (e.g. :my_context).
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# * incoming args
|
|
19
|
-
# step_args = [args] # TODO: overridable.
|
|
20
|
-
step_args = [ options, **options ]
|
|
21
|
-
|
|
22
|
-
# ** call the actual thing
|
|
23
|
-
res = instance.send(method, *step_args) # what goes in? kws?
|
|
24
|
-
|
|
25
|
-
# * interpret result (e.g. true=>Right) (should we keep doing that in the tie? so the op has it easier with success, etc?)
|
|
26
|
-
# * outgoing contract
|
|
27
|
-
# * outgoing args
|
|
28
|
-
|
|
29
|
-
[ *res, flow_options ]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# * tracing: incoming, outgoing, direction, etc. - do we want that in tasks, too?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
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/magnetic/dsl"
|
|
19
|
-
require "trailblazer/activity/magnetic/structure/plus_poles"
|
|
20
|
-
require "trailblazer/activity/magnetic/structure/alterations"
|
|
21
|
-
|
|
22
|
-
require "trailblazer/activity/schema/dependencies"
|
|
23
|
-
|
|
24
|
-
require "trailblazer/activity/magnetic"
|
|
25
|
-
require "trailblazer/activity/magnetic/builder"
|
|
26
|
-
# require "trailblazer/activity/magnetic/builder/dsl_helper"
|
|
27
|
-
# require "trailblazer/activity/magnetic/dsl_helper"
|
|
28
|
-
|
|
29
|
-
require "trailblazer/option"
|
|
30
|
-
require "trailblazer/activity/task_builder"
|
|
31
|
-
require "trailblazer/activity/magnetic/builder/default_normalizer"
|
|
32
|
-
require "trailblazer/activity/magnetic/builder/path"
|
|
33
|
-
require "trailblazer/activity/magnetic/builder/railway"
|
|
34
|
-
require "trailblazer/activity/magnetic/builder/fast_track" # TODO: move to Operation gem.
|
|
35
|
-
|
|
36
|
-
require "trailblazer/activity/magnetic/generate"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
class Trailblazer::Activity < Module
|
|
2
|
-
module Magnetic
|
|
3
|
-
module Merge
|
|
4
|
-
# THIS IS HIGHLY EXPERIMENTAL AS WE'RE NOT MERGING taskWrap etc.
|
|
5
|
-
def merge!(merged)
|
|
6
|
-
merged_adds = Builder.merge(self[:adds], merged[:adds])
|
|
7
|
-
# TODO: MERGE DEBUG, TASK_WRAP
|
|
8
|
-
builder, adds, circuit, outputs, = State.recompile(self[:builder], merged_adds)
|
|
9
|
-
|
|
10
|
-
self[:adds] = adds
|
|
11
|
-
self[:circuit] = circuit
|
|
12
|
-
self[:outputs] = outputs
|
|
13
|
-
|
|
14
|
-
self
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module Trailblazer
|
|
2
|
-
class Activity < Module # A {Subprocess} is an instance of an abstract {Activity} that can be `call`ed.
|
|
3
|
-
# It is the runtime instance that runs from a specific start event.
|
|
4
|
-
def self.Subprocess(*args)
|
|
5
|
-
Subprocess.new(*args)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# Subprocess allows to have tasks with a different call interface and start event.
|
|
9
|
-
# @param activity any object with an {Activity interface}
|
|
10
|
-
class Subprocess
|
|
11
|
-
include Interface
|
|
12
|
-
|
|
13
|
-
def initialize(activity, call: :call, **options)
|
|
14
|
-
@activity = activity
|
|
15
|
-
@options = options
|
|
16
|
-
@call = call
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def call(args, **circuit_options)
|
|
20
|
-
@activity.public_send(@call, args, circuit_options.merge(@options))
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# @private
|
|
24
|
-
def to_h
|
|
25
|
-
@activity.to_h # TODO: test explicitly
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def debug
|
|
29
|
-
@activity.debug
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def to_s
|
|
33
|
-
%{#<Trailblazer::Activity::Subprocess activity=#{@activity}>}
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# circuit.( args, runner: Runner, start_at: raise, **circuit_flow_options )
|
|
40
|
-
|
|
41
|
-
# subprocess.( options, flow_options, *args, start_event:<Event>, last_signal: signal )
|