trailblazer-activity 0.6.2 → 0.7.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/CHANGES.md +4 -0
- data/lib/trailblazer/activity.rb +1 -1
- data/lib/trailblazer/activity/dsl/helper.rb +32 -34
- data/lib/trailblazer/activity/dsl/magnetic/builder.rb +1 -1
- data/lib/trailblazer/activity/task_wrap/variable_mapping.rb +20 -13
- data/lib/trailblazer/activity/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be148af716c8a5bd21b666b22bf75bf2210854b4c710cfa69a26505b1725710d
|
|
4
|
+
data.tar.gz: 39f836d460d3dae33f9905103b4f6efdd57049ebdc9290ed21e441cefd0cb9dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1dc6d49f7436922ea378c4af9604242dec98ff08aa29d5c2f156b7569cbf2e2704380f6050a659dec7d9f28471d3194b3c2c4bd61ef4dfecf3657d1e6a98dfbc
|
|
7
|
+
data.tar.gz: 8b214a0952c72650665bd2413254d526bbab9fce4920b3b2fa25aced774994ca49a96bed66ef1ef4d6adc09c63d78ef604abef94205d1ee5edb09bcd544d66fe
|
data/CHANGES.md
CHANGED
data/lib/trailblazer/activity.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Trailblazer
|
|
|
38
38
|
module DSLHelper
|
|
39
39
|
extend Forwardable
|
|
40
40
|
def_delegators :@builder, :Path
|
|
41
|
-
def_delegators DSL
|
|
41
|
+
def_delegators DSL, :Output, :End, :Subprocess, :Track
|
|
42
42
|
|
|
43
43
|
def Path(*args, &block)
|
|
44
44
|
self[:builder].Path(*args, &block)
|
|
@@ -22,49 +22,47 @@ module Trailblazer
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# Shortcut functions for the DSL. These have no state.
|
|
25
|
-
|
|
26
|
-
module_function
|
|
25
|
+
module_function
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
# Output( Left, :failure )
|
|
28
|
+
# Output( :failure ) #=> Output::Semantic
|
|
29
|
+
def Output(signal, semantic=nil)
|
|
30
|
+
return OutputSemantic.new(signal) if semantic.nil?
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
Activity.Output(signal, semantic)
|
|
33
|
+
end
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
def End(semantic)
|
|
36
|
+
Activity.End(semantic)
|
|
37
|
+
end
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
def Track(color)
|
|
40
|
+
Track.new(color).freeze
|
|
41
|
+
end
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
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)
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
# this block is called in DSL::ProcessTuples. This could be improved somehow.
|
|
53
|
+
->(block) {
|
|
54
|
+
path.instance_exec(&block)
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
[ track_color, path ]
|
|
57
|
+
}
|
|
58
|
+
end
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
60
|
+
# Computes the :outputs options for {activity}
|
|
61
|
+
def Subprocess(activity)
|
|
62
|
+
{
|
|
63
|
+
task: activity,
|
|
64
|
+
outputs: activity.outputs
|
|
65
|
+
}
|
|
68
66
|
end
|
|
69
67
|
end
|
|
70
68
|
end
|
|
@@ -19,6 +19,20 @@ class Trailblazer::Activity < Module
|
|
|
19
19
|
ctx[:options] = options # without :input and :output
|
|
20
20
|
ctx[:options] = options.merge(Trailblazer::Activity::TaskWrap::VariableMapping(io_config) => true)
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
# The taskWrap extension that's included into the static taskWrap for a task.
|
|
24
|
+
def self.extension_for(input, output)
|
|
25
|
+
Trailblazer::Activity::DSL::Extension.new(
|
|
26
|
+
Merge.new(
|
|
27
|
+
Module.new do
|
|
28
|
+
extend Path::Plan()
|
|
29
|
+
|
|
30
|
+
task input, id: "task_wrap.input", before: "task_wrap.call_task"
|
|
31
|
+
task output, id: "task_wrap.output", before: "End.success", group: :end
|
|
32
|
+
end
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
end
|
|
22
36
|
end
|
|
23
37
|
|
|
24
38
|
# @private
|
|
@@ -30,6 +44,7 @@ class Trailblazer::Activity < Module
|
|
|
30
44
|
end
|
|
31
45
|
end
|
|
32
46
|
|
|
47
|
+
|
|
33
48
|
# Returns an Extension instance to be thrown into the `step` DSL arguments.
|
|
34
49
|
def self.VariableMapping(input:, output:)
|
|
35
50
|
input = Input.new(
|
|
@@ -40,16 +55,7 @@ class Trailblazer::Activity < Module
|
|
|
40
55
|
Output::Unscoped.new(
|
|
41
56
|
Trailblazer::Option::KW( filter_for(output) ) ) )
|
|
42
57
|
|
|
43
|
-
|
|
44
|
-
Merge.new(
|
|
45
|
-
Module.new do
|
|
46
|
-
extend Path::Plan()
|
|
47
|
-
|
|
48
|
-
task input, id: "task_wrap.input", before: "task_wrap.call_task"
|
|
49
|
-
task output, id: "task_wrap.output", before: "End.success", group: :end
|
|
50
|
-
end
|
|
51
|
-
)
|
|
52
|
-
)
|
|
58
|
+
VariableMapping.extension_for(input, output)
|
|
53
59
|
end
|
|
54
60
|
|
|
55
61
|
# TaskWrap step to compute the incoming {Context} for the wrapped task.
|
|
@@ -58,6 +64,8 @@ class Trailblazer::Activity < Module
|
|
|
58
64
|
# Both Input and Output are typically to be added before and after task_wrap.call_task.
|
|
59
65
|
#
|
|
60
66
|
# @note Assumption: we always have :input _and_ :output, where :input produces a Context and :output decomposes it.
|
|
67
|
+
|
|
68
|
+
# Calls your {@filter} and replaces the original ctx with your returned one.
|
|
61
69
|
class Input
|
|
62
70
|
def initialize(filter)
|
|
63
71
|
@filter = filter
|
|
@@ -67,7 +75,7 @@ class Trailblazer::Activity < Module
|
|
|
67
75
|
#
|
|
68
76
|
def call( (wrap_ctx, original_args), circuit_options )
|
|
69
77
|
# let user compute new ctx for the wrapped task.
|
|
70
|
-
input_ctx = apply_filter(*original_args)
|
|
78
|
+
input_ctx = apply_filter(*original_args)
|
|
71
79
|
|
|
72
80
|
wrap_ctx = wrap_ctx.merge( vm_original_ctx: original_args[0][0] ) # remember the original ctx
|
|
73
81
|
|
|
@@ -119,13 +127,12 @@ class Trailblazer::Activity < Module
|
|
|
119
127
|
@filter = filter
|
|
120
128
|
end
|
|
121
129
|
|
|
122
|
-
# Runs
|
|
130
|
+
# Runs your filter and replaces the ctx in `wrap_ctx[:return_args]` with the filtered one.
|
|
123
131
|
def call( (wrap_ctx, original_args), **circuit_options )
|
|
124
132
|
(original_ctx, original_flow_options), original_circuit_options = original_args
|
|
125
133
|
|
|
126
134
|
returned_ctx, _ = wrap_ctx[:return_args] # this is the Context returned from `call`ing the task.
|
|
127
135
|
original_ctx = wrap_ctx[:vm_original_ctx]
|
|
128
|
-
|
|
129
136
|
# let user compute the output.
|
|
130
137
|
output_ctx = @filter.(original_ctx, returned_ctx, **original_circuit_options)
|
|
131
138
|
|
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.7.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-05-
|
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hirb
|