trailblazer 2.1.0.beta3 → 2.1.0.beta4

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
- SHA1:
3
- metadata.gz: 36d27170113024b0c2af51f22fc1abc6042c6a68
4
- data.tar.gz: 7483dd6c7482d06e332dd4b0ff9b74dd6afe4d91
2
+ SHA256:
3
+ metadata.gz: 044bf54cdca3624c8e6bc5da16773c89de007343daa9312144a64699e7e4be01
4
+ data.tar.gz: ef916032a3a00776e16e743f443b3ce6a7388f1b3ae39e87d6014223e896a897
5
5
  SHA512:
6
- metadata.gz: b05d29959550818ae9103231ac9716f3ebb8a074139d1b4a0e5b0f3a8e48e724dfe348e09fc18356412b9874dd4be930ba91148736b49c930946316fa54e358a
7
- data.tar.gz: e5d373cd46eb4b2823df61256e03aa68ed98df9ad84a58b6ac96add3520fafc5577cfbcfa9adcf1dd460698db6219f9aa4136430f2ff8d632eaa0a01f6b6d744
6
+ metadata.gz: c18bec78e4bf2dd29865bf0644f8aad697e32066144a56c4ebda7fa52d9736a9991e2807da38bb2b0d07da51e1de8714a8a937f212141a8955a59c9c03e1342c
7
+ data.tar.gz: 9e8a51483076587ff6b495d46597f38f624dbbfe718517c93cd9a94a4fabee7d224ab415a8e913986bffeee76dd1c4255e94ceb73e12b7f96bb4fbb47484e8a0
data/.travis.yml CHANGED
@@ -11,3 +11,5 @@ matrix:
11
11
  gemfile: Gemfile
12
12
  - rvm: 2.3.1
13
13
  gemfile: Gemfile
14
+ - rvm: 2.4.1
15
+ gemfile: Gemfile
data/CHANGES.md CHANGED
@@ -7,6 +7,7 @@
7
7
  * Wrap
8
8
  dropped the `pipe` option. This is now `options, flow_options, *`
9
9
  `false` is now automatically connected to End.failure.
10
+ * remove `Uber::Callable`.
10
11
 
11
12
  * `operation.new` step removed.
12
13
  * Undocumented step behavior removed. You can't write to `self` anymore.
@@ -29,6 +30,10 @@ document Task API and define step API
29
30
  deprecate step->(options) ?
30
31
  injectable, per-operation step arguments strategy?
31
32
 
33
+ # 2.1.0.beta4
34
+
35
+ * Simple maintenance release to establish `activity-0.5.0`.
36
+
32
37
  # 2.1.0.beta3
33
38
 
34
39
  * More simplifications because of `activity`.
data/Gemfile CHANGED
@@ -14,7 +14,7 @@ gem "dry-auto_inject"
14
14
  gem "dry-matcher"
15
15
  gem "dry-validation"
16
16
 
17
- # gem "trailblazer-operation", path: "../operation"
17
+ gem "trailblazer-operation", path: "../operation"
18
18
  # gem "trailblazer-operation", github: "trailblazer/trailblazer-operation"
19
19
 
20
20
  gem "minitest-line"
