trailblazer-activity 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65286a1dcb00e4928ebad6db7bdfd52eaaeb225436a715ea3b1c15d142b15819
4
- data.tar.gz: 1bed34667414ac73686040941fbd17e37f2963b46366b98fd6e8b323bbea0563
3
+ metadata.gz: be148af716c8a5bd21b666b22bf75bf2210854b4c710cfa69a26505b1725710d
4
+ data.tar.gz: 39f836d460d3dae33f9905103b4f6efdd57049ebdc9290ed21e441cefd0cb9dd
5
5
  SHA512:
6
- metadata.gz: 52ce7e8fc9500aa1646852f653e68cbe86f06ec8327bcb1b833ba00b838694999495a0b98822bacd3ee88616fd5fb3d46af41a4144429bd1fb8c08df282407d7
7
- data.tar.gz: 74cc1e25042edca7c358ec783a0bb79af2d56f975076c6bfb68cde2df5ed09af058ca84d963602ffaa9e1683a65234e82059db8eface16445848975be0712ecf
6
+ metadata.gz: 1dc6d49f7436922ea378c4af9604242dec98ff08aa29d5c2f156b7569cbf2e2704380f6050a659dec7d9f28471d3194b3c2c4bd61ef4dfecf3657d1e6a98dfbc
7
+ data.tar.gz: 8b214a0952c72650665bd2413254d526bbab9fce4920b3b2fa25aced774994ca49a96bed66ef1ef4d6adc09c63d78ef604abef94205d1ee5edb09bcd544d66fe
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.7.0
2
+
3
+ * Remove `DSL::Helper`, "helper" methods now sit directly in the `DSL` namespace.
4
+
1
5
  # 0.6.2
2
6
 
3
7
  * Allow all `Option` types for input/output.
@@ -38,7 +38,7 @@ module Trailblazer
38
38
  module DSLHelper
39
39
  extend Forwardable
40
40
  def_delegators :@builder, :Path
41
- def_delegators DSL::Helper, :Output, :End, :Subprocess, :Track
41
+ def_delegators DSL, :Output, :End, :Subprocess, :Track
42
42
 
43
43
  def Path(*args, &block)
44
44
  self[:builder].Path(*args, &block)
@@ -22,49 +22,47 @@ module Trailblazer
22
22
  end
23
23
 
24
24
  # Shortcut functions for the DSL. These have no state.
25
- module Helper
26
- module_function
25
+ module_function
27
26
 
28
- # Output( Left, :failure )
29
- # Output( :failure ) #=> Output::Semantic
30
- def Output(signal, semantic=nil)
31
- return OutputSemantic.new(signal) if semantic.nil?
27
+ # Output( Left, :failure )
28
+ # Output( :failure ) #=> Output::Semantic
29
+ def Output(signal, semantic=nil)
30
+ return OutputSemantic.new(signal) if semantic.nil?
32
31
 
33
- Activity.Output(signal, semantic)
34
- end
32
+ Activity.Output(signal, semantic)
33
+ end
35
34
 
36
- def End(semantic)
37
- Activity.End(semantic)
38
- end
35
+ def End(semantic)
36
+ Activity.End(semantic)
37
+ end
39
38
 
40
- def Track(color)
41
- Track.new(color).freeze
42
- end
39
+ def Track(color)
40
+ Track.new(color).freeze
41
+ end
43
42
 
44
- def Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options)
45
- options = options.merge(track_color: track_color, end_semantic: end_semantic)
43
+ def Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options)
44
+ options = options.merge(track_color: track_color, end_semantic: end_semantic)
46
45
 
47
- # Build an anonymous class which will be where the block is evaluated in.
48
- # We use the same normalizer here, so DSL calls in the inner block have the same behavior.
49
- path = Module.new do
50
- extend Activity::Path( options.merge( normalizer: normalizer ) )
51
- end
46
+ # Build an anonymous class which will be where the block is evaluated in.
47
+ # We use the same normalizer here, so DSL calls in the inner block have the same behavior.
48
+ path = Module.new do
49
+ extend Activity::Path( options.merge( normalizer: normalizer ) )
50
+ end
52
51
 
53
- # this block is called in DSL::ProcessTuples. This could be improved somehow.
54
- ->(block) {
55
- path.instance_exec(&block)
52
+ # this block is called in DSL::ProcessTuples. This could be improved somehow.
53
+ ->(block) {
54
+ path.instance_exec(&block)
56
55
 
57
- [ track_color, path ]
58
- }
59
- end
56
+ [ track_color, path ]
57
+ }
58
+ end
60
59
 
