trailblazer-operation 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c019f1fb62cb71a67f95393c340495f3cd512c7914dffae69b8a8789a41b0a5
4
- data.tar.gz: 79e8ef13bbc5193d66e5bd522e3991215f97b581c202bb8b78fde79e877e204e
3
+ metadata.gz: 055b4f6ef1ce80319468ccbb1299dadf1ff82429179381904780a1d04bcda48f
4
+ data.tar.gz: c3d25c70992d811625a162c5dce4bc5751df2665034b80d6739b4153860914ca
5
5
  SHA512:
6
- metadata.gz: 26a554047293b40351fccc08b2f06877d142d6c1e81f6aa1cec0e51e6c4fb8f33f680cf90d5a35437b62e1eb3549d3504f45c601fcb707c2765e286e4de87ff9
7
- data.tar.gz: 30c55dd1a0d0edc75d4c1ff8bd5b66edb14250506eab46d9db090d1d4dbc35f8b0cd38d0abcdaa99d0f156578576461de281479014ac2028892ce31cefcdf519
6
+ metadata.gz: 4e1450dc8761312a31ebb9113a1086e4f51f501a8fbc178f597b9720b14a767e7cd4b42a833b42b2ed065b7c41cd8f9bb19c81ddd808020c4ab9f5643c0375c0
7
+ data.tar.gz: 7ee732afe996545413207ea93ece417b1d5ccb74b51820048957f73c22d8ea53eb61a01c1d96531056e8bbd407e5d1c004382e36132e5dfa435468b24192981c
@@ -1,6 +1,3 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
1
  name: CI
5
2
  on: [push, pull_request]
6
3
  jobs:
@@ -8,7 +5,7 @@ jobs:
8
5
  strategy:
9
6
  fail-fast: false
10
7
  matrix:
11
- ruby: [2.7, '3.0', '3.1']
8
+ ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', 'jruby']
12
9
  runs-on: ubuntu-latest
13
10
  steps:
14
11
  - uses: actions/checkout@v3
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.10.0
2
+
3
+ * Require `trailblazer-activity-dsl-linear-1.2.0`.
4
+ * Remove `Railway::Macaroni`.
5
+ * Remove `Operation::Callable`.
6
+ * Introduce `Operation::INITIAL_WRAP_STATIC` that is computed once at compile-time, not
7
+ with every `#call`.
8
+
1
9
  ## 0.9.0
2
10
 
3
11
  * Use `trailblazer-activity-dsl-linear` 1.1.0.
data/Gemfile CHANGED
@@ -3,16 +3,9 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in trailblazer.gemspec
4
4
  gemspec
5
5
 
6
- gem "multi_json"
6
+ # gem "trailblazer-developer", path: "../trailblazer-developer"
7
+ # gem "trailblazer-activity", path: "../trailblazer-activity"
8
+ # gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
7
9
 
8
- gem "dry-auto_inject"
9
-
10
- gem "benchmark-ips"
11
- gem "minitest-line"
12
-
13
- # gem "trailblazer-developer", path: "../trailblazer-developer"
14
- # gem "trailblazer-developer", git: "https://github.com/trailblazer/trailblazer-developer"
15
- # gem "trailblazer-activity", path: "../trailblazer-activity"
16
- # gem "trailblazer-context", path: "../trailblazer-context"
17
- # gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
18
- # gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
10
+ # gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
11
+ # gem "trailblazer-developer", github: "trailblazer/trailblazer-developer"
@@ -77,16 +77,14 @@ module Trailblazer
77
77
  end
78
78
 
79
79
  # TODO: remove when we stop supporting < 3.0.
80
+ # alternatively, ctx aliasing is only available for Ruby > 2.7.
80
81
  def call_with_flow_options(options, flow_options)
81
82
  raise "[Trailblazer] `Operation.call_with_flow_options is deprecated in Ruby 3.0. Use `Operation.(options, flow_options)`" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.0.0")
82
83
  call_with_public_interface(options, flow_options, {invoke_class: Activity::TaskWrap})
83
84
  end
84
85
 
85
- def initial_wrap_static(*)
86
- Activity::TaskWrap::Pipeline.new([Activity::TaskWrap::Pipeline.Row("task_wrap.call_task", method(:call_task))])
87
- end
88
-
89
- def call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
86
+ # @private
87
+ def self.call_task(wrap_ctx, original_args) # DISCUSS: copied from {TaskWrap.call_task}.
90
88
  op = wrap_ctx[:task]
91
89
 
92
90
  original_arguments, original_circuit_options = original_args
@@ -100,5 +98,11 @@ module Trailblazer
100
98
 
101
99
  return wrap_ctx, original_args
102
100
  end
101
+
102
+ INITIAL_WRAP_STATIC = Activity::TaskWrap::Pipeline.new([Activity::TaskWrap::Pipeline.Row("task_wrap.call_task", method(:call_task))])
103
+
104
+ def initial_wrap_static
105
+ INITIAL_WRAP_STATIC
106
+ end
103
107
  end
104
108
  end
@@ -1,7 +1,7 @@
1
1
  module Trailblazer
2
2
  module Version
3
3
  module Operation
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,9 @@ require "trailblazer/activity/dsl/linear"
2
2
  require 'forwardable'
3
3
  require 'trailblazer/operation/version'
4
4
 
5
+ #
6
+ # Developer's docs: https://trailblazer.to/2.1/docs/internals.html#internals-operation
7
+ #
5
8
  module Trailblazer
6
9
  # As opposed to {Activity::Railway} and {Activity::FastTrack} an operation
7
10
  # maintains different terminus subclasses.
@@ -57,5 +60,3 @@ require "trailblazer/operation/deprecated_macro" # TODO: remove in 2.2.
57
60
 
58
61
  require "trailblazer/operation/result"
59
62
  require "trailblazer/operation/railway"
60
-
61
- require "trailblazer/operation/railway/macaroni"
data/test/step_test.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
+ # TODO: throw away this test, most of it is tested in {dsl}.
4
+
3
5
  # Tests
4
6
  # --- step ->(*) { snippet }
5
7
  # --- step Callable
@@ -40,10 +42,18 @@ class StepTest < Minitest::Spec
40
42
 
41
43
  it { Create.(a: 1, b: 2, c: 3, d: 4, e: 5).inspect("a", "b", "c", "d", "e").must_equal "<Result:true [1, 2, 3, 4, 5] >" }
42
44
 
