trailblazer-activity 0.11.3 → 0.12.2
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 +17 -0
- data/CHANGES.md +21 -0
- data/Gemfile +1 -6
- data/lib/trailblazer/activity/introspect.rb +14 -0
- data/lib/trailblazer/activity/schema/intermediate.rb +6 -4
- data/lib/trailblazer/activity/task_builder.rb +6 -6
- data/lib/trailblazer/activity/task_wrap.rb +8 -2
- data/lib/trailblazer/activity/task_wrap/call_task.rb +3 -1
- data/lib/trailblazer/activity/task_wrap/runner.rb +1 -1
- data/lib/trailblazer/activity/task_wrap/variable_mapping.rb +8 -6
- data/lib/trailblazer/activity/testing.rb +10 -4
- data/lib/trailblazer/activity/version.rb +1 -1
- data/trailblazer-activity.gemspec +3 -1
- metadata +38 -16
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64e6b7c70557dea00024b9e16b1d85ee3046589a5b759028a2178cdd6da99231
|
|
4
|
+
data.tar.gz: 2283d2744d77ca89de067f1a368c98ddc60b4e4ca39337b59066d35f642a7c65
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9a1c011210c61b7e1ae55df77d003e4029160968093b3c71c73ccd65e460bdb911a97a016b7c524f9d3806074816f195a85f8e4e66b67245f670d7c69650417
|
|
7
|
+
data.tar.gz: cc45abe8914b199fa98e31e0e6e9e9b9582e4e097c296f3407f3e365851813a632eb45133f37bf95c71212c08c15e0deafc723d952d1f00bf6e8087035bd07cd
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
test:
|
|
5
|
+
strategy:
|
|
6
|
+
fail-fast: false
|
|
7
|
+
matrix:
|
|
8
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
|
9
|
+
ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head]
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- uses: ruby/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: ${{ matrix.ruby }}
|
|
16
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
17
|
+
- run: bundle exec rake
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# 0.12.2
|
|
2
|
+
|
|
3
|
+
* Use extracted `trailblazer-option`.
|
|
4
|
+
|
|
5
|
+
# 0.12.1
|
|
6
|
+
|
|
7
|
+
* Allow injecting `:wrap_static` into `TaskWrap.invoke`.
|
|
8
|
+
|
|
9
|
+
# 0.12.0
|
|
10
|
+
|
|
11
|
+
* Support for Ruby 3.0.
|
|
12
|
+
|
|
13
|
+
# 0.11.5
|
|
14
|
+
|
|
15
|
+
* Bug fix: `:output` filter from `TaskWrap::VariableMapping` wasn't returning the correct `flow_options`. If the wrapped task changed
|
|
16
|
+
its `flow_options`, the original one was still returned from the taskWrap run, not the updated one.
|
|
17
|
+
|
|
18
|
+
# 0.11.4
|
|
19
|
+
|
|
20
|
+
* Introduce the `config_wrap:` option in `Intermediate.call(intermediate, implementation, config_merge: {})` to allow injecting data into the activity's `:config` field.
|
|
21
|
+
|
|
1
22
|
# 0.11.3
|
|
2
23
|
|
|
3
24
|
* Allow `Testing.def_task` & `Testing.def_tasks` to return custom signals
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in workflow.gemspec
|
|
4
2
|
gemspec
|
|
5
3
|
|
|
6
|
-
gem "benchmark-ips"
|
|
7
|
-
gem "minitest-line"
|
|
8
|
-
|
|
9
|
-
# gem "trailblazer-context", path: "../trailblazer-context"
|
|
10
4
|
# gem "trailblazer-developer", path: "../trailblazer-developer"
|
|
5
|
+
# gem "trailblazer-context", github: "trailblazer/trailblazer-context", branch: "ruby-3"
|
|
@@ -68,6 +68,20 @@ module Trailblazer
|
|
|
68
68
|
def self.Graph(*args)
|
|
69
69
|
Graph.new(*args)
|
|
70
70
|
end
|
|
71
|
+
|
|
72
|
+
def self.render_task(proc)
|
|
73
|
+
if proc.is_a?(Method)
|
|
74
|
+
|
|
75
|
+
receiver = proc.receiver
|
|
76
|
+
receiver = receiver.is_a?(Class) ? (receiver.name || "#<Class:0x>") : (receiver.name || "#<Module:0x>") #"#<Class:0x>"
|
|
77
|
+
|
|
78
|
+
return "#<Method: #{receiver}.#{proc.name}>"
|
|
79
|
+
elsif proc.is_a?(Symbol)
|
|
80
|
+
return proc.to_s
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
proc.inspect
|
|
84
|
+
end
|
|
71
85
|
end # Introspect
|
|
72
86
|
end
|
|
73
87
|
end
|
|
@@ -12,14 +12,16 @@ class Trailblazer::Activity
|
|
|
12
12
|
# Compiles a {Schema} instance from an {intermediate} structure and
|
|
13
13
|
# the {implementation} object references.
|
|
14
14
|
#
|
|
15
|
-
# Intermediate structure, Implementation, calls extensions, passes {}
|
|
16
|
-
def self.call(intermediate, implementation)
|
|
17
|
-
config_default = {wrap_static: Hash.new(TaskWrap.initial_wrap_static)}
|
|
15
|
+
# Intermediate structure, Implementation, calls extensions, passes {config} # TODO
|
|
16
|
+
def self.call(intermediate, implementation, config_merge: {})
|
|
17
|
+
config_default = {wrap_static: Hash.new(TaskWrap.initial_wrap_static)} # DISCUSS: this really doesn't have to be here, but works for now and we want it in 99%.
|
|
18
|
+
config = config_default.merge(config_merge)
|
|
19
|
+
config.freeze
|
|
18
20
|
|
|
19
21
|
circuit = circuit(intermediate, implementation)
|
|
20
22
|
nodes = node_attributes(intermediate, implementation)
|
|
21
23
|
outputs = outputs(intermediate.stop_task_ids, nodes)
|
|
22
|
-
config = config(implementation, config:
|
|
24
|
+
config = config(implementation, config: config)
|
|
23
25
|
Schema.new(circuit, outputs, nodes, config)
|
|
24
26
|
end
|
|
25
27
|
|
|
@@ -5,7 +5,7 @@ module Trailblazer
|
|
|
5
5
|
# Output signal binary: true=>Right, false=>Left.
|
|
6
6
|
# Passes through all subclasses of Direction.~~~~~~~~~~~~~~~~~
|
|
7
7
|
def self.Binary(user_proc)
|
|
8
|
-
Task.new(Trailblazer::Option
|
|
8
|
+
Task.new(Trailblazer::Option(user_proc), user_proc)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
# Translates the return value of the user step into a valid signal.
|
|
@@ -28,16 +28,16 @@ module Trailblazer
|
|
|
28
28
|
|
|
29
29
|
def call( (ctx, flow_options), **circuit_options )
|
|
30
30
|
# Execute the user step with TRB's kw args.
|
|
31
|
-
result = @task.( ctx, **circuit_options
|
|
31
|
+
result = @task.(ctx, keyword_arguments: ctx.to_hash, **circuit_options) # circuit_options contains :exec_context.
|
|
32
32
|
|
|
33
33
|
# Return an appropriate signal which direction to go next.
|
|
34
|
-
signal = Activity::TaskBuilder.binary_signal_for(
|
|
34
|
+
signal = Activity::TaskBuilder.binary_signal_for(result, Activity::Right, Activity::Left)
|
|
35
35
|
|
|
36
|
-
return signal, [
|
|
36
|
+
return signal, [ctx, flow_options]
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def inspect
|
|
40
|
-
%{#<Trailblazer::Activity::TaskBuilder::Task user_proc=#{@user_proc}>}
|
|
39
|
+
def inspect # TODO: make me private!
|
|
40
|
+
%{#<Trailblazer::Activity::TaskBuilder::Task user_proc=#{Trailblazer::Activity::Introspect.render_task(@user_proc)}>}
|
|
41
41
|
end
|
|
42
42
|
alias_method :to_s, :inspect
|
|
43
43
|
end
|
|
@@ -13,11 +13,14 @@ module Trailblazer
|
|
|
13
13
|
module_function
|
|
14
14
|
|
|
15
15
|
# Compute runtime arguments necessary to execute a taskWrap per task of the activity.
|
|
16
|
-
|
|
16
|
+
# This method is the top-level entry, called only once for the entire activity graph.
|
|
17
|
+
def invoke(activity, args, wrap_runtime: {}, wrap_static: initial_wrap_static, **circuit_options)
|
|
17
18
|
circuit_options = circuit_options.merge(
|
|
18
19
|
runner: TaskWrap::Runner,
|
|
19
20
|
wrap_runtime: wrap_runtime,
|
|
20
|
-
|
|
21
|
+
# This {:activity} structure is currently (?) only needed in {TaskWrap.wrap_static_for}, where we
|
|
22
|
+
# access {activity[:wrap_static]} to compile the effective taskWrap.
|
|
23
|
+
activity: {wrap_static: {activity => wrap_static}, nodes: {}}, # for Runner. Ideally we'd have a list of all static_wraps here (even nested).
|
|
21
24
|
)
|
|
22
25
|
|
|
23
26
|
# signal, (ctx, flow), circuit_options =
|
|
@@ -43,6 +46,9 @@ module Trailblazer
|
|
|
43
46
|
@merge = merge
|
|
44
47
|
end
|
|
45
48
|
|
|
49
|
+
# Compile-time:
|
|
50
|
+
# Gets called via the {Normalizer} and represents an {:extensions} item.
|
|
51
|
+
# Adds/alters the activity's {wrap_static}.
|
|
46
52
|
def call(config:, task:, **)
|
|
47
53
|
before_pipe = State::Config.get(config, :wrap_static, task.circuit_task)
|
|
48
54
|
|
|
@@ -6,9 +6,11 @@ class Trailblazer::Activity
|
|
|
6
6
|
def self.call_task(wrap_ctx, original_args)
|
|
7
7
|
task = wrap_ctx[:task]
|
|
8
8
|
|
|
9
|
+
original_arguments, original_circuit_options = original_args
|
|
10
|
+
|
|
9
11
|
# Call the actual task we're wrapping here.
|
|
10
12
|
# puts "~~~~wrap.call: #{task}"
|
|
11
|
-
return_signal, return_args = task.(
|
|
13
|
+
return_signal, return_args = task.(original_arguments, **original_circuit_options)
|
|
12
14
|
|
|
13
15
|
# DISCUSS: do we want original_args here to be passed on, or the "effective" return_args which are different to original_args now?
|
|
14
16
|
wrap_ctx = wrap_ctx.merge( return_signal: return_signal, return_args: return_args )
|
|
@@ -17,7 +17,7 @@ class Trailblazer::Activity
|
|
|
17
17
|
|
|
18
18
|
# We save all original args passed into this Runner.call, because we want to return them later after this wrap
|
|
19
19
|
# is finished.
|
|
20
|
-
original_args = [
|
|
20
|
+
original_args = [args, circuit_options]
|
|
21
21
|
|
|
22
22
|
# call the wrap {Activity} around the task.
|
|
23
23
|
wrap_ctx, _ = task_wrap_pipeline.(wrap_ctx, original_args) # we omit circuit_options here on purpose, so the wrapping activity uses the default, plain Runner.
|
|
@@ -38,7 +38,7 @@ class Trailblazer::Activity
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
# {input.call()} is invoked in the circuit.
|
|
41
|
-
# `original_args` are the actual args passed to the wrapped task: [ [
|
|
41
|
+
# `original_args` are the actual args passed to the wrapped task: [ [ctx, ..], circuit_options ]
|
|
42
42
|
#
|
|
43
43
|
def call(wrap_ctx, original_args)
|
|
44
44
|
# let user compute new ctx for the wrapped task.
|
|
@@ -57,7 +57,7 @@ class Trailblazer::Activity
|
|
|
57
57
|
|
|
58
58
|
# Invoke the @filter callable with the original circuit interface.
|
|
59
59
|
def apply_filter((ctx, original_flow_options), original_circuit_options)
|
|
60
|
-
@filter.([ctx, original_flow_options], original_circuit_options) # returns {new_ctx}.
|
|
60
|
+
@filter.([ctx, original_flow_options], **original_circuit_options) # returns {new_ctx}.
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
@@ -73,12 +73,14 @@ class Trailblazer::Activity
|
|
|
73
73
|
def call(wrap_ctx, original_args)
|
|
74
74
|
(original_ctx, original_flow_options), original_circuit_options = original_args
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
return_args = wrap_ctx[:return_args]
|
|
77
|
+
|
|
78
|
+
returned_ctx, returned_flow_options = wrap_ctx[:return_args] # this is the Context returned from {call}ing the wrapped user task.
|
|
79
|
+
original_ctx = wrap_ctx[@id] # grab the original ctx from before which was set in the {:input} filter.
|
|
78
80
|
# let user compute the output.
|
|
79
|
-
output_ctx = @filter.(returned_ctx, [original_ctx,
|
|
81
|
+
output_ctx = @filter.(returned_ctx, [original_ctx, returned_flow_options], **original_circuit_options)
|
|
80
82
|
|
|
81
|
-
wrap_ctx = wrap_ctx.merge( return_args: [output_ctx,
|
|
83
|
+
wrap_ctx = wrap_ctx.merge( return_args: [output_ctx, returned_flow_options] )
|
|
82
84
|
|
|
83
85
|
# and then pass on the "new" context.
|
|
84
86
|
return wrap_ctx, original_args
|
|
@@ -62,10 +62,6 @@ module Trailblazer
|
|
|
62
62
|
Success = Activity::End(:success)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def Cct(activity)
|
|
66
|
-
Trailblazer::Developer::Render::Circuit.(activity)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
65
|
# TODO: Remove this once all it's references are removed
|
|
70
66
|
def implementing
|
|
71
67
|
Implementing
|
|
@@ -143,9 +139,19 @@ module Trailblazer
|
|
|
143
139
|
|
|
144
140
|
def assert_circuit(schema, circuit)
|
|
145
141
|
cct = Cct(schema)
|
|
142
|
+
|
|
146
143
|
cct = cct.gsub("#<Trailblazer::Activity::TaskBuilder::Task user_proc=", "<*")
|
|
147
144
|
assert_equal %{#{circuit}}, cct
|
|
148
145
|
end
|
|
146
|
+
|
|
147
|
+
def Cct(activity)
|
|
148
|
+
Trailblazer::Developer::Render::Circuit.(activity, inspect_task: Trailblazer::Activity::Testing.method(:render_task))
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Use this in {#Cct}.
|
|
153
|
+
def self.render_task(proc)
|
|
154
|
+
Activity::Introspect.render_task(proc)
|
|
149
155
|
end
|
|
150
156
|
end
|
|
151
157
|
end
|
|
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
end
|
|
18
18
|
spec.require_paths = ["lib"]
|
|
19
19
|
|
|
20
|
-
spec.add_dependency "trailblazer-context", "
|
|
20
|
+
spec.add_dependency "trailblazer-context", "~> 0.5.0"
|
|
21
|
+
spec.add_dependency "trailblazer-option", "~> 0.1.0"
|
|
21
22
|
|
|
22
23
|
spec.add_development_dependency "bundler"
|
|
23
24
|
spec.add_development_dependency "minitest", "~> 5.0"
|
|
25
|
+
spec.add_development_dependency "minitest-line"
|
|
24
26
|
spec.add_development_dependency "rake"
|
|
25
27
|
spec.add_development_dependency "trailblazer-developer", ">= 0.0.7"
|
|
26
28
|
|
metadata
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trailblazer-activity
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-06-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: trailblazer-context
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.3.1
|
|
20
|
-
- - "<"
|
|
17
|
+
- - "~>"
|
|
21
18
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.
|
|
19
|
+
version: 0.5.0
|
|
23
20
|
type: :runtime
|
|
24
21
|
prerelease: false
|
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
23
|
requirements:
|
|
27
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.5.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: trailblazer-option
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
28
32
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.
|
|
30
|
-
|
|
33
|
+
version: 0.1.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
31
39
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
40
|
+
version: 0.1.0
|
|
33
41
|
- !ruby/object:Gem::Dependency
|
|
34
42
|
name: bundler
|
|
35
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,6 +66,20 @@ dependencies:
|
|
|
58
66
|
- - "~>"
|
|
59
67
|
- !ruby/object:Gem::Version
|
|
60
68
|
version: '5.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: minitest-line
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
61
83
|
- !ruby/object:Gem::Dependency
|
|
62
84
|
name: rake
|
|
63
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,15 +108,15 @@ dependencies:
|
|
|
86
108
|
- - ">="
|
|
87
109
|
- !ruby/object:Gem::Version
|
|
88
110
|
version: 0.0.7
|
|
89
|
-
description:
|
|
111
|
+
description:
|
|
90
112
|
email:
|
|
91
113
|
- apotonick@gmail.com
|
|
92
114
|
executables: []
|
|
93
115
|
extensions: []
|
|
94
116
|
extra_rdoc_files: []
|
|
95
117
|
files:
|
|
118
|
+
- ".github/workflows/ci.yml"
|
|
96
119
|
- ".gitignore"
|
|
97
|
-
- ".travis.yml"
|
|
98
120
|
- CHANGES.md
|
|
99
121
|
- Gemfile
|
|
100
122
|
- LICENSE
|
|
@@ -124,7 +146,7 @@ homepage: http://trailblazer.to
|
|
|
124
146
|
licenses:
|
|
125
147
|
- LGPL-3.0
|
|
126
148
|
metadata: {}
|
|
127
|
-
post_install_message:
|
|
149
|
+
post_install_message:
|
|
128
150
|
rdoc_options: []
|
|
129
151
|
require_paths:
|
|
130
152
|
- lib
|
|
@@ -140,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
162
|
version: '0'
|
|
141
163
|
requirements: []
|
|
142
164
|
rubygems_version: 3.0.8
|
|
143
|
-
signing_key:
|
|
165
|
+
signing_key:
|
|
144
166
|
specification_version: 4
|
|
145
167
|
summary: Runtime code for Trailblazer activities.
|
|
146
168
|
test_files: []
|