61
- # Computes the :outputs options for {activity}
62
- def Subprocess(activity)
63
- {
64
- task: activity,
65
- outputs: activity.outputs
66
- }
67
- end
60
+ # Computes the :outputs options for {activity}
61
+ def Subprocess(activity)
62
+ {
63
+ task: activity,
64
+ outputs: activity.outputs
65
+ }
68
66
  end
69
67
  end
70
68
  end
@@ -35,7 +35,7 @@ module Trailblazer
35
35
  #
36
36
  # Output(:success) => Path() {}
37
37
  def Path(*args)
38
- Activity::DSL::Helper.Path(@normalizer, *args)
38
+ Activity::DSL.Path(@normalizer, *args)
39
39
  end
40
40
 
41
41
  # Public top-level entry point.
@@ -19,6 +19,20 @@ class Trailblazer::Activity < Module
19
19
  ctx[:options] = options # without :input and :output
20
20
  ctx[:options] = options.merge(Trailblazer::Activity::TaskWrap::VariableMapping(io_config) => true)
21
21
  end
22
+
23
+ # The taskWrap extension that's included into the static taskWrap for a task.
24
+ def self.extension_for(input, output)
25
+ Trailblazer::Activity::DSL::Extension.new(
26
+ Merge.new(
27
+ Module.new do
28
+ extend Path::Plan()
29
+
30
+ task input, id: "task_wrap.input", before: "task_wrap.call_task"
31
+ task output, id: "task_wrap.output", before: "End.success", group: :end
32
+ end
33
+ )
34
+ )
35
+ end
22
36
  end
23
37
 
24
38
  # @private
@@ -30,6 +44,7 @@ class Trailblazer::Activity < Module
30
44
  end
31
45
  end
32
46
 
47
+
33
48
  # Returns an Extension instance to be thrown into the `step` DSL arguments.
34
49
  def self.VariableMapping(input:, output:)
35
50
  input = Input.new(
@@ -40,16 +55,7 @@ class Trailblazer::Activity < Module
40
55
  Output::Unscoped.new(
41
56
  Trailblazer::Option::KW( filter_for(output) ) ) )
42
57
 
43
- Trailblazer::Activity::DSL::Extension.new(
44
- Merge.new(
45
- Module.new do
46
- extend Path::Plan()
47
-
48
- task input, id: "task_wrap.input", before: "task_wrap.call_task"
49
- task output, id: "task_wrap.output", before: "End.success", group: :end
50
- end
51
- )
52
- )
58
+ VariableMapping.extension_for(input, output)
53
59
  end
54
60
 
55
61
  # TaskWrap step to compute the incoming {Context} for the wrapped task.
@@ -58,6 +64,8 @@ class Trailblazer::Activity < Module
58
64
  # Both Input and Output are typically to be added before and after task_wrap.call_task.
59
65
  #
60
66
  # @note Assumption: we always have :input _and_ :output, where :input produces a Context and :output decomposes it.
67
+
68
+ # Calls your {@filter} and replaces the original ctx with your returned one.
61
69
  class Input
62
70
  def initialize(filter)
63
71
  @filter = filter
@@ -67,7 +75,7 @@ class Trailblazer::Activity < Module
67
75
  #
68
76
  def call( (wrap_ctx, original_args), circuit_options )
69
77
  # let user compute new ctx for the wrapped task.
70
- input_ctx = apply_filter(*original_args) # FIXME: THIS SHOULD ALWAYS BE A _NEW_ Context.
78
+ input_ctx = apply_filter(*original_args)
71
79
 
72
80
  wrap_ctx = wrap_ctx.merge( vm_original_ctx: original_args[0][0] ) # remember the original ctx
73
81
 
@@ -119,13 +127,12 @@ class Trailblazer::Activity < Module
119
127
  @filter = filter
120
128
  end
121
129
 
122
- # Runs the user filter and replaces the ctx in `wrap_ctx[:return_args]` with the filtered one.
130
+ # Runs your filter and replaces the ctx in `wrap_ctx[:return_args]` with the filtered one.
123
131
  def call( (wrap_ctx, original_args), **circuit_options )
124
132
  (original_ctx, original_flow_options), original_circuit_options = original_args
125
133
 
126
134
  returned_ctx, _ = wrap_ctx[:return_args] # this is the Context returned from `call`ing the task.
127
135
  original_ctx = wrap_ctx[:vm_original_ctx]
128
-
129
136
  # let user compute the output.
130
137
  output_ctx = @filter.(original_ctx, returned_ctx, **original_circuit_options)
131
138
 
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  class Activity < Module
3
- VERSION = "0.6.2"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hirb