trailblazer-activity-dsl-linear 0.2.3 → 0.2.4

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: c0cf822fabc3908a1f4d17cb3763de0e8207707fdca0fc70e8e044bb25648e2a
4
- data.tar.gz: f593d6ebf87bd6557412f0bb3416281393c8b2bdb65531f71fba8b3dca72e560
3
+ metadata.gz: e8dd3e02254b671396f311179af67026769e83716736abf5b760ea1ac149da89
4
+ data.tar.gz: 15cf93cb0c977ce2c7abd72d8f4e2866c79ff529e7bbb289a3f9baf8c7c2c350
5
5
  SHA512:
6
- metadata.gz: 46615d999f5352420c35ef394a747e2e5d1fdcaa6e66e73184ab6c05f3f3e2c1137f52f540914a4f6f96a928a0dc279f508a4cef662b1bbab135b32fcba8e9e3
7
- data.tar.gz: 2fc9847a11f5be34e940fcc489a53630835042ba6567b70440e1149f27e1a5dfcf3c284415c0be05e1ea431ab2f623e6c29176f6781222cabb103892a3442af9
6
+ metadata.gz: f26e85575fa37251c27f3c63d1ed0d172ad042153cbb10adcd790b627b51794f3f4f404c74cca4c5bbdf8dc5fe9aad0083db0ea4817cd1ac9356f4cc1824072d
7
+ data.tar.gz: ca25f0e7612524e6cbd1917e72a0c58256e4ab1f4e1c36232ab1c17c123c14637eda6891a881948812f0bbe6d4801e72cb03d22d699e16f80a655fea4ec463f9
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.4
2
+
3
+ * Add a minimal API for patching nested activities. This allows customizing deeply-nested activities without changing the original.
4
+
1
5
  # 0.2.3
2
6
 
3
7
  * Add `Strategy::invoke` which is a short-cut to `TaskWrap.invoke`. It's available as class method in all three strategies.
@@ -80,13 +80,39 @@ module Trailblazer
80
80
  end
81
81
 
82
82
  # Computes the {:outputs} options for {activity}.
83
- def Subprocess(activity)
83
+ def Subprocess(activity, path=[], patch=nil)
84
+ activity = Patch.(activity, path, patch) if path.any?
85
+
84
86
  {
85
87
  task: activity,
86
88
  outputs: Hash[activity.to_h[:outputs].collect { |output| [output.semantic, output] }]
87
89
  }
88
90
  end
89
91
 
92
+ module Patch
93
+ module_function
94
+
95
+ def call(activity, path, customization)
96
+ task_id, *path = path
97
+
98
+
99
+ patch =
100
+ if task_id
101
+ segment_activity = Introspect::Graph(activity).find(task_id).task
102
+ patched_segment_activity = call(segment_activity, path, customization)
103
+
104
+ # Replace the patched subprocess.
105
+ -> { step Subprocess(patched_segment_activity), replace: task_id, id: task_id }
106
+ else
107
+ customization # apply the *actual* patch from the Subprocess() call.
108
+ end
109
+
110
+ patched_activity = Class.new(activity)
111
+ patched_activity.class_exec(&patch)
112
+ patched_activity
113
+ end
114
+ end
115
+
90
116
  def normalize(options, local_keys) # TODO: test me.
91
117
  locals = options.reject { |key, value| ! local_keys.include?(key) }
92
118
  foreign = options.reject { |key, value| local_keys.include?(key) }
@@ -3,7 +3,7 @@ module Trailblazer
3
3
  module Activity
4
4
  module DSL
5
5
  module Linear
6
- VERSION = "0.2.3"
6
+ VERSION = "0.2.4"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity-dsl-linear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity