trailblazer-operation 0.7.5 → 0.8.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e06d73c350844dbfc8a0e2f1e7a6fab4d2943d52bb3efb8b35c51b5f9a042926
4
- data.tar.gz: 658a1b5b6d94a14d2f3b6a92c2da8bae5c0b4c157393a5da218fbe3bbdac8caf
3
+ metadata.gz: 5bbb0fa15c5191698a061f5bb8b93a5eace67064ea2fbcbf0e470fac0cd753ae
4
+ data.tar.gz: 8e2936aa292319ae85ff536b52a7804d458490789cf899993bcad735f127e737
5
5
  SHA512:
6
- metadata.gz: e9b30666287aa4e737a393266e9be36f2eb8fed6543329fb99c23afc17aa7b5ffd54c765e0adf008f62d673b4d4ff3a9a34e7b81e808c825b8f6faf9e3a0c0fd
7
- data.tar.gz: 5a022c81097174f73a9894b6b9a52333eaf5e83e300a1d3054a9abdb1205a7825a0b2da0ec643206f75cc33b35c21140682b2733cd2dccd559a47e0efc0a101a
6
+ metadata.gz: aa828e7e9ca916cd4d312925407e7a723831a13d08f4f8bc4eddae6b0f0867bd8f7c23929e5f385fde91a7dad9ed706b96cbb54010adbec607f7c315eb928725
7
+ data.tar.gz: ec3ecc37e71550152747ce598e4a1e44ac17beac712dbde45463a08e357673c3835539c6122e5047a6381b9440be32829f1a9f986d894715204bf5a39332d5a7
@@ -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', head, jruby, jruby-head]
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,7 @@
1
+ ## 0.8.0
2
+
3
+ * Use `trailblazer-activity-dsl-linear` 1.0.0.
4
+
1
5
  ## 0.7.5
2
6
 
3
7
  * Upgrade `trailblazer-activity` & `trailblazer-activity-dsl-linear` patch versions.
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
- @state.to_h[:fields][field]
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
- options = @state.to_h[:fields].merge(field => value)
12
- @state.update_options(options)
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.to_h[:fields]
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([["task_wrap.call_task", method(:call_task)]])
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}.
@@ -38,10 +38,12 @@ module Trailblazer
38
38
  @stack = stack
39
39
  end
40
40
 
41
+ # TODO: deprecate!
41
42
  def wtf
42
43
  Developer::Trace::Present.(@stack)
43
44
  end
44
45
 
46
+ # TODO: deprecate!
45
47
  def wtf?
46
48
  puts wtf
47
49
  end
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Operation
4
- VERSION = "0.7.5"
4
+ VERSION = "0.8.0.beta1"
5
5
  end
6
6
  end
7
7
  end
@@ -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
- # DISCUSS: I don't know where else to put this. It's not part of the {Activity} concept
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, skills, etc.
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 ->(options, **) { options["a"] = options["model.class"] }
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::DSL::Linear::Sequence::IndexError do
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::DSL::Linear::Sequence::IndexError: StepTest::InvalidStep:
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", ">= 0.4.1", "< 1.0.0"
21
- spec.add_dependency "trailblazer-activity", ">= 0.12.2", "< 1.0.0"
22
- spec.add_dependency "trailblazer-developer", ">= 0.0.21", "< 1.0.0"
20
+ spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.0.0.beta1", "< 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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.8.0.beta1
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: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity-dsl-linear
@@ -16,60 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.1
19
+ version: 1.0.0.beta1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.0
22
+ version: 1.1.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.4.1
29
+ version: 1.0.0.beta1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.0
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.2
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: 1.0.0
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 0.12.2
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: 1.0.0
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.21
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.21
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
@@ -181,7 +155,7 @@ homepage: http://trailblazer.to
181
155
  licenses:
182
156
  - MIT
183
157
  metadata: {}
184
- post_install_message:
158
+ post_install_message:
185
159
  rdoc_options: []
186
160
  require_paths:
187
161
  - lib
@@ -192,12 +166,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
166
  version: 2.1.0
193
167
  required_rubygems_version: !ruby/object:Gem::Requirement
194
168
  requirements:
195
- - - ">="
169
+ - - ">"
196
170
  - !ruby/object:Gem::Version
197
- version: '0'
171
+ version: 1.3.1
198
172
  requirements: []
199
- rubygems_version: 3.0.8
200
- signing_key:
173
+ rubygems_version: 3.2.3
174
+ signing_key:
201
175
  specification_version: 4
202
176
  summary: Trailblazer's operation object with railway flow and integrated error handling.
203
177
  test_files: