trailblazer-operation 0.1.2 → 0.1.3
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/CHANGES.md +4 -0
- data/Gemfile +1 -1
- data/lib/trailblazer/operation/railway/macaroni.rb +2 -0
- data/lib/trailblazer/operation/variable_mapping.rb +3 -3
- data/lib/trailblazer/operation/version.rb +1 -1
- data/lib/trailblazer/operation.rb +2 -0
- data/test/docs/macaroni_test.rb +17 -10
- data/test/docs/wiring_test.rb +52 -0
- data/trailblazer-operation.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f371c58b3c8fcd88c0c12a5e764be7a807c83c2
|
4
|
+
data.tar.gz: 67e41d4d0b7e0480a5948b45a2b53b4f56170ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00591cd8d45d48b909d03042e486ac14496c0156455ec89222e7a68b059e12c4398b38e6a6265e4e971f4735d9cd2e4f675d2a73749a2baf3fca9bc42680841d'
|
7
|
+
data.tar.gz: f4aefde8d80cd7f822fbccf3ef9e513650db0f5caafc21cda3041e9fe6a9d220ea43eae000390933cf2d9546e04e5fc7d90dd41f5e72ae6d664c67701fb938ab
|
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
@@ -20,5 +20,5 @@ gem "trailblazer-developer", git: "https://github.com/trailblazer/trailblazer-de
|
|
20
20
|
|
21
21
|
# gem "declarative", path: "../declarative"
|
22
22
|
|
23
|
-
|
23
|
+
gem "trailblazer-activity", path: "../trailblazer-circuit"
|
24
24
|
# gem "trailblazer-activity", git: "https://github.com/trailblazer/trailblazer-activity"
|
@@ -45,11 +45,11 @@ class Trailblazer::Activity
|
|
45
45
|
@strategy = strategy
|
46
46
|
end
|
47
47
|
|
48
|
-
# Runs the user filter and replaces the ctx in `wrap_ctx[:
|
48
|
+
# Runs the user filter and replaces the ctx in `wrap_ctx[:return_args]` with the filtered one.
|
49
49
|
def call( (wrap_ctx, original_args), **circuit_options )
|
50
50
|
(original_ctx, original_flow_options), original_circuit_options = original_args
|
51
51
|
|
52
|
-
returned_ctx, _ = wrap_ctx[:
|
52
|
+
returned_ctx, _ = wrap_ctx[:return_args] # this is the Context returned from `call`ing the task.
|
53
53
|
|
54
54
|
# returned_ctx is the Context object from the nested operation. In <=2.1, this might be a completely different one
|
55
55
|
# than "ours" we created in Input. We now need to compile a list of all added values. This is time-intensive and should
|
@@ -63,7 +63,7 @@ class Trailblazer::Activity
|
|
63
63
|
|
64
64
|
new_ctx = @strategy.( original_ctx, output ) # here, we compute the "new" options {Context}.
|
65
65
|
|
66
|
-
wrap_ctx = wrap_ctx.merge(
|
66
|
+
wrap_ctx = wrap_ctx.merge( return_args: [new_ctx, original_flow_options] )
|
67
67
|
|
68
68
|
# and then pass on the "new" context.
|
69
69
|
return Trailblazer::Activity::Right, [ wrap_ctx, original_args ]
|
@@ -23,6 +23,8 @@ require "trailblazer/operation/railway/normalizer"
|
|
23
23
|
require "trailblazer/operation/task_wrap"
|
24
24
|
require "trailblazer/operation/trace"
|
25
25
|
|
26
|
+
require "trailblazer/operation/railway/macaroni"
|
27
|
+
|
26
28
|
module Trailblazer
|
27
29
|
# The Trailblazer-style operation.
|
28
30
|
# Note that you don't have to use our "opinionated" version with result object, skills, etc.
|
data/test/docs/macaroni_test.rb
CHANGED
@@ -1,26 +1,33 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
require "trailblazer/operation/railway/macaroni"
|
4
|
-
|
5
3
|
class MacaroniTaskBuilderTest < Minitest::Spec
|
6
|
-
|
4
|
+
Memo = Struct.new(:title) do
|
5
|
+
def save
|
6
|
+
self.title = title[:title].reverse
|
7
|
+
end
|
8
|
+
end
|
7
9
|
|
10
|
+
#:create
|
8
11
|
class Memo::Create < Trailblazer::Operation
|
9
|
-
|
12
|
+
#~ign
|
13
|
+
Normalizer = Railway::Normalizer.new( task_builder: Railway::KwSignature )
|
10
14
|
|
11
15
|
step :create_model, normalizer: Normalizer
|
12
16
|
step :save, normalizer: Normalizer
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
#~ign end
|
18
|
+
#~methods
|
19
|
+
def create_model( params:, options:, ** )
|
20
|
+
options[:model] = Memo.new( title: params[:title] )
|
16
21
|
end
|
17
22
|
|
18
|
-
def save(model:, **)
|
19
|
-
model.
|
23
|
+
def save( model:, ** )
|
24
|
+
model.save
|
20
25
|
end
|
26
|
+
#~methods end
|
21
27
|
end
|
28
|
+
#:create end
|
22
29
|
|
23
30
|
it "allows optional macaroni call style" do
|
24
|
-
Memo::Create.( params: { title: "Wow!" } ).inspect(:model).must_equal %{<Result:true ["!woW"] >}
|
31
|
+
Memo::Create.( params: { title: "Wow!" } ).inspect(:model).must_equal %{<Result:true [#<struct MacaroniTaskBuilderTest::Memo title=\"!woW\">] >}
|
25
32
|
end
|
26
33
|
end
|
data/test/docs/wiring_test.rb
CHANGED
@@ -419,3 +419,55 @@ class WiringsDocRecoverTest < Minitest::Spec
|
|
419
419
|
[ result.success?, result[:s3], result[:azure], result[:b2], result[:problem] ].must_equal [ false, false, false, false, "All uploads failed." ]
|
420
420
|
end
|
421
421
|
end
|
422
|
+
|
423
|
+
class WiringsDocCustomConnectionTest < Minitest::Spec
|
424
|
+
Memo = Class.new(WiringDocsTest::Memo)
|
425
|
+
|
426
|
+
#:target-id
|
427
|
+
class Memo::Upload < Trailblazer::Operation
|
428
|
+
step :new?, Output(:failure) => "index"
|
429
|
+
step :upload
|
430
|
+
step :validate
|
431
|
+
fail :validation_error
|
432
|
+
step :index, id: "index"
|
433
|
+
#~target-id-methods
|
434
|
+
def new?(options, is_new:, **)
|
435
|
+
options[:new?] = is_new
|
436
|
+
end
|
437
|
+
|
438
|
+
def upload(options, **)
|
439
|
+
options[:upload] = true
|
440
|
+
end
|
441
|
+
|
442
|
+
def validate(options, validate:true, **)
|
443
|
+
options[:validate] = validate
|
444
|
+
end
|
445
|
+
|
446
|
+
def validation_error(options, **)
|
447
|
+
options[:validation_error] = true
|
448
|
+
end
|
449
|
+
|
450
|
+
def index(options, **)
|
451
|
+
options[:index] = true
|
452
|
+
end
|
453
|
+
#~target-id-methods end
|
454
|
+
end
|
455
|
+
#:target-id end
|
456
|
+
|
457
|
+
let(:my_image) { "beautiful landscape" }
|
458
|
+
|
459
|
+
it "works with new image" do
|
460
|
+
result = Memo::Upload.( image: my_image, is_new: true )
|
461
|
+
result.inspect(:new?, :upload, :validate, :validation_error, :index).must_equal %{<Result:true [true, true, true, nil, true] >}
|
462
|
+
end
|
463
|
+
|
464
|
+
it "skips everything but index for existing image" do
|
465
|
+
result = Memo::Upload.( image: my_image, is_new: false )
|
466
|
+
result.inspect(:new?, :upload, :validate, :validation_error, :index).must_equal %{<Result:true [false, nil, nil, nil, true] >}
|
467
|
+
end
|
468
|
+
|
469
|
+
it "fails in validation" do
|
470
|
+
result = Memo::Upload.( image: my_image, is_new: true, validate: false )
|
471
|
+
result.inspect(:new?, :upload, :validate, :validation_error, :index).must_equal %{<Result:false [true, true, false, true, nil] >}
|
472
|
+
end
|
473
|
+
end
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "trailblazer-activity", ">= 0.3.
|
20
|
+
spec.add_dependency "trailblazer-activity", ">= 0.3.2", "< 0.4.0"
|
21
21
|
spec.add_dependency "trailblazer-context", ">= 0.1.1", "< 0.3.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler"
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-activity
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.2
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.4.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.3.
|
29
|
+
version: 0.3.2
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.4.0
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.6.
|
174
|
+
rubygems_version: 2.6.8
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Trailblazer's operation object with railway flow and integrated error handling.
|