trailblazer-operation 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGES.md +8 -0
- data/Gemfile +5 -0
- data/lib/trailblazer/operation/class_dependencies.rb +7 -4
- data/lib/trailblazer/operation/public_call.rb +1 -1
- data/lib/trailblazer/operation/trace.rb +2 -0
- data/lib/trailblazer/operation/version.rb +1 -1
- data/lib/trailblazer/operation.rb +7 -9
- data/test/class_dependencies_test.rb +29 -2
- data/test/step_test.rb +2 -2
- data/trailblazer-operation.gemspec +2 -3
- metadata +8 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7d499269759535250f16ea0d6bcf6c23542ad4cc5be0e5ffda4d2e707d33ed
|
4
|
+
data.tar.gz: e92315fb7214bc17eda181a09ea1388c20a78bd74cc96e0f7312df30f919accf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '098ee61ee7be942eecc08843b3d88bb93c778774f6f69598bcb418473d4a264619a1461f7c0de8fc6c7d246c6b7f9cb546f000bc474055e3611bd0920d9af33d'
|
7
|
+
data.tar.gz: 3642d73a74df00b44eeb3762e0f2fd2751b5f6d0385ff3cb26c8699b9d417d9b7603273832604567c69cd276ff396d89f93b516b54f476936088cdbd1343a0b2
|
data/.github/workflows/ci.yml
CHANGED
@@ -6,7 +6,7 @@ jobs:
|
|
6
6
|
fail-fast: false
|
7
7
|
matrix:
|
8
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',
|
9
|
+
ruby: [2.5, 2.6, 2.7, '3.0', '3.1', head, jruby]
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
steps:
|
12
12
|
- uses: actions/checkout@v2
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.8.0
|
2
|
+
|
3
|
+
* Use `trailblazer-activity-dsl-linear` 1.0.0.
|
4
|
+
|
5
|
+
## 0.7.5
|
6
|
+
|
7
|
+
* Upgrade `trailblazer-activity` & `trailblazer-activity-dsl-linear` patch versions.
|
8
|
+
|
1
9
|
## 0.7.4
|
2
10
|
|
3
11
|
* Fix `Operation.call` being called twice before delegating to `call_with_circuit_interface`. This is done via a special `call_task` in the operation's taskWrap.
|
data/Gemfile
CHANGED
@@ -16,3 +16,8 @@ gem "minitest-line"
|
|
16
16
|
# gem "trailblazer-context", path: "../trailblazer-context"
|
17
17
|
# gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
18
18
|
# gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
|
19
|
+
|
20
|
+
# gem "trailblazer-macro", path: "../trailblazer-macro"
|
21
|
+
# gem "trailblazer-activity", path: "../trailblazer-activity"
|
22
|
+
# gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
23
|
+
# gem "trailblazer-declarative"
|
@@ -2,14 +2,17 @@
|
|
2
2
|
class Trailblazer::Operation
|
3
3
|
# The use of this module is currently not encouraged and it is only here for backward-compatibility.
|
4
4
|
# Instead, please pass dependencies via containers, locals, or macros into the respective steps.
|
5
|
+
#
|
5
6
|
module ClassDependencies
|
6
7
|
def [](field)
|
7
|
-
|
8
|
+
class_fields[field]
|
8
9
|
end
|
9
10
|
|
11
|
+
# Store a field on @state, which is provided by {Strategy}.
|
10
12
|
def []=(field, value)
|
11
|
-
|
12
|
-
|
13
|
+
@state.update!(:fields) do |fields|
|
14
|
+
fields.merge(field => value)
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def options_for_public_call(options, flow_options)
|
@@ -18,7 +21,7 @@ class Trailblazer::Operation
|
|
18
21
|
end
|
19
22
|
|
20
23
|
private def class_fields
|
21
|
-
@state.
|
24
|
+
@state.get(:fields)
|
22
25
|
end
|
23
26
|
|
24
27
|
private def context_for_fields(fields, (ctx, flow_options), **)
|
@@ -82,7 +82,7 @@ module Trailblazer
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def initial_wrap_static(*)
|
85
|
-
Activity::TaskWrap::Pipeline.new([
|
85
|
+
Activity::TaskWrap::Pipeline.new([Activity::TaskWrap::Pipeline.Row("task_wrap.call_task", method(:call_task))])
|
86
86
|
end
|
87
87
|
|
88
88
|
def call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
|
@@ -1,12 +1,11 @@
|
|
1
|
+
require "trailblazer/activity/dsl/linear"
|
1
2
|
require 'forwardable'
|
2
3
|
require 'trailblazer/operation/version'
|
3
|
-
require "trailblazer/option"
|
4
|
-
require "trailblazer/context"
|
5
|
-
|
6
|
-
require "trailblazer/activity/dsl/linear"
|
7
4
|
|
8
5
|
module Trailblazer
|
9
|
-
#
|
6
|
+
# As opposed to {Activity::Railway} and {Activity::FastTrack} an operation
|
7
|
+
# maintains different terminus subclasses.
|
8
|
+
# DISCUSS: remove this, at some point in time!
|
10
9
|
class Activity
|
11
10
|
class Railway
|
12
11
|
module End
|
@@ -31,6 +30,7 @@ module Trailblazer
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
33
|
+
# DISCUSS: where do we need this?
|
34
34
|
def self.Operation(options)
|
35
35
|
Class.new(Activity::FastTrack( Activity::Operation.OptionsForState.merge(options) )) do
|
36
36
|
extend Operation::PublicCall
|
@@ -38,10 +38,8 @@ module Trailblazer
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# The Trailblazer-style operation.
|
41
|
-
# Note that you don't have to use our "opinionated" version with result object,
|
42
|
-
class Operation < Activity::FastTrack(Activity::Operation.OptionsForState)
|
43
|
-
# extend Skill::Accessors # ::[] and ::[]= # TODO: fade out this usage.
|
44
|
-
|
41
|
+
# Note that you don't have to use our "opinionated" version with result object, etc.
|
42
|
+
class Operation < Activity::FastTrack(**Activity::Operation.OptionsForState)
|
45
43
|
class << self
|
46
44
|
alias_method :strategy_call, :call
|
47
45
|
end
|
@@ -8,16 +8,43 @@ class ClassDependenciesTest < Minitest::Spec
|
|
8
8
|
|
9
9
|
self["model.class"] = Module
|
10
10
|
|
11
|
-
step ->(
|
11
|
+
step ->(ctx, **) { ctx["a"] = ctx["model.class"] }
|
12
12
|
end
|
13
13
|
|
14
14
|
it { Index.({}).inspect("a", "model.class").must_equal %{<Result:true [Module, Module] >} }
|
15
15
|
|
16
16
|
it "creates separate ctx for circuit interface" do
|
17
|
+
# raise "this can't work since the OP is run without TaskWrap.invoke"
|
17
18
|
signal, (ctx, _) = Index.([{}, {}], {})
|
18
19
|
|
19
|
-
ctx["model.class"].inspect.must_equal %{Module} # FIXME: should this be here?
|
20
20
|
ctx[:a].inspect.must_equal %{Module}
|
21
|
+
ctx["model.class"].inspect.must_equal %{Module} # FIXME: should this be here?
|
22
|
+
end
|
23
|
+
|
24
|
+
# nested OPs
|
25
|
+
it "injects class dependencies for nested OP" do
|
26
|
+
class Home < Trailblazer::Operation
|
27
|
+
step Subprocess(Index)
|
28
|
+
end
|
29
|
+
|
30
|
+
# "model.class" gets injected automatically just before {Index}.
|
31
|
+
Home.({params: {}}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}} mutable_options={\"a\"=>Module}>> >}
|
32
|
+
|
33
|
+
# "model.class" gets injected by user and overrides class dependencies.
|
34
|
+
Home.({params: {}, "model.class" => Symbol}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}, \"model.class\"=>Symbol} mutable_options={\"a\"=>Symbol}>> >}
|
35
|
+
|
36
|
+
|
37
|
+
class Dashboard < Trailblazer::Operation
|
38
|
+
extend ClassDependencies
|
39
|
+
self["model.class"] = Float # this overrides {Index}'es dependency
|
40
|
+
|
41
|
+
pass ->(ctx, **) { ctx[:Dashboard] = ctx["model.class"] }
|
42
|
+
step Subprocess(Index)
|
43
|
+
end
|
44
|
+
|
45
|
+
# TODO: "model.class" gets injected automatically in {Dashboard} and overrides the {Index} input.
|
46
|
+
Dashboard.({params: {}}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Float} mutable_options=#<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Float} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}} mutable_options={:Dashboard=>Float, \"a\"=>Float}>>>> >}
|
47
|
+
|
21
48
|
end
|
22
49
|
|
23
50
|
describe "inheritance" do
|
data/test/step_test.rb
CHANGED
@@ -177,13 +177,13 @@ class StepTest < Minitest::Spec
|
|
177
177
|
#-
|
178
178
|
# not existent :name
|
179
179
|
it do
|
180
|
-
op = assert_raises Trailblazer::Activity::
|
180
|
+
op = assert_raises Trailblazer::Activity::Adds::IndexError do
|
181
181
|
class InvalidStep < Trailblazer::Operation
|
182
182
|
step :a, before: "I don't exist!"
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
error_message = %{#<Trailblazer::Activity::
|
186
|
+
error_message = %{#<Trailblazer::Activity::Adds::IndexError: StepTest::InvalidStep:
|
187
187
|
\e[31m\"I don't exist!\" is not a valid step ID. Did you mean any of these ?\e[0m
|
188
188
|
\e[32m\"Start.default\"
|
189
189
|
\"End.success\"
|
@@ -17,9 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "trailblazer-activity-dsl-linear",
|
21
|
-
spec.add_dependency "trailblazer-
|
22
|
-
spec.add_dependency "trailblazer-developer", ">= 0.0.21", "< 1.0.0"
|
20
|
+
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.0.0", "< 1.1.0"
|
21
|
+
spec.add_dependency "trailblazer-developer", ">= 0.0.26"
|
23
22
|
|
24
23
|
spec.add_development_dependency "bundler"
|
25
24
|
spec.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,75 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-operation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-activity-dsl-linear
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.4.0
|
20
|
-
- - "<"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 1.0.0
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.4.0
|
30
20
|
- - "<"
|
31
21
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: trailblazer-activity
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.12.1
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 1.0.0
|
22
|
+
version: 1.1.0
|
43
23
|
type: :runtime
|
44
24
|
prerelease: false
|
45
25
|
version_requirements: !ruby/object:Gem::Requirement
|
46
26
|
requirements:
|
47
27
|
- - ">="
|
48
28
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
29
|
+
version: 1.0.0
|
50
30
|
- - "<"
|
51
31
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.
|
32
|
+
version: 1.1.0
|
53
33
|
- !ruby/object:Gem::Dependency
|
54
34
|
name: trailblazer-developer
|
55
35
|
requirement: !ruby/object:Gem::Requirement
|
56
36
|
requirements:
|
57
37
|
- - ">="
|
58
38
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.0.
|
60
|
-
- - "<"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.0.0
|
39
|
+
version: 0.0.26
|
63
40
|
type: :runtime
|
64
41
|
prerelease: false
|
65
42
|
version_requirements: !ruby/object:Gem::Requirement
|
66
43
|
requirements:
|
67
44
|
- - ">="
|
68
45
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.0.
|
70
|
-
- - "<"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 1.0.0
|
46
|
+
version: 0.0.26
|
73
47
|
- !ruby/object:Gem::Dependency
|
74
48
|
name: bundler
|
75
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
170
|
- !ruby/object:Gem::Version
|
197
171
|
version: '0'
|
198
172
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
173
|
+
rubygems_version: 3.2.3
|
200
174
|
signing_key:
|
201
175
|
specification_version: 4
|
202
176
|
summary: Trailblazer's operation object with railway flow and integrated error handling.
|