trailblazer-operation 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 7d1a238c8c4bb3a49a8adad7d2ffc709f1f4766d
4
- data.tar.gz: d3495a92e3fc1519b7e847ccd8f1ad2ff84d41a7
3
+ metadata.gz: 2f371c58b3c8fcd88c0c12a5e764be7a807c83c2
4
+ data.tar.gz: 67e41d4d0b7e0480a5948b45a2b53b4f56170ba9
5
5
  SHA512:
6
- metadata.gz: 2f922d3d9a2ebbe3abdc6eb919cf6c99dbd66ffa990f041ba9a1aea6de1a2c56c5f1c436388978c434017213d6eb370059a03846613a3704a1617615d2168435
7
- data.tar.gz: 60eabb5de8f611edc69a9c81003dc78a29c4734ba316e4cdcc6497ba7075ff4c7d1a732dca8660af1c9a327e582bb4c27ccc494820f5495c1b2b93a5fe8022a8
6
+ metadata.gz: '00591cd8d45d48b909d03042e486ac14496c0156455ec89222e7a68b059e12c4398b38e6a6265e4e971f4735d9cd2e4f675d2a73749a2baf3fca9bc42680841d'
7
+ data.tar.gz: f4aefde8d80cd7f822fbccf3ef9e513650db0f5caafc21cda3041e9fe6a9d220ea43eae000390933cf2d9546e04e5fc7d90dd41f5e72ae6d664c67701fb938ab
data/CHANGES.md CHANGED
@@ -14,6 +14,10 @@ lots of work on the DSL specific parts.
14
14
 
15
15
  params:, rest: ..
16
16
 
17
+ ## 0.1.3
18
+
19
+ * New taskWrap API for `activity` 0.3.2.
20
+
17
21
  ## 0.1.2
18
22
 
19
23
  * Add @mensfeld's "Macaroni" step style for a keyword-only signature for steps.
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
- # gem "trailblazer-activity", path: "../circuit"
23
+ gem "trailblazer-activity", path: "../trailblazer-circuit"
24
24
  # gem "trailblazer-activity", git: "https://github.com/trailblazer/trailblazer-activity"
@@ -17,5 +17,7 @@ module Trailblazer
17
17
  end
18
18
  end
19
19
  end
20
+
21
+ KwSignature = Macaroni
20
22
  end
21
23
  end
@@ -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[:result_args]` with the filtered one.
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[:result_args] # this is the Context returned from `call`ing the task.
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( result_args: [new_ctx, original_flow_options] )
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 ]
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  class Operation
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -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.
@@ -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
- module Memo; end
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
- Normalizer = Railway::Normalizer.new( task_builder: Railway::Macaroni )
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
- def create_model(params:, options:, **)
15
- options[:model] = params[:title]
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.reverse!
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
@@ -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.1", "< 0.4.0"
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.2
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-19 00:00:00.000000000 Z
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.1
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.1
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.12
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.