trailblazer-operation 0.0.11 → 0.0.12
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/.travis.yml +1 -1
- data/CHANGES.md +13 -0
- data/lib/trailblazer/operation/option.rb +6 -6
- data/lib/trailblazer/operation/version.rb +1 -1
- data/lib/trailblazer/skill.rb +6 -5
- data/test/2.0.0-pipetree_test.rb +16 -0
- data/test/2.1.0-pipetree_test.rb +16 -0
- data/test/skill_test.rb +0 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea04dd0790a33b1d8ed216bc6c38b2051c8879dd
|
4
|
+
data.tar.gz: 5950c507d31e4ae46c90ef9b1b22789bdcb5c87b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0b2ec25620b01f1f3ddef0ef93bae31de3b7df540d7c6048252ab8d3d1ed294ba9744cf751fdeeffdd1771a8cefd05aba100b3f15a1f1b9750e094ef0602dc
|
7
|
+
data.tar.gz: bc2d57beb613557e4594dba1734424cb39fa4d49e88247fa9d9d800ca1a7c6d7e3f30157a5a2360f9355adad9214f8af63deebde0a04caec53dc13abfc60e63a
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.0.12
|
2
|
+
|
3
|
+
* Allow passing tmp options into `KW::Option` that will be merged with `options` and then transformed into kw args, but only locally for the step scope (or wherever you do `Option.()`). The API:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
Option::KW.(proc).(input, options, some: "more", ...)
|
7
|
+
```
|
8
|
+
Note that `KW::Option` could be massively sped up with simple optimizations.
|
9
|
+
|
10
|
+
## 0.0.11
|
11
|
+
|
12
|
+
* Use `Forwardable` instead of `Uber::Delegates`.
|
13
|
+
|
1
14
|
## 0.0.10
|
2
15
|
|
3
16
|
* `Flow` is now `Railway`.
|
@@ -35,19 +35,19 @@ class Trailblazer::Operation
|
|
35
35
|
|
36
36
|
# Call the option with keyword arguments. Ruby <= 2.0.
|
37
37
|
class KW < Option
|
38
|
-
def self.call_proc(proc, input, options)
|
38
|
+
def self.call_proc(proc, input, options, tmp_options={})
|
39
39
|
return proc.(options) if proc.arity == 1
|
40
|
-
proc.(options, **options)
|
40
|
+
proc.(options, **options.to_hash(tmp_options))
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.call_method(proc, input, options)
|
43
|
+
def self.call_method(proc, input, options, tmp_options={})
|
44
44
|
return input.send(proc, options) if input.method(proc).arity == 1 # TODO: remove this
|
45
|
-
input.send(proc, options, **options)
|
45
|
+
input.send(proc, options, **options.to_hash(tmp_options))
|
46
46
|
end
|
47
47
|
|
48
|
-
def self.call_callable(callable, input, options)
|
48
|
+
def self.call_callable(callable, input, options, tmp_options={})
|
49
49
|
return callable.(options) if callable.method(:call).arity == 1
|
50
|
-
callable.(options, **options)
|
50
|
+
callable.(options, **options.to_hash(tmp_options))
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/trailblazer/skill.rb
CHANGED
@@ -32,15 +32,16 @@ module Trailblazer
|
|
32
32
|
|
33
33
|
# Called when Ruby transforms options into kw args, via **options.
|
34
34
|
# TODO: this method has massive potential for speed improvements.
|
35
|
-
|
35
|
+
# The `tmp_options` argument is experimental. It allows adding temporary options
|
36
|
+
# to the kw args.
|
37
|
+
#:private:
|
38
|
+
def to_hash(tmp_options={})
|
36
39
|
{}.tap do |h|
|
37
|
-
arr = to_runtime_data << to_mutable_data
|
38
|
-
|
40
|
+
arr = to_runtime_data << to_mutable_data << tmp_options
|
39
41
|
|
40
42
|
arr.each { |hsh|
|
41
|
-
|
43
|
+
hsh.each { |k, v| h[k.to_sym] = v }
|
42
44
|
}
|
43
|
-
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
data/test/2.0.0-pipetree_test.rb
CHANGED
@@ -18,6 +18,22 @@ class KWBugsTest < Minitest::Spec
|
|
18
18
|
it { Merchant::New.( {}, { "yo"=> nil } ) }
|
19
19
|
end
|
20
20
|
|
21
|
+
class KWOptionsTest < Minitest::Spec
|
22
|
+
X = Trailblazer::Operation::Option::KW.( ->(options, **) { options["x"] = true } )
|
23
|
+
Y = Trailblazer::Operation::Option::KW.( ->(options, params:nil, **) { options["y"] = params } )
|
24
|
+
Z = Trailblazer::Operation::Option::KW.( ->(options, params:nil, z:nil, **) { options["kw_z"] = z } )
|
25
|
+
A = Trailblazer::Operation::Option::KW.( ->(options, params:nil, z:nil, **) { options["options_z"] = options["z"] } )
|
26
|
+
|
27
|
+
class Create < Trailblazer::Operation
|
28
|
+
step [ ->(input, options) { X.(input, options, z: "Z!") }, name: "X" ]
|
29
|
+
step [ ->(input, options) { Y.(input, options, z: "Z!") }, name: "Y" ]
|
30
|
+
step [ ->(input, options) { Z.(input, options, z: "Z!") }, name: "Z" ]
|
31
|
+
step [ ->(input, options) { A.(input, options, z: "Z!") }, name: "A" ]
|
32
|
+
end
|
33
|
+
|
34
|
+
it { Create.({ params: "yo" }, "z" => 1).inspect("x", "y", "kw_z", "options_z").must_equal %{<Result:true [true, {:params=>\"yo\"}, "Z!", 1] >} }
|
35
|
+
end
|
36
|
+
|
21
37
|
|
22
38
|
class Ruby200PipetreeTest < Minitest::Spec
|
23
39
|
class Create < Trailblazer::Operation
|
data/test/2.1.0-pipetree_test.rb
CHANGED
@@ -18,6 +18,22 @@ class KWBugsTest < Minitest::Spec
|
|
18
18
|
it { Merchant::New.( {}, { "yo"=> nil } ) }
|
19
19
|
end
|
20
20
|
|
21
|
+
class KWOptionsTest < Minitest::Spec
|
22
|
+
X = Trailblazer::Operation::Option::KW.( ->(options, **) { options["x"] = true } )
|
23
|
+
Y = Trailblazer::Operation::Option::KW.( ->(options, params:, **) { options["y"] = params } )
|
24
|
+
Z = Trailblazer::Operation::Option::KW.( ->(options, params:, z:, **) { options["kw_z"] = z } )
|
25
|
+
A = Trailblazer::Operation::Option::KW.( ->(options, params:, z:, **) { options["options_z"] = options["z"] } )
|
26
|
+
|
27
|
+
class Create < Trailblazer::Operation
|
28
|
+
step [ ->(input, options) { X.(input, options, z: "Z!") }, name: "X" ]
|
29
|
+
step [ ->(input, options) { Y.(input, options, z: "Z!") }, name: "Y" ]
|
30
|
+
step [ ->(input, options) { Z.(input, options, z: "Z!") }, name: "Z" ]
|
31
|
+
step [ ->(input, options) { A.(input, options, z: "Z!") }, name: "A" ]
|
32
|
+
end
|
33
|
+
|
34
|
+
it { Create.({ params: "yo" }, "z" => 1).inspect("x", "y", "kw_z", "options_z").must_equal %{<Result:true [true, {:params=>\"yo\"}, "Z!", 1] >} }
|
35
|
+
end
|
36
|
+
|
21
37
|
|
22
38
|
class Ruby200PipetreeTest < Minitest::Spec
|
23
39
|
class Create < Trailblazer::Operation
|
data/test/skill_test.rb
CHANGED
@@ -46,12 +46,3 @@ class SkillTest < Minitest::Spec
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
# resolve: prefer @instance_attrs over competences
|
50
|
-
# or instace_atrt is competences
|
51
|
-
|
52
|
-
# dependencies = { current_user: Runtime::User..., container: BLA }
|
53
|
-
# dependencies[:current_user]
|
54
|
-
# dependencies["user.create.contract"] # delegates to container, somehow.
|
55
|
-
|
56
|
-
# Create.(params, dependencies) # not sure if op should build this runtime dependencies hash or if it comes from outside.
|
57
|
-
|
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.0.
|
4
|
+
version: 0.0.12
|
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-01-
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uber
|