trailblazer-activity-dsl-linear 0.2.9 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +22 -0
- data/lib/trailblazer/activity/dsl/linear/helper.rb +28 -25
- data/lib/trailblazer/activity/dsl/linear/normalizer.rb +17 -12
- data/lib/trailblazer/activity/dsl/linear/strategy.rb +1 -1
- data/lib/trailblazer/activity/dsl/linear/variable_mapping.rb +2 -2
- data/lib/trailblazer/activity/dsl/linear/version.rb +1 -1
- data/lib/trailblazer/activity/fast_track.rb +10 -0
- data/trailblazer-activity-dsl-linear.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f64e4cda0443bb3635a41f04a79ea5f12193ace7aac22d613eb3ce0749d3d303
|
4
|
+
data.tar.gz: ade9350dfbf4475edb0a67190d4e9cd37cbca8f838b27c63c5be21780b9d466d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ad5a07613723c38ec2a29100b33a4b983451eca8d34884da03b6a98a3441709aa8e2f4c05d7717aebcbe3b6d47b3f3a07b389469396bea8cb6befd24ea1c1b
|
7
|
+
data.tar.gz: 1ac0b62f981d089cec84331ccb524b20f2f7aca089ed8e944ce422de126646176f0e66752a878d124cdf828d6261fd2d52e2e9ec63c2ade7eba658fa4bb9f3da
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# 0.3.4
|
2
|
+
|
3
|
+
* Allow DSL helpers such as `End()` in `Path()`.
|
4
|
+
* Introduce `Path(..., before: )` option to insert all path member steps before a certain element.
|
5
|
+
* Allow `Path(..., connect_to: Track(..))`.
|
6
|
+
|
7
|
+
# 0.3.3
|
8
|
+
|
9
|
+
* Fix for registering `PassFast` & `FailFast` ends in `FastTrack` to fix circuit interface callables which emits those signals.
|
10
|
+
|
11
|
+
# 0.3.2
|
12
|
+
|
13
|
+
* Updrading `trailblazer-activity` version to utilise new `trailblazer-context` :drum:
|
14
|
+
|
15
|
+
# 0.3.1
|
16
|
+
|
17
|
+
* Fixes in circuit interface normalization when given task is a {Symbol}, consider additional {task} options (like {id}) and assign {task} symbol as an {id}.
|
18
|
+
|
19
|
+
# 0.3.0
|
20
|
+
|
21
|
+
* Fix circuit interface callable to make `step task: :instance_method` use circuit signature.
|
22
|
+
|
1
23
|
# 0.2.9
|
2
24
|
|
3
25
|
* The `Path()` helper, when used with `:end_task` will now automatically _append_ the end task (or terminus) to `End.success`.
|
@@ -43,33 +43,16 @@ module Trailblazer
|
|
43
43
|
Id.new(id).freeze
|
44
44
|
end
|
45
45
|
|
46
|
-
def Path(track_color: "track_#{rand}",
|
47
|
-
|
48
|
-
|
46
|
+
def Path(track_color: "track_#{rand}", connect_to: nil, before: false, **options, &block)
|
47
|
+
path = Activity::Path(track_name: track_color, **options)
|
48
|
+
activity = Class.new(path) { self.instance_exec(&block) }
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
seq = state.to_h[:sequence]
|
54
|
-
|
55
|
-
_end_id =
|
56
|
-
if connect_to
|
57
|
-
end_id
|
58
|
-
else
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
|
62
|
-
seq = strip_start_and_ends(seq, end_id: _end_id) # don't cut off end unless {:connect_to} is set.
|
50
|
+
seq = activity.instance_variable_get(:@state).to_h[:sequence] # TODO: fix @state interface
|
51
|
+
# Strip default ends `Start.default` and `End.success` (if present).
|
52
|
+
seq = seq[1..-1].reject{ |row| row[3][:stop_event] && row[3][:id] == 'End.success' }
|
63
53
|
|
64
54
|
if connect_to
|
65
|
-
|
66
|
-
|
67
|
-
searches = [Search.ById(output, connect_to.value)]
|
68
|
-
|
69
|
-
row = seq[-1]
|
70
|
-
row = row[0..1] + [searches] + [row[3]] # FIXME: not mutating an array is so hard: we only want to replace the "searches" element, index 2
|
71
|
-
|
72
|
-
seq = seq[0..-2] + [row]
|
55
|
+
seq = connect_for_sequence(seq, connect_to: connect_to)
|
73
56
|
end
|
74
57
|
|
75
58
|
# Add the path elements before {End.success}.
|
@@ -80,9 +63,12 @@ module Trailblazer
|
|
80
63
|
# the terminus of the path goes _after_ {End.success} into the "end group".
|
81
64
|
insert_method = options[:stop_event] ? Insert.method(:Append) : Insert.method(:Prepend)
|
82
65
|
|
66
|
+
insert_target = "End.success" # insert before/after
|
67
|
+
insert_target = before if before && connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Track) # FIXME: this is a bit hacky, of course!
|
68
|
+
|
83
69
|
{
|
84
70
|
row: row,
|
85
|
-
insert: [insert_method,
|
71
|
+
insert: [insert_method, insert_target]
|
86
72
|
}
|
87
73
|
end
|
88
74
|
|
@@ -90,6 +76,23 @@ module Trailblazer
|
|
90
76
|
return Track.new(track_color, adds, {})
|
91
77
|
end
|
92
78
|
|
79
|
+
# Connect last row of the {sequence} to the given step via its {Id}
|
80
|
+
# Useful when steps needs to be inserted in between {Start} and {connect Id()}.
|
81
|
+
private def connect_for_sequence(sequence, connect_to:)
|
82
|
+
output, _ = sequence[-1][2][0].(sequence, sequence[-1]) # FIXME: the Forward() proc contains the row's Output, and the only current way to retrieve it is calling the search strategy. It should be Forward#to_h
|
83
|
+
|
84
|
+
# searches = [Search.ById(output, connect_to.value)]
|
85
|
+
searches = [Search.ById(output, connect_to.value)] if connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Id)
|
86
|
+
searches = [Search.Forward(output, connect_to.color)] if connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Track) # FIXME: use existing mapping logic!
|
87
|
+
|
88
|
+
row = sequence[-1]
|
89
|
+
row = row[0..1] + [searches] + [row[3]] # FIXME: not mutating an array is so hard: we only want to replace the "searches" element, index 2
|
90
|
+
|
91
|
+
sequence = sequence[0..-2] + [row]
|
92
|
+
|
93
|
+
sequence
|
94
|
+
end
|
95
|
+
|
93
96
|
# Computes the {:outputs} options for {activity}.
|
94
97
|
def Subprocess(activity, patch: {})
|
95
98
|
activity = Patch.customize(activity, options: patch)
|
@@ -54,22 +54,27 @@ module Trailblazer
|
|
54
54
|
# Specific to the "step DSL": if the first argument is a callable, wrap it in a {step_interface_builder}
|
55
55
|
# since its interface expects the step interface, but the circuit will call it with circuit interface.
|
56
56
|
def normalize_step_interface((ctx, flow_options), *)
|
57
|
-
options = case
|
57
|
+
options = case ctx[:options]
|
58
58
|
when Hash
|
59
|
-
#
|
60
|
-
|
59
|
+
# Circuit Interface
|
60
|
+
task = ctx[:options].fetch(:task)
|
61
|
+
id = ctx[:options][:id]
|
62
|
+
|
63
|
+
if task.is_a?(Symbol)
|
64
|
+
# step task: :find, id: :load
|
65
|
+
{ **ctx[:options], id: (id || task), task: Trailblazer::Option( task ) }
|
66
|
+
else
|
67
|
+
# step task: Callable, ... (Subprocess, Proc, macros etc)
|
68
|
+
ctx[:options] # NOOP
|
69
|
+
end
|
61
70
|
else
|
62
|
-
|
71
|
+
# Step Interface
|
72
|
+
# step :find, ...
|
73
|
+
# step Callable, ... (Method, Proc etc)
|
74
|
+
{ task: ctx[:options], wrap_task: true }
|
63
75
|
end
|
64
76
|
|
65
|
-
|
66
|
-
# task = wrap_with_step_interface(task: options, step_interface_builder: ctx[:user_options][:step_interface_builder]) # TODO: make this optional with appropriate wiring.
|
67
|
-
task = options
|
68
|
-
|
69
|
-
ctx = ctx.merge(options: {task: task, wrap_task: true})
|
70
|
-
end
|
71
|
-
|
72
|
-
return Trailblazer::Activity::Right, [ctx, flow_options]
|
77
|
+
return Trailblazer::Activity::Right, [ctx.merge(options: options), flow_options]
|
73
78
|
end
|
74
79
|
|
75
80
|
def wrap_task_with_step_interface((ctx, flow_options), **)
|
@@ -74,7 +74,7 @@ module Trailblazer
|
|
74
74
|
return args[0], options.merge(evaluated_options)
|
75
75
|
end
|
76
76
|
|
77
|
-
def Path(options, &block) # syntactically, we can't access the {do ... end} block here.
|
77
|
+
def Path(**options, &block) # syntactically, we can't access the {do ... end} block here.
|
78
78
|
BlockProxy.new(options, block)
|
79
79
|
end
|
80
80
|
|
@@ -68,10 +68,10 @@ module Trailblazer
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def call((original_ctx, flow_options), **circuit_options)
|
71
|
-
Trailblazer::Context
|
71
|
+
Trailblazer::Context(
|
72
72
|
@filter.(original_ctx, **circuit_options),
|
73
73
|
{},
|
74
|
-
[
|
74
|
+
flow_options[:context_options]
|
75
75
|
)
|
76
76
|
end
|
77
77
|
end
|
@@ -63,6 +63,11 @@ module Trailblazer
|
|
63
63
|
def pass_fast_option((ctx, flow_options), *)
|
64
64
|
ctx = merge_connections_for(ctx, ctx, :pass_fast, :success)
|
65
65
|
|
66
|
+
ctx = merge_connections_for(ctx, ctx, :pass_fast, :pass_fast, :pass_fast)
|
67
|
+
ctx = merge_outputs_for(ctx,
|
68
|
+
pass_fast: Activity.Output(Activity::FastTrack::PassFast, :pass_fast),
|
69
|
+
)
|
70
|
+
|
66
71
|
return Right, [ctx, flow_options]
|
67
72
|
end
|
68
73
|
|
@@ -76,6 +81,11 @@ module Trailblazer
|
|
76
81
|
def fail_fast_option((ctx, flow_options), *)
|
77
82
|
ctx = merge_connections_for(ctx, ctx, :fail_fast, :failure)
|
78
83
|
|
84
|
+
ctx = merge_connections_for(ctx, ctx, :fail_fast, :fail_fast, :fail_fast)
|
85
|
+
ctx = merge_outputs_for(ctx,
|
86
|
+
fail_fast: Activity.Output(Activity::FastTrack::FailFast, :fail_fast),
|
87
|
+
)
|
88
|
+
|
79
89
|
return Right, [ctx, flow_options]
|
80
90
|
end
|
81
91
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
end
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "trailblazer-activity", ">= 0.
|
22
|
+
spec.add_dependency "trailblazer-activity", ">= 0.11.3", "< 1.0.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "minitest", "~> 5.0"
|
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.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-activity
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.3
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.0.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.11.3
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.0.0
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.7.
|
139
|
+
rubygems_version: 2.7.3
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Simple DSL to define Trailblazer activities.
|