43
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
44
- it { Trailblazer::Developer.railway(Create).gsub(/0x.+?step_test.rb/, "").gsub(/\)\s.+?step_test.rb/, ") test/step_test.rb").must_equal %{[>#<Proc::30 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ..., **) test/step_test.rb:18>,>d,>MyMacro]} }
45
- else
46
- it { Trailblazer::Developer.railway(Create).gsub(/0x.+?step_test.rb/, "").must_equal %{[>#<Proc::30 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c>,>d,>MyMacro]} }
45
+ it "allows {Developer.railway}" do
46
+ output = Trailblazer::Developer.railway(Create)
47
+ .gsub(/0x.+?step_test.rb/, "")
48
+ .gsub(/\)\s.+?step_test.rb/, ") test/step_test.rb")
49
+
50
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2.0")
51
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ...) test/step_test.rb:20>,>d,>MyMacro])
52
+ elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
53
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c(options, c: ..., **) test/step_test.rb:20>,>d,>MyMacro])
54
+ else
55
+ assert_equal output, %([>#<Proc::32 (lambda)>,>StepTest::Callable,>#<Method: StepTest::Implementation.c>,>d,>MyMacro])
56
+ end
47
57
  end
48
58
 
49
59
  #---
@@ -173,27 +183,6 @@ class StepTest < Minitest::Spec
173
183
  # FIXME: we have all fast track ends here.
174
184
  it { skip; Ii["__activity__"].circuit.instance_variable_get(:@map).size.must_equal 6 }
175
185
 
176
- #---
177
- #-
178
- # not existent :name
179
- it do
180
- op = assert_raises Trailblazer::Activity::Adds::IndexError do
181
- class InvalidStep < Trailblazer::Operation
182
- step :a, before: "I don't exist!"
183
- end
184
- end
185
-
186
- error_message = %{#<Trailblazer::Activity::Adds::IndexError: StepTest::InvalidStep:
187
- \e[31m\"I don't exist!\" is not a valid step ID. Did you mean any of these ?\e[0m
188
- \e[32m\"Start.default\"
189
- \"End.success\"
190
- \"End.pass_fast\"
191
- \"End.fail_fast\"
192
- \"End.failure\"\e[0m>}
193
-
194
- assert_match error_message, op.inspect
195
- end
196
-
197
186
  #---
198
187
  #- :name
199
188
  #- step :whatever, id: :validate
data/test/trace_test.rb CHANGED
@@ -8,7 +8,7 @@ class TraceTest < Minitest::Spec
8
8
 
9
9
  class Create < Trailblazer::Operation
10
10
  step ->(options, a_return:, **) { options[:a] = a_return }, id: "Create.task.a"
11
- step({task: B, id: "MyNested"}, B.to_h[:outputs][0] => Track(:success))
11
+ step Subprocess(B), id: "MyNested"
12
12
  step ->(options, **) { options[:c] = true }, id: "Create.task.c"
13
13
  step ->(_options, params:, **) { params.any? }, id: "Create.task.params"
14
14
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["apotonick@gmail.com"]
10
10
  spec.description = %q(Trailblazer's operation object.)
11
11
  spec.summary = %q(Trailblazer's operation object with railway flow and integrated error handling.)
12
- spec.homepage = "http://trailblazer.to"
12
+ spec.homepage = "https://trailblazer.to/2.1/docs/operation.html"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -17,13 +17,13 @@ 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", ">= 1.1.0", "< 1.2.0"
21
- spec.add_dependency "trailblazer-developer", ">= 0.0.26"
20
+ spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.2.0", "< 1.4.0"
21
+ spec.add_dependency "trailblazer-developer"
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "minitest-line"
25
26
  spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rubocop"
27
27
 
28
- spec.required_ruby_version = ">= 2.1.0"
28
+ spec.required_ruby_version = ">= 2.5.0"
29
29
  end
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.9.0
4
+ version: 0.10.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-12-14 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity-dsl-linear
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 1.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.0
22
+ version: 1.4.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: 1.1.0
29
+ version: 1.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.2.0
32
+ version: 1.4.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: trailblazer-developer
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.26
39
+ version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.0.26
46
+ version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +73,7 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: rake
76
+ name: minitest-line
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
@@ -87,7 +87,7 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: rubocop
90
+ name: rake
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
@@ -108,21 +108,16 @@ extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
110
  - ".github/workflows/ci.yml"
111
- - ".github/workflows/ci_jruby.yml"
112
- - ".github/workflows/ci_legacy.yml"
113
- - ".github/workflows/ci_truffleruby.yml"
114
111
  - ".gitignore"
115
112
  - CHANGES.md
116
113
  - Gemfile
117
114
  - README.md
118
115
  - Rakefile
119
116
  - lib/trailblazer/operation.rb
120
- - lib/trailblazer/operation/callable.rb
121
117
  - lib/trailblazer/operation/class_dependencies.rb
122
118
  - lib/trailblazer/operation/deprecated_macro.rb
123
119
  - lib/trailblazer/operation/public_call.rb
124
120
  - lib/trailblazer/operation/railway.rb
125
- - lib/trailblazer/operation/railway/macaroni.rb
126
121
  - lib/trailblazer/operation/result.rb
127
122
  - lib/trailblazer/operation/trace.rb
128
123
  - lib/trailblazer/operation/version.rb
@@ -152,7 +147,7 @@ files:
152
147
  - test/wiring/defaults_test.rb
153
148
  - test/wiring/subprocess_test.rb
154
149
  - trailblazer-operation.gemspec
155
- homepage: http://trailblazer.to
150
+ homepage: https://trailblazer.to/2.1/docs/operation.html
156
151
  licenses:
157
152
  - MIT
158
153
  metadata: {}
@@ -164,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
159
  requirements:
165
160
  - - ">="
166
161
  - !ruby/object:Gem::Version
167
- version: 2.1.0
162
+ version: 2.5.0
168
163
  required_rubygems_version: !ruby/object:Gem::Requirement
169
164
  requirements:
170
165
  - - ">="
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI JRuby
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [jruby, jruby-head]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI with EOL ruby versions
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [2.5, 2.6]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- ## This file is managed by Terraform.
2
- ## Do not modify this file directly, as it may be overwritten.
3
- ## Please open an issue instead.
4
- name: CI TruffleRuby
5
- on: [push, pull_request]
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: [truffleruby, truffleruby-head]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- bundler-cache: true
19
- - run: bundle exec rake
@@ -1,42 +0,0 @@
1
- module Trailblazer
2
- class Operation
3
- # Use {Callable} if you have an operation or any other callable object that does
4
- # _not_ expose an {Activity interface}. For example, {Operation.call} isn't compatible
5
- # with activities, hence you need to decorate it using {Callable}. The returned object
6
- # exposes an {Activity interface}.
7
- #
8
- # @param :call [Symbol] Method name to call
9
- # @param options [Hash] Hash to merge into {circuit_options}, e.g. {:start_task}.
10
- #
11
- # @example Create and use a Callable instance.
12
- # callable = Trailblazer::Operation::Callable( Memo::Create, call: :__call__ )
13
- # callable.( [ctx, {}] ) #=> Activity interface, ::call will invoke Memo::Create.__call__.
14
- def self.Callable(*args)
15
- Callable.new(*args)
16
- end
17
-
18
- # Subprocess allows to have tasks with a different call interface and start event.
19
- # @param activity any object with an {Activity interface}
20
- class Callable
21
- include Activity::Interface
22
-
23
- def initialize(activity, call: :call, **options)
24
- @activity = activity
25
- @options = options
26
- @call = call
27
- end
28
-
29
- def call(args, **circuit_options)
30
- @activity.public_send(@call, args, circuit_options.merge(@options))
31
- end
32
-
33
- extend Forwardable
34
- # @private
35
- def_delegators :@activity, :to_h, :debug
36
-
37
- def to_s
38
- %{#<Trailblazer::Activity::Callable activity=#{@activity}>}
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- module Trailblazer
2
- module Operation::Railway
3
- # Call the user's steps with a differing API (inspired by Maciej Mensfeld) that
4
- # only receives keyword args. The `options` keyword is the stateful context object
5
- #
6
- # def my_step( params:, ** )
7
- # def my_step( params:, options:, ** )
8
- module Macaroni
9
- def self.call(user_proc)
10
- Activity::TaskBuilder::Task.new(Trailblazer::Option.build(Macaroni::Option, user_proc), user_proc)
11
- end
12
-
13
- class Option < Trailblazer::Option
14
- # The Option#call! method prepares the arguments.
15
- def self.call!(proc, options, *)
16
- proc.(**options.to_hash.merge(options: options))
17
- end
18
- end
19
- end
20
-
21
- KwSignature = Macaroni
22
- end
23
- end