data/README.md CHANGED
@@ -5,6 +5,7 @@ _Trailblazer provides new high-level abstractions for Ruby frameworks. It gently
5
5
  [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
6
  [![TRB Newsletter](https://img.shields.io/badge/TRB-newsletter-lightgrey.svg)](http://trailblazer.to/newsletter/)
7
7
  [![Gem Version](https://badge.fury.io/rb/trailblazer.svg)](http://badge.fury.io/rb/trailblazer)
8
+ [![Open Source Helpers](https://www.codetriage.com/trailblazer/trailblazer/badges/users.svg)](https://www.codetriage.com/trailblazer/trailblazer)
8
9
 
9
10
  **This document discusses Trailblazer 2.1.** An overview about the additions are [on our website](http://trailblazer.to/blog/2017-12-trailblazer-2-1-what-you-need-to-know.html).
10
11
 
@@ -29,12 +29,12 @@ class Trailblazer::Operation
29
29
 
30
30
  def define_call
31
31
  class_mod.class_exec(container, dependency_map) do |container, dependency_map|
32
- define_method :call do |params={}, options={}, *dependencies|
33
- options_with_deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
34
- obj[name] = options[name] || container[identifier]
35
- }.merge(options)
32
+ define_method :call do |ctx={}, *dependencies|
33
+ ctx_with_deps = dependency_map.to_h.each_with_object({}) { |(name, identifier), obj|
34
+ obj[name] = ctx[name] || container[identifier]
35
+ }.merge(ctx)
36
36
 
37
- super(params, options_with_deps, *dependencies)
37
+ super(ctx_with_deps, *dependencies)
38
38
  end
39
39
  end
40
40
  end
@@ -1,6 +1,7 @@
1
1
  # per default, everything we pass into a circuit is immutable. it's the ops/act's job to allow writing (via a Context)
2
2
  module Trailblazer
3
3
  class Operation
4
+ # {Nested} macro.
4
5
  def self.Nested(callable, input:nil, output:nil, id: "Nested(#{callable})")
5
6
  task_wrap_extensions = Module.new do
6
7
  extend Activity::Path::Plan()
@@ -35,7 +36,7 @@ module Trailblazer
35
36
  # The returned {Nested} instance is a valid circuit element and will be `call`ed in the circuit.
36
37
  # It simply returns the nested activity's `signal,options,flow_options` return set.
37
38
  # The actual wiring - where to go with that - is done by the step DSL.
38
- return Trailblazer::Activity::Subprocess(nested_operation, call: :__call__), nested_operation, false
39
+ return Trailblazer::Operation::Callable(nested_operation, call: :__call__), nested_operation, false
39
40
  end
40
41
 
41
42
  def self.nestable_object?(object)
@@ -71,7 +72,7 @@ module Trailblazer
71
72
 
72
73
  # overwrite :task so task_wrap.call_task will call this activity. This is a trick so we don't have to repeat
73
74
  # logic from #call_task here.
74
- wrap_ctx[:task] = Trailblazer::Activity::Subprocess( activity, call: :__call__ )
75
+ wrap_ctx[:task] = Trailblazer::Operation::Callable( activity, call: :__call__ )
75
76
 
76
77
  return Activity::Right, [ wrap_ctx, original_args ]
77
78
  end
@@ -46,6 +46,8 @@ class Trailblazer::Operation
46
46
  # FIXME: we *might* return some "older version" of options here!
47
47
  if returned === false
48
48
  return @operation.outputs[:failure].signal, [options, flow_options]
49
+ elsif returned === true
50
+ return @operation.outputs[:success].signal, [options, flow_options]
49
51
  end
50
52
 
51
53
  returned # let's hope returned is one of activity's Ends.
@@ -1,3 +1,3 @@
1
1
  module Trailblazer
2
- VERSION = "2.1.0.beta3"
2
+ VERSION = "2.1.0.beta4"
3
3
  end
@@ -10,15 +10,22 @@ class DryAutoInjectTest < Minitest::Spec
10
10
 
11
11
  class Create < Trailblazer::Operation
12
12
  include AutoInject[:user_repository]
13
+
14
+ pass :use_it!
15
+
16
+ def use_it!(ctx, user_repository:, **)
17
+ ctx[:my_repo] = user_repository
18
+ end
13
19
  end
14
20
 
15
21
  it "auto-injects user_repository" do
16
- res = Create.({})
22
+ res = Create.(params: {})
17
23
  res[:user_repository].must_equal Object
24
+ res[:my_repo].must_equal Object
18
25
  end
19
26
 
20
27
  it "allows dependency injection via ::call" do
21
- Create.({}, user_repository: String)[:user_repository].must_equal String
28
+ Create.(params: {}, user_repository: String)[:user_repository].must_equal String
22
29
  end
23
30
 
24
31
  describe "inheritance" do
@@ -231,7 +231,7 @@ class FastTrackWithNestedTest < Minitest::Spec
231
231
  #:ft-rewire
232
232
  class Memo::Create < Trailblazer::Operation
233
233
  step :validate
234
- step Nested( Lib::Authenticate ), Output(:fail_fast) => :failure
234
+ step Nested( Lib::Authenticate ), Output(:fail_fast) => Track(:failure)
235
235
  step :create_model
236
236
  step :save
237
237
  #~ignrw
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class DocsInputOutputTest < Minitest::Spec
4
+ class NoMappingTest < Minitest::Spec
5
+ Memo = Class.new(Memo)
6
+ end
7
+ end
@@ -122,9 +122,9 @@ end
122
122
  # end
123
123
  # #:class-level end
124
124
 
125
- # it { Create.(); Create["result.policy"].must_equal nil }
125
+ # it { Create.(); Create["result.policy"].must_be_nil }
126
126
  # it { Create.(params: {}, current_user: Module)["x"].must_equal true }
127
- # it { Create.(params: {} )["x"].must_equal nil }
127
+ # it { Create.(params: {} )["x"].must_be_nil }
128
128
  # end
129
129
 
130
130
 
@@ -118,7 +118,7 @@ class RescueTest < Minitest::Spec
118
118
  end
119
119
 
120
120
  step Rescue( RecordNotFound, handler: :rollback! ) {
121
- step Wrap ->(*, &block) { Sequel.transaction do block.call end } {
121
+ step Wrap (->(*, &block) { Sequel.transaction do block.call end }) {
122
122
  step Model( Song, :find )
123
123
  step ->(options, *) { options[:model].lock! } # lock the model.
124
124
  step Contract::Build( constant: MyContract )
@@ -37,18 +37,21 @@ class WrapTest < Minitest::Spec
37
37
  end
38
38
  end
39
39
 
40
+ # it allows returning legacy true/false
40
41
  class Create < Trailblazer::Operation
41
42
  class MyContract < Reform::Form
42
43
  property :title
43
44
  end
44
45
 
45
- step Wrap ->(options, *, &block) {
46
+ step Wrap( ->(options, *, &block) {
46
47
  begin
47
48
  block.call
48
49
  rescue => exception
49
50
  options["result.model.find"] = "argh! because #{exception.class}"
50
- false
51
- end } {
51
+ return false
52
+ end
53
+ true
54
+ }) {
52
55
  step Model( Song, :find )
53
56
  step Contract::Build( constant: MyContract )
54
57
  }
@@ -63,7 +66,7 @@ class WrapTest < Minitest::Spec
63
66
  # Wrap return
64
67
  class WrapReturnTest < Minitest::Spec
65
68
  class Create < Trailblazer::Operation
66
- step Wrap ->(options, *, &block) { options["yield?"] ? block.call : false } {
69
+ step Wrap( ->(options, *, &block) { options["yield?"] ? block.call : false }) {
67
70
  step ->(options, **) { options["x"] = true }
68
71
  success :noop!
69
72
  # ...
@@ -118,7 +121,7 @@ class WrapTest < Minitest::Spec
118
121
  end
119
122
 
120
123
  #~wrap-only end
121
- step Wrap ->(*, &block) { Sequel.transaction do block.call end } {
124
+ step Wrap( ->(*, &block) { Sequel.transaction do block.call end } ) {
122
125
  step Model( Song, :new )
123
126
  #~wrap-only
124
127
  step Contract::Build( constant: MyContract )
@@ -200,7 +203,7 @@ class WrapTest < Minitest::Spec
200
203
  class WrapWithMethodTest < Minitest::Spec
201
204
  class Create < Trailblazer::Operation
202
205
  step Model( Song, :new )
203
- step Wrap ->(options, *, &block) { block.call } {
206
+ step Wrap( ->(options, *, &block) { block.call } ) {
204
207
  step :check_model!
205
208
 
206
209
  }
data/test/module_test.rb CHANGED
@@ -86,7 +86,7 @@
86
86
  # op["dispatched"].must_equal [:notify_me!]
87
87
  # op["model"].name.must_equal "Feelings"
88
88
  # op["model"].artist.id.must_equal 1
89
- # op["model"].artist.full_name.must_equal nil # property not declared.
89
+ # op["model"].artist.full_name.must_be_nil # property not declared.
90
90
  # end
91
91
 
92
92
  # it do
data/test/nested_test.rb CHANGED
@@ -169,7 +169,7 @@ class NestedTest < Minitest::Spec
169
169
  result["can.B.see.params?"].must_be_nil
170
170
  if is_successful
171
171
  result["can.B.see.A.mutable.data?"].must_equal "from A!"
172
- result["can.B.see.A.class.data?"].must_equal nil # we don't look for it.
172
+ result["can.B.see.A.class.data?"].must_be_nil # we don't look for it.
173
173
  result["can.A.see.B.mutable.data?"].must_equal "from AlmostB!"
174
174
  else
175
175
  result["can.B.see.A.mutable.data?"].must_be_nil
@@ -267,7 +267,7 @@ class NestedWithFastTrackTest < Minitest::Spec
267
267
  #- Nested, :pass_fast => :failure
268
268
  it "attaches :pass_fast => :failure" do
269
269
  op = Class.new(Trailblazer::Operation) do
270
- step Nested( Edit ), Output(:pass_fast) => :failure
270
+ step Nested( Edit ), Output(:pass_fast) => Track(:failure)
271
271
  step :b
272
272
  fail :f
273
273
 
@@ -38,7 +38,7 @@ class DslContractTest < MiniTest::Spec
38
38
  end
39
39
 
40
40
  # no inheritance with setter.
41
- it { CreateOrFind["contract.default.class"].must_equal nil }
41
+ it { CreateOrFind["contract.default.class"].must_be_nil }
42
42
 
43
43
  # ---
44
44
  # Op::contract Constant
@@ -197,7 +197,7 @@ class DslContractTest < MiniTest::Spec
197
197
  form.sync
198
198
 
199
199
  song.genre.must_equal "Punkrock"
200
- song.band.must_equal nil
200
+ song.band.must_be_nil
201
201
  end
202
202
  end
203
203
 
data/test/test_helper.rb CHANGED
@@ -31,3 +31,10 @@ end
31
31
  require "pp"
32
32
 
33
33
  Minitest::Spec::Operation = Trailblazer::Operation
34
+
35
+ Memo = Struct.new(:id, :body) do
36
+ def self.find(id)
37
+ return new(id, "Yo!") if id
38
+ nil
39
+ end
40
+ end
data/trailblazer.gemspec CHANGED
@@ -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-operation", ">= 0.2.0", "< 0.3.0"
20
+ spec.add_dependency "trailblazer-operation", ">= 0.2.3", "< 0.3.0"
21
21
  spec.add_dependency "trailblazer-activity", ">= 0.4.3", "< 0.6.0"
22
22
 
23
23
  spec.add_dependency "reform", ">= 2.2.0", "< 3.0.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.beta3
4
+ version: 2.1.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-02 00:00:00.000000000 Z
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-operation
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: 0.2.3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.3.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.2.0
29
+ version: 0.2.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.3.0
@@ -220,6 +220,7 @@ files:
220
220
  - test/docs/dry_test.rb
221
221
  - test/docs/fast_test.rb
222
222
  - test/docs/guard_test.rb
223
+ - test/docs/input_output_test.rb
223
224
  - test/docs/macro_test.rb
224
225
  - test/docs/model_test.rb
225
226
  - test/docs/nested_test.rb
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
267
  version: 1.3.1
267
268
  requirements: []
268
269
  rubyforge_project:
269
- rubygems_version: 2.6.8
270
+ rubygems_version: 2.7.3
270
271
  signing_key:
271
272
  specification_version: 4
272
273
  summary: A high-level architecture for Ruby and Rails.
@@ -279,6 +280,7 @@ test_files:
279
280
  - test/docs/dry_test.rb
280
281
  - test/docs/fast_test.rb
281
282
  - test/docs/guard_test.rb
283
+ - test/docs/input_output_test.rb
282
284
  - test/docs/macro_test.rb
283
285
  - test/docs/model_test.rb
284
286
  - test/docs/nested_test.rb