trailblazer-activity-dsl-linear 1.0.0 → 1.1.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/.github/workflows/ci.yml +6 -4
- data/.github/workflows/ci_jruby.yml +19 -0
- data/.github/workflows/ci_legacy.yml +19 -0
- data/.github/workflows/ci_truffleruby.yml +19 -0
- data/CHANGES.md +28 -0
- data/Gemfile +3 -3
- data/Rakefile +1 -1
- data/lib/trailblazer/activity/dsl/linear/feature/patch.rb +5 -1
- data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb +242 -147
- data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb +278 -0
- data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb +65 -211
- data/lib/trailblazer/activity/dsl/linear/helper.rb +17 -5
- data/lib/trailblazer/activity/dsl/linear/normalizer/terminus.rb +1 -1
- data/lib/trailblazer/activity/dsl/linear/normalizer.rb +3 -12
- data/lib/trailblazer/activity/dsl/linear/strategy.rb +41 -2
- data/lib/trailblazer/activity/dsl/linear/version.rb +1 -1
- data/lib/trailblazer/activity/dsl/linear.rb +1 -0
- data/lib/trailblazer/activity/fast_track.rb +5 -13
- data/lib/trailblazer/activity/path.rb +13 -24
- data/lib/trailblazer/activity/railway.rb +4 -12
- data/trailblazer-activity-dsl-linear.gemspec +3 -2
- metadata +32 -8
@@ -71,8 +71,8 @@ module Trailblazer
|
|
71
71
|
end
|
72
72
|
|
73
73
|
# Used only once per strategy class body.
|
74
|
-
def compile_strategy!(
|
75
|
-
options =
|
74
|
+
def compile_strategy!(strategy_dsl, **options)
|
75
|
+
options = DSL.OptionsForSequenceBuilder(strategy_dsl, **options)
|
76
76
|
|
77
77
|
compile_strategy_for!(**options)
|
78
78
|
end
|
@@ -127,8 +127,47 @@ module Trailblazer
|
|
127
127
|
class_exec(&block) if block_given?
|
128
128
|
end
|
129
129
|
end
|
130
|
+
|
131
|
+
def OptionsForSequenceBuilder(strategy_dsl, termini: nil, **user_options)
|
132
|
+
# DISCUSS: instead of calling a separate {initial_sequence} method we could make DSL strategies
|
133
|
+
# use the actual DSL to build up the initial_sequence, somewhere outside? Maybe using {:adds}?
|
134
|
+
strategy_options, strategy_termini = strategy_dsl.options_for_sequence_build(**user_options) # call Path.options_for_sequence_builder
|
135
|
+
|
136
|
+
# DISCUSS: passing on Normalizers here is a service, not sure I like it.
|
137
|
+
initial_sequence = process_termini(strategy_options[:sequence], termini || strategy_termini, normalizers: strategy_dsl::Normalizers)
|
138
|
+
|
139
|
+
{
|
140
|
+
step_interface_builder: method(:build_circuit_task_for_step),
|
141
|
+
adds: [], # DISCUSS: needed?
|
142
|
+
**user_options,
|
143
|
+
**strategy_options, # this might (and should!) override :track_name etc.
|
144
|
+
sequence: initial_sequence,
|
145
|
+
}
|
146
|
+
# no {:termini} left in options
|
147
|
+
end
|
148
|
+
|
149
|
+
# If no {:termini} were provided by the Strategy user, we use the default
|
150
|
+
# {strategy_termini}.
|
151
|
+
def process_termini(sequence, termini, **options_for_append_terminus)
|
152
|
+
termini.each do |task, terminus_options|
|
153
|
+
sequence = append_terminus(sequence, task, **options_for_append_terminus, **terminus_options)
|
154
|
+
end
|
155
|
+
|
156
|
+
return sequence
|
157
|
+
end
|
158
|
+
|
159
|
+
def append_terminus(sequence, task, normalizers:, **options)
|
160
|
+
# DISCUSS: why are we requiring {:normalizers} here? only for invoking Normalizer.terminus
|
161
|
+
_sequence = Linear::Sequence::Builder.update_sequence_for(:terminus, task, options, normalizers: normalizers, sequence: sequence, normalizer_options: {})
|
162
|
+
end
|
163
|
+
|
164
|
+
# Wraps {user_step} into a circuit-interface compatible callable, a.k.a. "task".
|
165
|
+
def build_circuit_task_for_step(user_step)
|
166
|
+
Activity::Circuit::TaskAdapter.for_step(user_step, option: true)
|
167
|
+
end
|
130
168
|
end # DSL
|
131
169
|
|
170
|
+
|
132
171
|
# FIXME: move to State#dup
|
133
172
|
def self.copy(value, **) # DISCUSS: should that be here?
|
134
173
|
value.copy
|
@@ -34,6 +34,7 @@ require "trailblazer/activity/railway"
|
|
34
34
|
require "trailblazer/activity/fast_track"
|
35
35
|
require "trailblazer/activity/dsl/linear/feature/variable_mapping"
|
36
36
|
require "trailblazer/activity/dsl/linear/feature/variable_mapping/dsl"
|
37
|
+
require "trailblazer/activity/dsl/linear/feature/variable_mapping/runtime"
|
37
38
|
require "trailblazer/activity/dsl/linear/feature/patch"
|
38
39
|
require "trailblazer/activity/dsl/linear/feature/variable_mapping/inherit"
|
39
40
|
|
@@ -106,11 +106,6 @@ module Trailblazer
|
|
106
106
|
ctx
|
107
107
|
end
|
108
108
|
|
109
|
-
def initial_sequence(sequence:, fail_fast_end: Activity::End.new(semantic: :fail_fast), pass_fast_end: Activity::End.new(semantic: :pass_fast), **)
|
110
|
-
sequence = Path::DSL.append_terminus(sequence, fail_fast_end, magnetic_to: :fail_fast, id: "End.fail_fast", normalizers: Normalizers)
|
111
|
-
sequence = Path::DSL.append_terminus(sequence, pass_fast_end, magnetic_to: :pass_fast, id: "End.pass_fast", normalizers: Normalizers)
|
112
|
-
end
|
113
|
-
|
114
109
|
# Normalizer pipelines taking care of processing your DSL options.
|
115
110
|
Normalizers = Linear::Normalizer::Normalizers.new(
|
116
111
|
step: FastTrack::DSL.Normalizer(),
|
@@ -119,16 +114,13 @@ module Trailblazer
|
|
119
114
|
terminus: Linear::Normalizer::Terminus.Normalizer(),
|
120
115
|
)
|
121
116
|
|
122
|
-
def
|
123
|
-
|
124
|
-
|
117
|
+
def options_for_sequence_build(fail_fast_end: Activity::End.new(semantic: :fail_fast), pass_fast_end: Activity::End.new(semantic: :pass_fast), **options)
|
118
|
+
fail_fast_terminus_options = [fail_fast_end, magnetic_to: :fail_fast, id: "End.fail_fast", normalizers: Normalizers]
|
119
|
+
past_fast_terminus_options = [pass_fast_end, magnetic_to: :pass_fast, id: "End.pass_fast", normalizers: Normalizers]
|
125
120
|
|
126
|
-
|
121
|
+
railway_options, railway_termini = Railway::DSL.options_for_sequence_build(**options)
|
127
122
|
|
128
|
-
|
129
|
-
**options,
|
130
|
-
sequence: initial_sequence,
|
131
|
-
}
|
123
|
+
return railway_options, railway_termini + [fail_fast_terminus_options, past_fast_terminus_options]
|
132
124
|
end
|
133
125
|
end # DSL
|
134
126
|
|
@@ -45,7 +45,6 @@ module Trailblazer
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# This is slow and should be done only once at compile-time,
|
48
|
-
# DISCUSS: maybe make this a function?
|
49
48
|
# These are the normalizers for an {Activity}, to be injected into a State.
|
50
49
|
Normalizers = Linear::Normalizer::Normalizers.new(
|
51
50
|
step: Normalizer(), # here, we extend the generic FastTrack::step_normalizer with the Activity-specific DSL
|
@@ -56,39 +55,29 @@ module Trailblazer
|
|
56
55
|
|
57
56
|
# DISCUSS: following methods are not part of Normalizer
|
58
57
|
|
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: {})
|
61
|
-
end
|
62
|
-
|
63
58
|
# @private
|
64
59
|
def start_sequence(track_name:)
|
65
60
|
Linear::Strategy::DSL.start_sequence(wirings: [Linear::Sequence::Search::Forward(unary_outputs[:success], track_name)])
|
66
61
|
end
|
67
62
|
|
68
|
-
|
69
|
-
|
70
|
-
sequence = start_sequence(track_name: track_name)
|
71
|
-
sequence = append_terminus(sequence, end_task, id: end_id, magnetic_to: track_name, normalizers: Normalizers, append_to: "Start.default")
|
72
|
-
end
|
63
|
+
def options_for_sequence_build(track_name: :success, end_task: Activity::End.new(semantic: :success), end_id: "End.success", **)
|
64
|
+
initial_sequence = start_sequence(track_name: track_name)
|
73
65
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
track_name: track_name,
|
83
|
-
end_id: end_id,
|
84
|
-
step_interface_builder: Activity::TaskBuilder.method(:Binary), # DISCUSS: this is currently the only option we want to pass on in Path() ?
|
85
|
-
adds: [], # DISCUSS: needed?
|
86
|
-
**options
|
66
|
+
termini = [
|
67
|
+
[end_task, id: end_id, magnetic_to: track_name, append_to: "Start.default"]
|
68
|
+
]
|
69
|
+
|
70
|
+
options = {
|
71
|
+
sequence: initial_sequence,
|
72
|
+
track_name: track_name,
|
73
|
+
end_id: end_id, # needed in Normalizer.normalize_sequence_insert.
|
87
74
|
}
|
75
|
+
|
76
|
+
return options, termini
|
88
77
|
end
|
89
78
|
end # DSL
|
90
79
|
|
91
|
-
compile_strategy!(DSL, normalizers: DSL::Normalizers) # sets :normalizer, normalizer_options, sequence and activity
|
80
|
+
compile_strategy!(Path::DSL, normalizers: DSL::Normalizers) # sets :normalizer, normalizer_options, sequence and activity
|
92
81
|
end # Path
|
93
82
|
|
94
83
|
def self.Path(**options, &block)
|
@@ -88,10 +88,6 @@ module Trailblazer
|
|
88
88
|
{failure: [Linear::Sequence::Search.method(:Forward), :failure]}
|
89
89
|
end
|
90
90
|
|
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)
|
93
|
-
end
|
94
|
-
|
95
91
|
Normalizers = Linear::Normalizer::Normalizers.new(
|
96
92
|
step: Railway::DSL.Normalizer(),
|
97
93
|
fail: Railway::DSL.NormalizerForFail(),
|
@@ -99,16 +95,12 @@ module Trailblazer
|
|
99
95
|
terminus: Linear::Normalizer::Terminus.Normalizer(),
|
100
96
|
)
|
101
97
|
|
102
|
-
def
|
103
|
-
|
104
|
-
merge(failure_end: failure_end)
|
98
|
+
def options_for_sequence_build(failure_end: Activity::End.new(semantic: :failure), **options)
|
99
|
+
failure_terminus_options = [failure_end, magnetic_to: :failure, id: "End.failure", normalizers: Normalizers]
|
105
100
|
|
106
|
-
|
101
|
+
path_options, path_termini = Path::DSL.options_for_sequence_build(**options)
|
107
102
|
|
108
|
-
|
109
|
-
**options,
|
110
|
-
sequence: initial_sequence,
|
111
|
-
}
|
103
|
+
return path_options, path_termini + [failure_terminus_options]
|
112
104
|
end
|
113
105
|
end # DSL
|
114
106
|
|
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
end
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "trailblazer-activity", ">= 0.
|
21
|
+
spec.add_dependency "trailblazer-activity", ">= 0.15.0", "< 0.16.0"
|
22
22
|
spec.add_dependency "trailblazer-declarative", ">= 0.0.1", "< 0.1.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "minitest", "~> 5.0"
|
26
26
|
spec.add_development_dependency "rake"
|
27
|
-
spec.add_development_dependency "trailblazer-developer", ">= 0.0.
|
27
|
+
spec.add_development_dependency "trailblazer-developer", ">= 0.0.27", "< 0.1.0"
|
28
|
+
spec.add_development_dependency "trailblazer-core-utils", "0.0.2"
|
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-activity
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.15.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.16.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.
|
29
|
+
version: 0.15.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.16.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: trailblazer-declarative
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,14 +98,34 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.0.
|
101
|
+
version: 0.0.27
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.1.0
|
102
105
|
type: :development
|
103
106
|
prerelease: false
|
104
107
|
version_requirements: !ruby/object:Gem::Requirement
|
105
108
|
requirements:
|
106
109
|
- - ">="
|
107
110
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.0.
|
111
|
+
version: 0.0.27
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.1.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: trailblazer-core-utils
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 0.0.2
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.0.2
|
109
129
|
description: Simple DSL to define Trailblazer activities with arbitrary wirings.
|
110
130
|
email:
|
111
131
|
- apotonick@gmail.com
|
@@ -114,6 +134,9 @@ extensions: []
|
|
114
134
|
extra_rdoc_files: []
|
115
135
|
files:
|
116
136
|
- ".github/workflows/ci.yml"
|
137
|
+
- ".github/workflows/ci_jruby.yml"
|
138
|
+
- ".github/workflows/ci_legacy.yml"
|
139
|
+
- ".github/workflows/ci_truffleruby.yml"
|
117
140
|
- ".gitignore"
|
118
141
|
- CHANGES.md
|
119
142
|
- DSL_IDEAS
|
@@ -128,6 +151,7 @@ files:
|
|
128
151
|
- lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb
|
129
152
|
- lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb
|
130
153
|
- lib/trailblazer/activity/dsl/linear/feature/variable_mapping/inherit.rb
|
154
|
+
- lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb
|
131
155
|
- lib/trailblazer/activity/dsl/linear/helper.rb
|
132
156
|
- lib/trailblazer/activity/dsl/linear/helper/path.rb
|
133
157
|
- lib/trailblazer/activity/dsl/linear/normalizer.rb
|