trailblazer-activity 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGES.md +26 -1
- data/Gemfile +1 -6
- data/lib/trailblazer/activity.rb +1 -1
- data/lib/trailblazer/activity/circuit.rb +1 -1
- 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/call_task.rb +3 -1
- data/lib/trailblazer/activity/task_wrap/inject.rb +1 -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 +15 -7
- data/lib/trailblazer/activity/version.rb +1 -1
- data/trailblazer-activity.gemspec +2 -1
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f790c2cce163e21a33c31093c7d74358574f851249b810a4e776472fccc9cb4f
|
4
|
+
data.tar.gz: 0e78fa480306d480850ef3709871e234ece90939e9552a4ddcfe0bb26f5e2853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35b942b116679ad0aae0793fc102ad274f2aef584dd91a9d808d0abf50f3ca62ba0e20b9eca9590063bf97096ed177c119d41e18c964d4f33730f9719e30836b
|
7
|
+
data.tar.gz: 63596947b49ca3bfd44d3cd567bf6abfdefbc086cea31da14716654a920caaa443c49071828114a2e7fa99905d3d5810ef9b19087b27b1782a7b1bdcdcddd410
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,6 +1,31 @@
|
|
1
|
+
# 0.12.0
|
2
|
+
|
3
|
+
* Support for Ruby 3.0.
|
4
|
+
|
5
|
+
# 0.11.5
|
6
|
+
|
7
|
+
* Bug fix: `:output` filter from `TaskWrap::VariableMapping` wasn't returning the correct `flow_options`. If the wrapped task changed
|
8
|
+
its `flow_options`, the original one was still returned from the taskWrap run, not the updated one.
|
9
|
+
|
10
|
+
# 0.11.4
|
11
|
+
|
12
|
+
* Introduce the `config_wrap:` option in `Intermediate.call(intermediate, implementation, config_merge: {})` to allow injecting data into the activity's `:config` field.
|
13
|
+
|
14
|
+
# 0.11.3
|
15
|
+
|
16
|
+
* Allow `Testing.def_task` & `Testing.def_tasks` to return custom signals
|
17
|
+
|
18
|
+
# 0.11.2
|
19
|
+
|
20
|
+
* Updrading `trailblazer-context` version :drum:
|
21
|
+
|
22
|
+
# 0.11.1
|
23
|
+
|
24
|
+
* Internal warning fixes.
|
25
|
+
|
1
26
|
# 0.11.0
|
2
27
|
|
3
|
-
* Support for Ruby 2.7.
|
28
|
+
* Support for Ruby 2.7. Most warnings are gone.
|
4
29
|
|
5
30
|
# 0.10.1
|
6
31
|
|
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"
|
data/lib/trailblazer/activity.rb
CHANGED
@@ -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
|
@@ -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 )
|
@@ -13,7 +13,7 @@ class Trailblazer::Activity
|
|
13
13
|
|
14
14
|
ctx = original_ctx.merge(defaulted_options)
|
15
15
|
|
16
|
-
Trailblazer::Context
|
16
|
+
Trailblazer::Context(ctx, {}, flow_options[:context_options])
|
17
17
|
end
|
18
18
|
|
19
19
|
output = ->(new_ctx, (original_ctx, _flow_options), _circuit_options) { # FIXME: use Unscope
|
@@ -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
|
@@ -27,7 +27,9 @@ module Trailblazer
|
|
27
27
|
Module.new do
|
28
28
|
define_singleton_method(name) do | (ctx, flow_options), ** |
|
29
29
|
ctx[:seq] << name
|
30
|
-
|
30
|
+
signal = ctx.key?(name) ? ctx[name] : Activity::Right
|
31
|
+
|
32
|
+
return signal, [ctx, flow_options]
|
31
33
|
end
|
32
34
|
end.method(name)
|
33
35
|
end
|
@@ -38,9 +40,9 @@ module Trailblazer
|
|
38
40
|
names.each do |name|
|
39
41
|
define_method(name) do | (ctx, flow_options), ** |
|
40
42
|
ctx[:seq] << name
|
41
|
-
|
43
|
+
signal = ctx.key?(name) ? ctx[name] : Activity::Right
|
42
44
|
|
43
|
-
return
|
45
|
+
return signal, [ctx, flow_options]
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -60,10 +62,6 @@ module Trailblazer
|
|
60
62
|
Success = Activity::End(:success)
|
61
63
|
end
|
62
64
|
|
63
|
-
def Cct(activity)
|
64
|
-
Trailblazer::Developer::Render::Circuit.(activity)
|
65
|
-
end
|
66
|
-
|
67
65
|
# TODO: Remove this once all it's references are removed
|
68
66
|
def implementing
|
69
67
|
Implementing
|
@@ -141,9 +139,19 @@ module Trailblazer
|
|
141
139
|
|
142
140
|
def assert_circuit(schema, circuit)
|
143
141
|
cct = Cct(schema)
|
142
|
+
|
144
143
|
cct = cct.gsub("#<Trailblazer::Activity::TaskBuilder::Task user_proc=", "<*")
|
145
144
|
assert_equal %{#{circuit}}, cct
|
146
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)
|
147
155
|
end
|
148
156
|
end
|
149
157
|
end
|
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
end
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "trailblazer-context", ">= 0.
|
20
|
+
spec.add_dependency "trailblazer-context", ">= 0.4.0", "< 0.5.0"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
spec.add_development_dependency "minitest-line"
|
24
25
|
spec.add_development_dependency "rake"
|
25
26
|
spec.add_development_dependency "trailblazer-developer", ">= 0.0.7"
|
26
27
|
|
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.12.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:
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-context
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.4.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.5.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.4.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.5.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '5.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest-line
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: rake
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
153
|
- !ruby/object:Gem::Version
|
140
154
|
version: '0'
|
141
155
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.3
|
156
|
+
rubygems_version: 3.2.3
|
144
157
|
signing_key:
|
145
158
|
specification_version: 4
|
146
159
|
summary: Runtime code for Trailblazer activities.
|