trailblazer-macro 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/Gemfile +3 -3
- data/lib/trailblazer/macro/guard.rb +3 -3
- data/lib/trailblazer/macro/nested.rb +2 -2
- data/lib/trailblazer/macro/version.rb +1 -1
- data/lib/trailblazer/macro/wrap.rb +1 -1
- data/test/docs/guard_test.rb +21 -0
- data/trailblazer-macro.gemspec +2 -3
- metadata +12 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d1d66ce0e6bf576b852792bdee95a0d67148cee1fbb21fdb791e83984154b1f
|
4
|
+
data.tar.gz: d274da669e987828fbfbf8b45b677d5596558e22e7729f882a35546fd3244e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10aac4d11e1b286e27101955722ff1ae581df1608dd268f40dcfb8a559db0b91f2cc2a0a72ace708a9a83f34ec3c55efb059d0117e3605df012fd81800714a84
|
7
|
+
data.tar.gz: 6227e472b59a584de223884a8111b7da5b43bfa3e5f07a5522caef1ff7cf765fb1801aff192f070214513d61cfe0d23b0c66cf2298e6532a9fb04dc6fd06efd0
|
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
@@ -5,11 +5,11 @@ gemspec
|
|
5
5
|
|
6
6
|
# gem "trailblazer", github: "trailblazer/trailblazer"
|
7
7
|
# gem "trailblazer-activity", path: "../trailblazer-activity"
|
8
|
-
# gem "trailblazer-activity-dsl-linear", github: "trailblazer/trailblazer-activity-dsl-linear", branch: 'master'
|
9
8
|
# gem "trailblazer-activity-dsl-linear", path: "../trailblazer-activity-dsl-linear"
|
10
|
-
# gem "trailblazer-operation", github: "trailblazer/trailblazer-operation", branch: 'linear'
|
11
|
-
# gem "trailblazer-activity"#, github: "trailblazer/trailblazer-activity"
|
12
9
|
# gem "trailblazer-macro-contract", git: "https://github.com/trailblazer/trailblazer-macro-contract"
|
10
|
+
# gem "trailblazer-context", path: "../trailblazer-context"
|
11
|
+
# gem "trailblazer-operation", path: "../trailblazer-operation"
|
12
|
+
|
13
13
|
|
14
14
|
gem "minitest-line"
|
15
15
|
gem "rubocop", require: false
|
@@ -6,11 +6,11 @@ module Trailblazer::Macro
|
|
6
6
|
|
7
7
|
module Guard
|
8
8
|
def self.build(callable)
|
9
|
-
option = Trailblazer::Option
|
9
|
+
option = Trailblazer::Option(callable)
|
10
10
|
|
11
11
|
# this gets wrapped in a Operation::Result object.
|
12
|
-
->((
|
13
|
-
Trailblazer::Operation::Result.new(!!option.call(
|
12
|
+
->((ctx, *), **circuit_args) do
|
13
|
+
Trailblazer::Operation::Result.new(!!option.call(ctx, keyword_arguments: ctx.to_hash, **circuit_args), {})
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -38,7 +38,7 @@ module Trailblazer
|
|
38
38
|
# This is what {Nested} in 2.0 used to do, where the outcome could only be true/false (or success/failure).
|
39
39
|
class Dynamic
|
40
40
|
def initialize(nested_activity_decider)
|
41
|
-
@nested_activity_decider = Option
|
41
|
+
@nested_activity_decider = Trailblazer::Option(nested_activity_decider)
|
42
42
|
|
43
43
|
@outputs = {
|
44
44
|
:success => Activity::Output(Activity::Railway::End::Success.new(semantic: :success), :success),
|
@@ -53,7 +53,7 @@ module Trailblazer
|
|
53
53
|
(ctx, _), original_circuit_options = original_args
|
54
54
|
|
55
55
|
# TODO: evaluate the option to get the actual "object" to call.
|
56
|
-
activity = @nested_activity_decider.(ctx, original_circuit_options)
|
56
|
+
activity = @nested_activity_decider.(ctx, keyword_arguments: ctx.to_hash, **original_circuit_options)
|
57
57
|
|
58
58
|
# Overwrite :task so task_wrap.call_task will call this activity.
|
59
59
|
# This is a trick so we don't have to repeat logic from #call_task here.
|
@@ -48,7 +48,7 @@ module Trailblazer
|
|
48
48
|
|
49
49
|
def call((ctx, flow_options), **circuit_options)
|
50
50
|
block_calling_wrapped = -> {
|
51
|
-
call_wrapped_activity([ctx, flow_options], circuit_options)
|
51
|
+
call_wrapped_activity([ctx, flow_options], **circuit_options)
|
52
52
|
}
|
53
53
|
|
54
54
|
# call the user's Wrap {} block in the operation.
|
data/test/docs/guard_test.rb
CHANGED
@@ -108,6 +108,27 @@ class DocsGuardNamedTest < Minitest::Spec
|
|
108
108
|
}
|
109
109
|
end
|
110
110
|
|
111
|
+
#---
|
112
|
+
# dependency injection
|
113
|
+
class DocsGuardInjectionTest < Minitest::Spec
|
114
|
+
#:di-op
|
115
|
+
class Create < Trailblazer::Operation
|
116
|
+
step Policy::Guard( ->(options, current_user:, **) { current_user == Module } )
|
117
|
+
end
|
118
|
+
#:di-op end
|
119
|
+
|
120
|
+
it { Create.(:current_user => Module).inspect("").must_equal %{<Result:true [nil] >} }
|
121
|
+
it {
|
122
|
+
result =
|
123
|
+
#:di-call
|
124
|
+
Create.(
|
125
|
+
:current_user => Module,
|
126
|
+
:"policy.default.eval" => Trailblazer::Operation::Policy::Guard.build(->(options, **) { false })
|
127
|
+
)
|
128
|
+
#:di-call end
|
129
|
+
result.inspect("").must_equal %{<Result:false [nil] >} }
|
130
|
+
end
|
131
|
+
|
111
132
|
#---
|
112
133
|
# missing current_user throws exception
|
113
134
|
class DocsGuardMissingKeywordTest < Minitest::Spec
|
data/trailblazer-macro.gemspec
CHANGED
@@ -25,9 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "roar"
|
26
26
|
spec.add_development_dependency "trailblazer-developer"
|
27
27
|
|
28
|
-
spec.add_dependency "trailblazer-activity", ">= 0.
|
29
|
-
spec.add_dependency "trailblazer-
|
30
|
-
spec.add_dependency "trailblazer-operation", ">= 0.6.5" # TODO: this dependency will be removed.
|
28
|
+
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.4.0", "< 0.5.0"
|
29
|
+
spec.add_dependency "trailblazer-operation", ">= 0.7.0" # TODO: this dependency will be removed.
|
31
30
|
|
32
31
|
spec.required_ruby_version = ">= 2.2.0"
|
33
32
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-macro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
- Marc Tich
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -95,60 +95,40 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: trailblazer-activity
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
101
|
-
requirements:
|
102
|
-
- - ">="
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
version: 0.11.2
|
105
|
-
- - "<"
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: 1.0.0
|
108
|
-
type: :runtime
|
109
|
-
prerelease: false
|
110
|
-
version_requirements: !ruby/object:Gem::Requirement
|
111
|
-
requirements:
|
112
|
-
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version: 0.11.2
|
115
|
-
- - "<"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 1.0.0
|
118
98
|
- !ruby/object:Gem::Dependency
|
119
99
|
name: trailblazer-activity-dsl-linear
|
120
100
|
requirement: !ruby/object:Gem::Requirement
|
121
101
|
requirements:
|
122
102
|
- - ">="
|
123
103
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
104
|
+
version: 0.4.0
|
125
105
|
- - "<"
|
126
106
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
107
|
+
version: 0.5.0
|
128
108
|
type: :runtime
|
129
109
|
prerelease: false
|
130
110
|
version_requirements: !ruby/object:Gem::Requirement
|
131
111
|
requirements:
|
132
112
|
- - ">="
|
133
113
|
- !ruby/object:Gem::Version
|
134
|
-
version: 0.
|
114
|
+
version: 0.4.0
|
135
115
|
- - "<"
|
136
116
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
117
|
+
version: 0.5.0
|
138
118
|
- !ruby/object:Gem::Dependency
|
139
119
|
name: trailblazer-operation
|
140
120
|
requirement: !ruby/object:Gem::Requirement
|
141
121
|
requirements:
|
142
122
|
- - ">="
|
143
123
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.
|
124
|
+
version: 0.7.0
|
145
125
|
type: :runtime
|
146
126
|
prerelease: false
|
147
127
|
version_requirements: !ruby/object:Gem::Requirement
|
148
128
|
requirements:
|
149
129
|
- - ">="
|
150
130
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0.
|
131
|
+
version: 0.7.0
|
152
132
|
description: Macros for Trailblazer's operation
|
153
133
|
email:
|
154
134
|
- apotonick@gmail.com
|
@@ -192,7 +172,7 @@ homepage: http://trailblazer.to
|
|
192
172
|
licenses:
|
193
173
|
- LGPL-3.0
|
194
174
|
metadata: {}
|
195
|
-
post_install_message:
|
175
|
+
post_install_message:
|
196
176
|
rdoc_options: []
|
197
177
|
require_paths:
|
198
178
|
- lib
|
@@ -207,8 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
187
|
- !ruby/object:Gem::Version
|
208
188
|
version: '0'
|
209
189
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
-
signing_key:
|
190
|
+
rubygems_version: 3.2.3
|
191
|
+
signing_key:
|
212
192
|
specification_version: 4
|
213
193
|
summary: 'Macros for Trailblazer''s operation: Policy, Wrap, Rescue and more.'
|
214
194
|
test_files:
|