trailblazer-context 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -5
- data/CHANGES.md +4 -0
- data/LICENSE +1 -1
- data/Rakefile +0 -3
- data/lib/trailblazer/container_chain.rb +0 -2
- data/lib/trailblazer/context.rb +2 -2
- data/lib/trailblazer/context/aliasing.rb +4 -2
- data/lib/trailblazer/context/indifferent_access.rb +9 -6
- data/lib/trailblazer/context/version.rb +1 -1
- data/lib/trailblazer/option.rb +18 -19
- data/test/context_test.rb +79 -81
- data/test/option_test.rb +6 -6
- data/test/test_helper.rb +0 -1
- data/trailblazer-context.gemspec +1 -2
- metadata +4 -21
- data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +0 -136
- data/.rubocop.yml +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6c3c7ff9c8b061c5ac0d5aca954f03cd1b5ff0bf286aa787ede12f1e187890
|
4
|
+
data.tar.gz: 0fdc45ffab9316c7799f2ce59f54c6409305cf91fa01349d30d026eac998c188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9f349028afca126e1961e50ebb0ff661a5fe5a0e2573108c9c79f762694cdb03c6914beca4eec4c5b3b25aecae03d4706c47c84854d0ebb57b6e8a42ec279f
|
7
|
+
data.tar.gz: 1fba9db52f9e3680cccb3b89624c8a159bbd144fbd0b86b3a71972ea1feff96978b82867c976a568aec709b09d0fe859d173a1a813fa5747cb42d179bf6c7520
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
-
require "rubocop/rake_task"
|
4
3
|
|
5
4
|
Rake::TestTask.new(:test) do |t|
|
6
5
|
t.libs << "test"
|
@@ -8,6 +7,4 @@ Rake::TestTask.new(:test) do |t|
|
|
8
7
|
t.test_files = FileList["test/*_test.rb"]
|
9
8
|
end
|
10
9
|
|
11
|
-
RuboCop::RakeTask.new(:rubocop)
|
12
|
-
|
13
10
|
task default: %i[test]
|
@@ -39,11 +39,9 @@ class Trailblazer::Context::ContainerChain
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# rubocop:disable Style/AsciiComments
|
43
42
|
# alternative implementation:
|
44
43
|
# containers.reverse.each do |container| @mutable_options.merge!(container) end
|
45
44
|
#
|
46
45
|
# benchmark, merging in #initialize vs. this resolver.
|
47
46
|
# merge 39.678k (± 9.1%) i/s - 198.700k in 5.056653s
|
48
47
|
# resolver 68.928k (± 6.4%) i/s - 342.836k in 5.001610s
|
49
|
-
# rubocop:enable Style/AsciiComments
|
data/lib/trailblazer/context.rb
CHANGED
@@ -17,11 +17,11 @@ module Trailblazer
|
|
17
17
|
# NOTE: In the future, we might look up the Context to use in the ctx.
|
18
18
|
# The demanding signature is for forward-compat.
|
19
19
|
# @private
|
20
|
-
def self.for(wrapped_options, (ctx, flow_options), circuit_options) # TODO: remove
|
20
|
+
def self.for(wrapped_options, (ctx, flow_options), **circuit_options) # TODO: remove
|
21
21
|
implementation.build(wrapped_options, {}, [ctx, flow_options], circuit_options)
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.for_circuit(wrapped_options, mutable_options, (ctx, flow_options), circuit_options)
|
24
|
+
def self.for_circuit(wrapped_options, mutable_options, (ctx, flow_options), **circuit_options)
|
25
25
|
context_class = flow_options[:context_class] || implementation # Context::IndifferentAccess
|
26
26
|
|
27
27
|
context_class.build(wrapped_options, mutable_options, [ctx, flow_options], circuit_options)
|
@@ -8,12 +8,14 @@ module Trailblazer
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def [](key)
|
11
|
-
return super unless aka = @aliases[key] # yepp, nil/false won't work
|
11
|
+
return super unless (aka = @aliases[key]) # yepp, nil/false won't work
|
12
|
+
|
12
13
|
super(aka)
|
13
14
|
end
|
14
15
|
|
15
16
|
def key?(key)
|
16
|
-
return super unless aka = @aliases[key] # yepp, nil/false won't work
|
17
|
+
return super unless (aka = @aliases[key]) # yepp, nil/false won't work
|
18
|
+
|
17
19
|
super(aka)
|
18
20
|
end
|
19
21
|
|
@@ -12,7 +12,7 @@ module Trailblazer
|
|
12
12
|
@wrapped_options[name.to_s]
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.build(wrapped_options, mutable_options, (
|
15
|
+
def self.build(wrapped_options, mutable_options, (_ctx, flow_options), **)
|
16
16
|
new(wrapped_options, mutable_options, flow_options)
|
17
17
|
end
|
18
18
|
end
|
@@ -24,11 +24,14 @@ module Trailblazer
|
|
24
24
|
|
25
25
|
include Aliasing # FIXME
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
|
28
|
+
class << self
|
29
|
+
# This also builds IndifferentAccess::Aliasing.
|
30
|
+
# The {#build} method is designed to take all args from {for_circuit} and then
|
31
|
+
# translate that to the constructor.
|
32
|
+
def build(wrapped_options, mutable_options, (_ctx, flow_options), **)
|
33
|
+
new(wrapped_options, mutable_options, **flow_options)
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
data/lib/trailblazer/option.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
1
|
module Trailblazer
|
2
|
-
# @note This might go to trailblazer-args along with `Context` at some point.
|
3
|
-
def self.Option(proc)
|
4
|
-
Option.build(Option, proc)
|
5
|
-
end
|
6
|
-
|
7
2
|
class Option
|
8
|
-
# Generic builder for a callable "option".
|
9
|
-
# @param call_implementation [Class, Module] implements the process of calling the proc
|
10
|
-
# while passing arguments/options to it in a specific style (e.g. kw args, step interface).
|
11
|
-
# @return [Proc] when called, this proc will evaluate its option (at run-time).
|
12
|
-
def self.build(call_implementation, proc)
|
13
|
-
if proc.is_a? Symbol
|
14
|
-
->(*args, &block) { call_implementation.evaluate_method(proc, *args, &block) }
|
15
|
-
else
|
16
|
-
->(*args, &block) { call_implementation.evaluate_callable(proc, *args, &block) }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
3
|
# A call implementation invoking `proc.(*args)` and plainly forwarding all arguments.
|
21
4
|
# Override this for your own step strategy (see KW#call!).
|
22
5
|
# @private
|
@@ -27,16 +10,28 @@ module Trailblazer
|
|
27
10
|
# Note that both #evaluate_callable and #evaluate_method drop most of the args.
|
28
11
|
# If you need those, override this class.
|
29
12
|
# @private
|
30
|
-
def self.evaluate_callable(proc, *args,
|
13
|
+
def self.evaluate_callable(proc, *args, **, &block)
|
31
14
|
call!(proc, *args, &block)
|
32
15
|
end
|
33
16
|
|
34
17
|
# Make the context's instance method a "lambda" and reuse #call!.
|
35
18
|
# @private
|
36
|
-
def self.evaluate_method(proc, *args, exec_context: raise("No :exec_context given."),
|
19
|
+
def self.evaluate_method(proc, *args, exec_context: raise("No :exec_context given."), **, &block)
|
37
20
|
call!(exec_context.method(proc), *args, &block)
|
38
21
|
end
|
39
22
|
|
23
|
+
# Generic builder for a callable "option".
|
24
|
+
# @param call_implementation [Class, Module] implements the process of calling the proc
|
25
|
+
# while passing arguments/options to it in a specific style (e.g. kw args, step interface).
|
26
|
+
# @return [Proc] when called, this proc will evaluate its option (at run-time).
|
27
|
+
def self.build(call_implementation, proc)
|
28
|
+
if proc.is_a? Symbol
|
29
|
+
->(*args, &block) { call_implementation.evaluate_method(proc, *args, &block) }
|
30
|
+
else
|
31
|
+
->(*args, &block) { call_implementation.evaluate_callable(proc, *args, &block) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
40
35
|
# Returns a {Proc} that, when called, invokes the `proc` argument with keyword arguments.
|
41
36
|
# This is known as "step (call) interface".
|
42
37
|
#
|
@@ -75,4 +70,8 @@ module Trailblazer
|
|
75
70
|
end
|
76
71
|
end
|
77
72
|
end
|
73
|
+
# @note This might go to trailblazer-args along with `Context` at some point.
|
74
|
+
def self.Option(proc)
|
75
|
+
Option.build(Option, proc)
|
76
|
+
end
|
78
77
|
end
|
data/test/context_test.rb
CHANGED
@@ -2,8 +2,6 @@ require "test_helper"
|
|
2
2
|
require "trailblazer/container_chain"
|
3
3
|
|
4
4
|
class ArgsTest < Minitest::Spec
|
5
|
-
Context = Trailblazer::Context
|
6
|
-
|
7
5
|
let(:immutable) { {repository: "User"} }
|
8
6
|
|
9
7
|
let(:ctx) { Trailblazer::Context(immutable) }
|
@@ -16,16 +14,16 @@ class ArgsTest < Minitest::Spec
|
|
16
14
|
# options[] and options[]=
|
17
15
|
ctx[:model] = Module
|
18
16
|
ctx[:contract] = Integer
|
19
|
-
ctx[:model] .must_equal Module
|
20
|
-
ctx[:contract].must_equal Integer
|
17
|
+
_(ctx[:model]) .must_equal Module
|
18
|
+
_(ctx[:contract]).must_equal Integer
|
21
19
|
|
22
20
|
# it { }
|
23
|
-
immutable.inspect.must_equal %({:repository=>\"User\"})
|
21
|
+
_(immutable.inspect).must_equal %({:repository=>\"User\"})
|
24
22
|
end
|
25
23
|
|
26
24
|
it "allows false/nil values" do
|
27
25
|
ctx["x"] = false
|
28
|
-
ctx["x"].must_equal false
|
26
|
+
_(ctx["x"]).must_equal false
|
29
27
|
|
30
28
|
ctx["x"] = nil
|
31
29
|
assert_nil ctx["x"]
|
@@ -36,7 +34,7 @@ class ArgsTest < Minitest::Spec
|
|
36
34
|
ctx = Trailblazer::Context(immutable)
|
37
35
|
|
38
36
|
# it { }
|
39
|
-
ctx.to_hash.must_equal(repository: "User")
|
37
|
+
_(ctx.to_hash).must_equal(repository: "User")
|
40
38
|
|
41
39
|
# last added has precedence.
|
42
40
|
# only symbol keys.
|
@@ -44,7 +42,7 @@ class ArgsTest < Minitest::Spec
|
|
44
42
|
ctx[:a] = Symbol
|
45
43
|
ctx["a"] = String
|
46
44
|
|
47
|
-
ctx.to_hash.must_equal(repository: "User", a: String)
|
45
|
+
_(ctx.to_hash).must_equal(repository: "User", a: String)
|
48
46
|
end
|
49
47
|
|
50
48
|
describe "#merge" do
|
@@ -53,8 +51,8 @@ class ArgsTest < Minitest::Spec
|
|
53
51
|
|
54
52
|
merged = ctx.merge(current_user: Module)
|
55
53
|
|
56
|
-
merged.to_hash.must_equal(repository: "User", current_user: Module)
|
57
|
-
ctx.to_hash.must_equal(repository: "User")
|
54
|
+
_(merged.to_hash).must_equal(repository: "User", current_user: Module)
|
55
|
+
_(ctx.to_hash).must_equal(repository: "User")
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -75,50 +73,50 @@ class ContextWithIndifferentAccessTest < Minitest::Spec
|
|
75
73
|
|
76
74
|
immutable = {model: Object, "policy" => Hash}
|
77
75
|
|
78
|
-
ctx = Trailblazer::Context.for_circuit(immutable, {}, [immutable, flow_options], circuit_options)
|
76
|
+
ctx = Trailblazer::Context.for_circuit(immutable, {}, [immutable, flow_options], **circuit_options)
|
79
77
|
|
80
|
-
ctx[:model].must_equal Object
|
81
|
-
ctx["model"].must_equal Object
|
82
|
-
ctx[:policy].must_equal Hash
|
83
|
-
ctx["policy"].must_equal Hash
|
78
|
+
_(ctx[:model]).must_equal Object
|
79
|
+
_(ctx["model"]).must_equal Object
|
80
|
+
_(ctx[:policy]).must_equal Hash
|
81
|
+
_(ctx["policy"]).must_equal Hash
|
84
82
|
|
85
83
|
ctx["contract.default"] = Module
|
86
|
-
ctx["contract.default"].must_equal Module
|
87
|
-
ctx[:"contract.default"].must_equal Module
|
84
|
+
_(ctx["contract.default"]).must_equal Module
|
85
|
+
_(ctx[:"contract.default"]).must_equal Module
|
88
86
|
|
89
87
|
# key?
|
90
|
-
ctx.key?("____contract.default").must_equal false
|
91
|
-
ctx.key?("contract.default").must_equal true
|
92
|
-
ctx.key?(:"contract.default").must_equal true
|
88
|
+
_(ctx.key?("____contract.default")).must_equal false
|
89
|
+
_(ctx.key?("contract.default")).must_equal true
|
90
|
+
_(ctx.key?(:"contract.default")).must_equal true
|
93
91
|
|
94
92
|
# context in context
|
95
|
-
ctx2 = Trailblazer::Context.for_circuit(ctx, {}, [ctx, flow_options], circuit_options)
|
93
|
+
ctx2 = Trailblazer::Context.for_circuit(ctx, {}, [ctx, flow_options], **circuit_options)
|
96
94
|
|
97
|
-
ctx2[:model].must_equal Object
|
98
|
-
ctx2["model"].must_equal Object
|
95
|
+
_(ctx2[:model]).must_equal Object
|
96
|
+
_(ctx2["model"]).must_equal Object
|
99
97
|
|
100
98
|
ctx2["contract.default"] = Class
|
101
|
-
ctx2["contract.default"].must_equal Class
|
102
|
-
ctx2[:"contract.default"].must_equal Class
|
99
|
+
_(ctx2["contract.default"]).must_equal Class
|
100
|
+
_(ctx2[:"contract.default"]).must_equal Class
|
103
101
|
|
104
102
|
# key?
|
105
|
-
ctx2.key?("contract.default").must_equal true
|
106
|
-
ctx2.key?(:"contract.default").must_equal true
|
107
|
-
ctx2.key?("model").must_equal true
|
103
|
+
_(ctx2.key?("contract.default")).must_equal true
|
104
|
+
_(ctx2.key?(:"contract.default")).must_equal true
|
105
|
+
_(ctx2.key?("model")).must_equal true
|
108
106
|
|
109
107
|
# wrapped ctx doesn't change
|
110
|
-
ctx["contract.default"].must_equal Module
|
111
|
-
ctx[:"contract.default"].must_equal Module
|
108
|
+
_(ctx["contract.default"]).must_equal Module
|
109
|
+
_(ctx[:"contract.default"]).must_equal Module
|
112
110
|
|
113
111
|
|
114
112
|
ctx3 = ctx.merge("result" => false)
|
115
113
|
|
116
|
-
ctx3["contract.default"].must_equal Module
|
117
|
-
ctx3[:"contract.default"].must_equal Module
|
118
|
-
ctx3["result"].must_equal false
|
119
|
-
ctx3[:result].must_equal false
|
120
|
-
ctx3.key?("result").must_equal true
|
121
|
-
ctx3.key?(:result).must_equal true
|
114
|
+
_(ctx3["contract.default"]).must_equal Module
|
115
|
+
_(ctx3[:"contract.default"]).must_equal Module
|
116
|
+
_(ctx3["result"]).must_equal false
|
117
|
+
_(ctx3[:result]).must_equal false
|
118
|
+
_(ctx3.key?("result")).must_equal true
|
119
|
+
_(ctx3.key?(:result)).must_equal true
|
122
120
|
end
|
123
121
|
|
124
122
|
it "Aliasable" do
|
@@ -127,65 +125,65 @@ class ContextWithIndifferentAccessTest < Minitest::Spec
|
|
127
125
|
|
128
126
|
immutable = {model: Object, "policy" => Hash}
|
129
127
|
|
130
|
-
ctx = Trailblazer::Context.for_circuit(immutable, {}, [immutable, flow_options], circuit_options)
|
128
|
+
ctx = Trailblazer::Context.for_circuit(immutable, {}, [immutable, flow_options], **circuit_options)
|
131
129
|
|
132
|
-
ctx[:model].must_equal Object
|
133
|
-
ctx["model"].must_equal Object
|
134
|
-
ctx[:policy].must_equal Hash
|
135
|
-
ctx["policy"].must_equal Hash
|
130
|
+
_(ctx[:model]).must_equal Object
|
131
|
+
_(ctx["model"]).must_equal Object
|
132
|
+
_(ctx[:policy]).must_equal Hash
|
133
|
+
_(ctx["policy"]).must_equal Hash
|
136
134
|
|
137
135
|
ctx["contract.default"] = Module
|
138
|
-
ctx["contract.default"].must_equal Module
|
139
|
-
ctx[:"contract.default"].must_equal Module
|
136
|
+
_(ctx["contract.default"]).must_equal Module
|
137
|
+
_(ctx[:"contract.default"]).must_equal Module
|
140
138
|
|
141
139
|
# alias
|
142
|
-
ctx[:result]
|
143
|
-
ctx["result"]
|
140
|
+
assert_nil ctx[:result]
|
141
|
+
assert_nil ctx["result"]
|
144
142
|
|
145
|
-
ctx[:contract].must_equal Module
|
143
|
+
_(ctx[:contract]).must_equal Module
|
146
144
|
|
147
|
-
ctx[:stack]
|
145
|
+
assert_nil ctx[:stack]
|
148
146
|
|
149
147
|
# Set an aliased property via setter
|
150
148
|
ctx["trace.stack"] = Object
|
151
|
-
ctx[:stack].must_equal Object
|
152
|
-
ctx["trace.stack"].must_equal Object
|
149
|
+
_(ctx[:stack]).must_equal Object
|
150
|
+
_(ctx["trace.stack"]).must_equal Object
|
153
151
|
|
154
152
|
# key?
|
155
|
-
ctx.key?("____contract.default").must_equal false
|
156
|
-
ctx.key?("contract.default").must_equal true
|
157
|
-
ctx.key?(:"contract.default").must_equal true
|
158
|
-
ctx.key?(:contract).must_equal true
|
159
|
-
ctx.key?(:result).must_equal false
|
160
|
-
ctx.key?(:stack).must_equal true
|
161
|
-
ctx.key?("trace.stack").must_equal true
|
162
|
-
ctx.key?(:"trace.stack").must_equal true
|
153
|
+
_(ctx.key?("____contract.default")).must_equal false
|
154
|
+
_(ctx.key?("contract.default")).must_equal true
|
155
|
+
_(ctx.key?(:"contract.default")).must_equal true
|
156
|
+
_(ctx.key?(:contract)).must_equal true
|
157
|
+
_(ctx.key?(:result)).must_equal false
|
158
|
+
_(ctx.key?(:stack)).must_equal true
|
159
|
+
_(ctx.key?("trace.stack")).must_equal true
|
160
|
+
_(ctx.key?(:"trace.stack")).must_equal true
|
163
161
|
|
164
162
|
# to_hash
|
165
|
-
ctx.to_hash.must_equal(:model=>Object, :policy=>Hash, :"contract.default"=>Module, :"trace.stack"=>Object, :contract=>Module, :stack=>Object)
|
163
|
+
_(ctx.to_hash).must_equal(:model=>Object, :policy=>Hash, :"contract.default"=>Module, :"trace.stack"=>Object, :contract=>Module, :stack=>Object)
|
166
164
|
|
167
165
|
# context in context
|
168
|
-
ctx2 = Trailblazer::Context.for_circuit(ctx, {}, [ctx, flow_options], circuit_options)
|
169
|
-
|
170
|
-
ctx2.key?("____contract.default").must_equal false
|
171
|
-
ctx2.key?("contract.default").must_equal true
|
172
|
-
ctx2.key?(:"contract.default").must_equal true
|
173
|
-
ctx2.key?(:contract).must_equal true
|
174
|
-
ctx2.key?(:result).must_equal false
|
175
|
-
ctx2.key?("result.default").must_equal false
|
176
|
-
ctx2.key?(:stack).must_equal true
|
177
|
-
ctx2.key?("trace.stack").must_equal true
|
178
|
-
ctx2.key?(:"trace.stack").must_equal true
|
166
|
+
ctx2 = Trailblazer::Context.for_circuit(ctx, {}, [ctx, flow_options], **circuit_options)
|
167
|
+
|
168
|
+
_(ctx2.key?("____contract.default")).must_equal false
|
169
|
+
_(ctx2.key?("contract.default")).must_equal true
|
170
|
+
_(ctx2.key?(:"contract.default")).must_equal true
|
171
|
+
_(ctx2.key?(:contract)).must_equal true
|
172
|
+
_(ctx2.key?(:result)).must_equal false
|
173
|
+
_(ctx2.key?("result.default")).must_equal false
|
174
|
+
_(ctx2.key?(:stack)).must_equal true
|
175
|
+
_(ctx2.key?("trace.stack")).must_equal true
|
176
|
+
_(ctx2.key?(:"trace.stack")).must_equal true
|
179
177
|
|
180
178
|
# Set aliased in new context via setter
|
181
179
|
ctx2["result.default"] = Class
|
182
180
|
|
183
|
-
ctx2[:result].must_equal Class
|
184
|
-
ctx2[:"result.default"].must_equal Class
|
181
|
+
_(ctx2[:result]).must_equal Class
|
182
|
+
_(ctx2[:"result.default"]).must_equal Class
|
185
183
|
|
186
|
-
ctx2.key?("result.default").must_equal true
|
187
|
-
ctx2.key?(:"result.default").must_equal true
|
188
|
-
ctx2.key?(:result).must_equal true
|
184
|
+
_(ctx2.key?("result.default")).must_equal true
|
185
|
+
_(ctx2.key?(:"result.default")).must_equal true
|
186
|
+
_(ctx2.key?(:result)).must_equal true
|
189
187
|
|
190
188
|
# todo: TEST flow_options={context_class: SomethingElse}
|
191
189
|
end
|
@@ -196,17 +194,17 @@ class ContextWithIndifferentAccessTest < Minitest::Spec
|
|
196
194
|
# {Aliasing#initialize}
|
197
195
|
ctx = Trailblazer::Context::IndifferentAccess.new(immutable, {}, context_alias: {"policy.default" => :policy})
|
198
196
|
|
199
|
-
ctx[:model].must_equal Object
|
200
|
-
ctx["model"].must_equal Object
|
201
|
-
ctx[:policy].must_equal Hash
|
197
|
+
_(ctx[:model]).must_equal Object
|
198
|
+
_(ctx["model"]).must_equal Object
|
199
|
+
_(ctx[:policy]).must_equal Hash
|
202
200
|
|
203
201
|
ctx2 = ctx.merge(result: :success)
|
204
202
|
|
205
203
|
|
206
|
-
ctx2[:model].must_equal Object
|
207
|
-
ctx2["model"].must_equal Object
|
208
|
-
ctx2[:policy].must_equal Hash
|
209
|
-
ctx2[:result].must_equal :success
|
204
|
+
_(ctx2[:model]).must_equal Object
|
205
|
+
_(ctx2["model"]).must_equal Object
|
206
|
+
_(ctx2[:policy]).must_equal Hash
|
207
|
+
_(ctx2[:result]).must_equal :success
|
210
208
|
end
|
211
209
|
end
|
212
210
|
|
data/test/option_test.rb
CHANGED
@@ -2,10 +2,10 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
class OptionTest < Minitest::Spec
|
4
4
|
def assert_result(result, block = nil)
|
5
|
-
result.must_equal([{a: 1}, 2, {b: 3}, block])
|
5
|
+
_(result).must_equal([{a: 1}, 2, {b: 3}, block])
|
6
6
|
|
7
|
-
positional.inspect.must_equal %({:a=>1})
|
8
|
-
keywords.inspect.must_equal %({:a=>2, :b=>3})
|
7
|
+
_(positional.inspect).must_equal %({:a=>1})
|
8
|
+
_(keywords.inspect).must_equal %({:a=>2, :b=>3})
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "positional and kws" do
|
@@ -79,8 +79,8 @@ class OptionTest < Minitest::Spec
|
|
79
79
|
|
80
80
|
describe "positionals" do
|
81
81
|
def assert_result_pos(result)
|
82
|
-
result.must_equal([1, 2, [3, 4]])
|
83
|
-
positionals.must_equal [1, 2, 3, 4]
|
82
|
+
_(result).must_equal([1, 2, [3, 4]])
|
83
|
+
_(positionals).must_equal [1, 2, 3, 4]
|
84
84
|
end
|
85
85
|
|
86
86
|
class Step
|
@@ -124,7 +124,7 @@ class OptionTest < Minitest::Spec
|
|
124
124
|
|
125
125
|
describe "Option::KW" do
|
126
126
|
def assert_result_kws(result)
|
127
|
-
result.must_equal([{a: 1, b: 2, c: 3}, 1, 2, {c: 3}])
|
127
|
+
_(result).must_equal([{a: 1, b: 2, c: 3}, 1, 2, {c: 3}])
|
128
128
|
end
|
129
129
|
|
130
130
|
class Step
|
data/test/test_helper.rb
CHANGED
data/trailblazer-context.gemspec
CHANGED
@@ -23,8 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
25
|
spec.add_development_dependency "rake"
|
26
|
-
spec.add_development_dependency "rubocop"
|
27
26
|
|
28
27
|
# maybe we could remove this?
|
29
|
-
spec.required_ruby_version = ">= 2.
|
28
|
+
spec.required_ruby_version = ">= 2.1.0"
|
30
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
description: Argument-specific data structures for Trailblazer such as Context, Option
|
70
56
|
and ContainerChain.
|
71
57
|
email:
|
@@ -75,8 +61,6 @@ extensions: []
|
|
75
61
|
extra_rdoc_files: []
|
76
62
|
files:
|
77
63
|
- ".gitignore"
|
78
|
-
- ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
|
79
|
-
- ".rubocop.yml"
|
80
64
|
- ".travis.yml"
|
81
65
|
- CHANGES.md
|
82
66
|
- Gemfile
|
@@ -106,15 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
90
|
requirements:
|
107
91
|
- - ">="
|
108
92
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
93
|
+
version: 2.1.0
|
110
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
95
|
requirements:
|
112
96
|
- - ">="
|
113
97
|
- !ruby/object:Gem::Version
|
114
98
|
version: '0'
|
115
99
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 2.7.3
|
100
|
+
rubygems_version: 3.0.3
|
118
101
|
signing_key:
|
119
102
|
specification_version: 4
|
120
103
|
summary: Argument-specific data structures for Trailblazer.
|
@@ -1,136 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5.0
|
3
|
-
DisplayCopNames: true
|
4
|
-
Layout/CaseIndentation:
|
5
|
-
IndentOneStep: true
|
6
|
-
Layout/FirstArrayElementLineBreak:
|
7
|
-
Enabled: true
|
8
|
-
Layout/FirstHashElementLineBreak:
|
9
|
-
Enabled: true
|
10
|
-
Layout/FirstMethodArgumentLineBreak:
|
11
|
-
Enabled: true
|
12
|
-
Layout/FirstMethodParameterLineBreak:
|
13
|
-
Enabled: true
|
14
|
-
Layout/MultilineAssignmentLayout:
|
15
|
-
Enabled: true
|
16
|
-
EnforcedStyle: same_line
|
17
|
-
Layout/SpaceInsideHashLiteralBraces:
|
18
|
-
EnforcedStyle: no_space
|
19
|
-
Metrics/LineLength:
|
20
|
-
Max: 130
|
21
|
-
Metrics/ParameterLists:
|
22
|
-
Max: 5
|
23
|
-
Naming/VariableNumber:
|
24
|
-
EnforcedStyle: snake_case
|
25
|
-
Style/AndOr:
|
26
|
-
EnforcedStyle: conditionals
|
27
|
-
Style/AutoResourceCleanup:
|
28
|
-
Enabled: true
|
29
|
-
Style/CollectionMethods:
|
30
|
-
Enabled: true
|
31
|
-
Style/Documentation:
|
32
|
-
Enabled: false
|
33
|
-
Style/EmptyLiteral:
|
34
|
-
Enabled: false
|
35
|
-
Style/EmptyMethod:
|
36
|
-
EnforcedStyle: expanded
|
37
|
-
Style/FormatStringToken:
|
38
|
-
EnforcedStyle: template
|
39
|
-
Style/ImplicitRuntimeError:
|
40
|
-
Enabled: true
|
41
|
-
Style/MethodCalledOnDoEndBlock:
|
42
|
-
Enabled: true
|
43
|
-
Style/MethodDefParentheses:
|
44
|
-
EnforcedStyle: require_parentheses
|
45
|
-
Style/MissingElse:
|
46
|
-
Enabled: true
|
47
|
-
EnforcedStyle: case
|
48
|
-
Style/NumericLiterals:
|
49
|
-
Enabled: false
|
50
|
-
Style/OptionHash:
|
51
|
-
Enabled: true
|
52
|
-
Style/PercentLiteralDelimiters:
|
53
|
-
PreferredDelimiters:
|
54
|
-
"%w": "[]"
|
55
|
-
"%W": "[]"
|
56
|
-
"%i": "[]"
|
57
|
-
"%I": "[]"
|
58
|
-
"%r": "()"
|
59
|
-
Style/ReturnNil:
|
60
|
-
Enabled: true
|
61
|
-
Style/SafeNavigation:
|
62
|
-
Enabled: false
|
63
|
-
Style/Send:
|
64
|
-
Enabled: true
|
65
|
-
Style/SignalException:
|
66
|
-
EnforcedStyle: semantic
|
67
|
-
Style/StringLiterals:
|
68
|
-
EnforcedStyle: double_quotes
|
69
|
-
Style/StringLiteralsInInterpolation:
|
70
|
-
EnforcedStyle: double_quotes
|
71
|
-
Style/StringMethods:
|
72
|
-
Enabled: true
|
73
|
-
Style/SymbolArray:
|
74
|
-
Enabled: true
|
75
|
-
# this allows in rspec to have expect { } with multiple lines
|
76
|
-
Style/BlockDelimiters:
|
77
|
-
EnforcedStyle: braces_for_chaining
|
78
|
-
Layout/EndOfLine:
|
79
|
-
Enabled: false
|
80
|
-
# don't need these checks in test folders
|
81
|
-
Metrics/ModuleLength:
|
82
|
-
Exclude:
|
83
|
-
- "spec/**/*"
|
84
|
-
- "test/**/*"
|
85
|
-
Metrics/BlockLength:
|
86
|
-
Exclude:
|
87
|
-
- "spec/**/*"
|
88
|
-
- "test/**/*"
|
89
|
-
- "*.gemspec" # definitely not in the gemspec
|
90
|
-
Metrics/MethodLength:
|
91
|
-
Max: 20
|
92
|
-
Lint/UnreachableCode:
|
93
|
-
Description: 'Unreachable code.'
|
94
|
-
Enabled: false
|
95
|
-
Lint/Void:
|
96
|
-
Enabled: false
|
97
|
-
Layout/AlignHash:
|
98
|
-
EnforcedLastArgumentHashStyle: ignore_implicit
|
99
|
-
Metrics/AbcSize:
|
100
|
-
Max: 25
|
101
|
-
Style/LambdaCall:
|
102
|
-
Enabled: false
|
103
|
-
Style/Semicolon:
|
104
|
-
Enabled: false
|
105
|
-
Naming/UncommunicativeMethodParamName:
|
106
|
-
Enabled: false
|
107
|
-
Style/ClassAndModuleChildren:
|
108
|
-
Enabled: false
|
109
|
-
Layout/LeadingCommentSpace:
|
110
|
-
Exclude:
|
111
|
-
- 'test/docs/**/*'
|
112
|
-
Layout/AlignHash:
|
113
|
-
EnforcedHashRocketStyle: table
|
114
|
-
Style/FrozenStringLiteralComment:
|
115
|
-
Enabled: false
|
116
|
-
Layout/AlignHash:
|
117
|
-
EnforcedColonStyle: table
|
118
|
-
SingleLineMethods:
|
119
|
-
Enabled: false
|
120
|
-
Style/Lambda:
|
121
|
-
EnforcedStyle: literal
|
122
|
-
Style/AsciiComments:
|
123
|
-
Enabled: false
|
124
|
-
Style/CollectionMethods:
|
125
|
-
Enabled: false
|
126
|
-
Style/RedundantReturn:
|
127
|
-
Enabled: false
|
128
|
-
Style/PercentLiteralDelimiters:
|
129
|
-
PreferredDelimiters:
|
130
|
-
default: {}
|
131
|
-
"%q": '()'
|
132
|
-
"%r": '{}'
|
133
|
-
"%w": '[]'
|
134
|
-
"%": '{}'
|
135
|
-
Style/HashSyntax:
|
136
|
-
Enabled: false
|
data/.rubocop.yml
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.2
|
3
|
-
|
4
|
-
inherit_from:
|
5
|
-
- https://raw.githubusercontent.com/trailblazer/meta/master/rubocop.yml
|
6
|
-
|
7
|
-
Lint/UnusedMethodArgument:
|
8
|
-
Exclude:
|
9
|
-
- 'lib/trailblazer/option.rb'
|
10
|
-
|
11
|
-
Metrics/ClassLength:
|
12
|
-
Exclude:
|
13
|
-
- 'test/**'
|
14
|
-
|
15
|
-
Style/ImplicitRuntimeError:
|
16
|
-
Exclude:
|
17
|
-
- 'lib/trailblazer/option.rb'
|
18
|
-
|
19
|
-
Naming/UncommunicativeMethodParamName:
|
20
|
-
Exclude:
|
21
|
-
- 'test/option_test.rb'
|
22
|
-
|
23
|
-
Style/ClassAndModuleChildren:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
# wants to use map instead of collect
|
27
|
-
Style/CollectionMethods:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
# wants to use fail instea of raise
|
31
|
-
Style/SignalException:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
# because in gemspec we say >= 2.0.0 wants to have 2.0 as target ruby version here but
|
35
|
-
# it's not supported anymore from rubocop
|
36
|
-
Gemspec/RequiredRubyVersion:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
Style/Lambda:
|
40
|
-
EnforcedStyle: literal
|