trailblazer-macro 2.1.0.beta6 → 2.1.0.beta7

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
2
  SHA256:
3
- metadata.gz: 00614cb0bcb127cf89ff6c1e199fa6fc8f080ac7492a41155adfb9c90a4b55bd
4
- data.tar.gz: 84d68e15a27452b1833679ff80f898f3158f908222ed2aa6a8fa288dc22b474d
3
+ metadata.gz: 8b28fce36bb1ae4a995432b091624dfc319e60a216c0ee277cba94b7f17fcdf1
4
+ data.tar.gz: f50322231cf78170aa11c57698ac3e7bd629c40f7961960d21f5ba0aca9144de
5
5
  SHA512:
6
- metadata.gz: c348fb564c7d873c716886c4764a7297d654acb1f31bfadc3568e5b2110ad01a3d6f12ade831db98c4ceae9e44a7fcd02a29ed8ab0aea533a6a546ab344d16f8
7
- data.tar.gz: cc6be5f0b0b0ec3f5499dcfaaa846e4ef0d9afb8aa818e7ccaf02798a997f0b796d396acd2de05be4a1f7de16e4da975f603cf1a9e859e4c6d8523575c8c38dc
6
+ metadata.gz: e0a7db056ec5573d1ad883387dd1d32a3c035d509aec54e023317d1e5061c73f88a098d13758d7fdbc4cc8101873ef4ad583ebef7116f9abd94fe7f5c1146f0a
7
+ data.tar.gz: d6ca9fc728a873a2f01ca832b4dbc4d21a48da02af2fe6a5d4790d11f267ad15f92b40f3b755ce71702d98e0055ae960dbafa0c9bd647493e05c90175430fa67
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.1.0.beta7
2
+
3
+ * Nested :input, :output now uses activity's VariableMapping.
4
+
1
5
  # 2.1.0.beta6
2
6
 
3
7
  * Use newest operation.
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  # gem "trailblazer", github: "trailblazer/trailblazer"
7
- # gem "trailblazer-activity", path: "../trailblazer-activity"
8
- # gem "trailblazer-operation", path: "../operation"
7
+ gem "trailblazer-activity", path: "../trailblazer-activity"
8
+ gem "trailblazer-operation", path: "../operation"
9
9
  # gem "trailblazer-activity"#, github: "trailblazer/trailblazer-activity"
10
10
  # gem "trailblazer-macro-contract", git: "https://github.com/trailblazer/trailblazer-macro-contract"
11
11
 
@@ -1,7 +1,6 @@
1
1
  require "trailblazer/operation"
2
2
 
3
3
  require "trailblazer/operation/inject"
4
- require "trailblazer/operation/input_output"
5
4
 
6
5
  require "trailblazer/operation/model"
7
6
  require "trailblazer/operation/policy"
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  module Macro
3
- VERSION = "2.1.0.beta6".freeze
3
+ VERSION = "2.1.0.beta7".freeze
4
4
  end
5
5
  end
@@ -2,33 +2,41 @@
2
2
  module Trailblazer
3
3
  class Operation
4
4
  # {Nested} macro.
5
- def self.Nested(callable, input:nil, output:nil, id: "Nested(#{callable})")
5
+ def self.Nested(callable, id: "Nested(#{callable})", input: nil, output: nil)
6
6
  task_wrap_extensions = Module.new do
7
7
  extend Activity::Path::Plan()
8
8
  end
9
9
 
10
- task, operation, is_dynamic = Nested.build(callable)
10
+ input_output = Nested.input_output_extensions_for(input, output) # TODO: deprecate this?
11
11
 
12
- # TODO: move this to the generic step DSL
13
- if input || output
14
- task_wrap_extensions = InputOutput.plan( input, output )
15
- end
12
+ task, operation, is_dynamic = Nested.build(callable)
16
13
 
17
14
  if is_dynamic
18
15
  task_wrap_extensions.task task.method(:compute_nested_activity), id: ".compute_nested_activity", after: "Start.default", group: :start
19
16
  task_wrap_extensions.task task.method(:compute_return_signal), id: ".compute_return_signal", after: "task_wrap.call_task"
20
17
  end
21
18
 
22
- {
19
+ options = {
23
20
  task: task,
24
21
  id: id,
25
22
  Trailblazer::Activity::DSL::Extension.new(Trailblazer::Activity::TaskWrap::Merge.new(task_wrap_extensions)) => true,
26
- outputs: operation.outputs
27
- }
23
+ outputs: operation.outputs,
24
+ }.merge(input_output)
28
25
  end
29
26
 
30
27
  # @private
31
28
  module Nested
29
+ def self.input_output_extensions_for(input, output)
30
+ return {} unless input || output
31
+
32
+ input = input || ->(original_ctx, **) { original_ctx }
33
+ output = output || ->(new_ctx, **) { new_ctx.decompose.last } # merges "mutable" part into original, since it's in Unscoped.
34
+
35
+ {
36
+ Activity::TaskWrap::VariableMapping(input: input, output: output) => true
37
+ }
38
+ end
39
+
32
40
  # DISCUSS: use builders here?
33
41
  def self.build(nested_operation)
34
42
  return dynamic = Dynamic.new(nested_operation), dynamic, true unless nestable_object?(nested_operation)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-macro
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.beta6
4
+ version: 2.1.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-03 00:00:00.000000000 Z
12
+ date: 2018-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -123,7 +123,6 @@ files:
123
123
  - lib/trailblazer/macro.rb
124
124
  - lib/trailblazer/macro/version.rb
125
125
  - lib/trailblazer/operation/guard.rb
126
- - lib/trailblazer/operation/input_output.rb
127
126
  - lib/trailblazer/operation/model.rb
128
127
  - lib/trailblazer/operation/nested.rb
129
128
  - lib/trailblazer/operation/policy.rb
@@ -1,28 +0,0 @@
1
- module Trailblazer
2
- # Add an input and output filter for a task, allowing to control what a task "sees"
3
- # (receives as input) and returns (or, what the outer caller "sees").
4
- #
5
- # This works by adding two variable mappers to the taskWrap.
6
- # One before the actual task gets called (input) and one before the end (output).
7
- module Operation::InputOutput
8
- # naming: Macaroni, VariableMapping
9
- def self.plan(input, output)
10
- default_input_filter = ->(options, *) { ctx = options }
11
- default_output_filter = ->(options, *) { options }
12
-
13
- input ||= default_input_filter
14
- output ||= default_output_filter
15
-
16
- input_filter = Activity::TaskWrap::Input.new(input)
17
- output_filter = Activity::TaskWrap::Output.new(output)
18
-
19
- # taskWrap extensions
20
- Module.new do
21
- extend Activity::Path::Plan()
22
-
23
- task input_filter, id: ".input", before: "task_wrap.call_task"
24
- task output_filter, id: ".output", before: "End.success", group: :end # DISCUSS: position
25
- end
26
- end
27
- end
28
- end