trailblazer-activity-dsl-linear 0.4.1 → 0.4.2

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: 36d9e093365ba01dad631acf3435eaab26230d348edc12ac2691d984ec5fe1f3
4
- data.tar.gz: 50aa04fe0e5214fc8021ea8436a4153df8dd69361bd9f9468a18b38e7309f85f
3
+ metadata.gz: 48015005cd4c2e881df17be4be592445bdf9c528bd4b720bd521a4b96551c646
4
+ data.tar.gz: 6d9ed497b87bae7ebb106beb99e508eefd0c8f2bc3b5b2a07cf6fdf582f1aac1
5
5
  SHA512:
6
- metadata.gz: 45f9ec2af2d4af584608d22f3a613495c199d6f665a1e312302f4e0c615871a96b67b8f80b92df597615dd1d7bb0faf142d43084d83e278e8ce1b85a184b0472
7
- data.tar.gz: 55f68875e60eb8669a711e0d175e4a690ebe6b8e9be13df8c34426788652ebf34e8f48b84aa9f6b0161d4aca25eefb4272179233e7c5dcb80807befd34ecc106
6
+ metadata.gz: b221f07fccc51338300aa8bba4435edf4990e366667d381d060a5b31f1dff3badd6888ff6d5db0597fc378538bda1d6658d7c1e30073397c08f58f459ca87954
7
+ data.tar.gz: 2ea9893cfbf3ac551e01128c4e14adf524c84235d4129d7e7cb1f9f84bf1a9b665c4f4a920fa36d557fcc837f2adfd6ac12eb72c61c8e300476ac6a3f72cc901
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.4.2
2
+
3
+ * Don't allow duplicate activities in Sequence (#47) :ghost:
4
+ * {:inherit} will only inherit the wirings supported in child activity (#48)
5
+
1
6
  # 0.4.1
2
7
 
3
8
  * Updrading `trailblazer-activity` to use shiny `trailblazer-option`.
@@ -246,13 +246,21 @@ module Trailblazer
246
246
  index = Linear::Insert.find_index(sequence, id)
247
247
  row = sequence[index] # from this row we're inheriting options.
248
248
 
249
- extensions = (row[3][:extensions]||[]) + (ctx[:extensions]||[]) # FIXME: DEFAULTING, FOR FUCK'S SAKE
249
+ connections = get_inheritable_connections(ctx, row[3][:connections])
250
+ extensions = Array(row[3][:extensions]) + Array(ctx[:extensions])
250
251
 
251
- ctx = ctx.merge(connections: row[3][:connections], extensions: extensions) # "inherit"
252
+ ctx = ctx.merge(connections: connections, extensions: extensions) # "inherit"
252
253
 
253
254
  return Trailblazer::Activity::Right, [ctx, flow_options]
254
255
  end
255
256
 
257
+ # return connections from {parent} step which are supported by current step
258
+ private def get_inheritable_connections(ctx, parent_connections)
259
+ return parent_connections unless ctx[:outputs]
260
+
261
+ parent_connections.slice(*ctx[:outputs].keys)
262
+ end
263
+
256
264
  # TODO: make this extendable!
257
265
  def cleanup_options((ctx, flow_options), *)
258
266
  # new_ctx = ctx.reject { |k, v| [:connections, :outputs, :end_id, :step_interface_builder, :failure_end, :track_name, :sequence].include?(k) }
@@ -3,7 +3,7 @@ module Trailblazer
3
3
  module Activity
4
4
  module DSL
5
5
  module Linear
6
- VERSION = "0.4.1"
6
+ VERSION = "0.4.2"
7
7
  end
8
8
  end
9
9
  end
@@ -81,12 +81,27 @@ module Trailblazer
81
81
  }
82
82
  end
83
83
 
84
+ def normalize_duplications((ctx, flow_options), *)
85
+ return Right, [ctx, flow_options] if ctx[:replace]
86
+
87
+ signal, (ctx, flow_options) = raise_on_duplicate_id([ctx, flow_options])
88
+ signal, (ctx, flow_options) = clone_duplicate_activity([ctx, flow_options])
89
+
90
+ return signal, [ctx, flow_options]
91
+ end
92
+
84
93
  def raise_on_duplicate_id((ctx, flow_options), *)
85
- id, sequence, insert = ctx[:id], ctx[:sequence], ctx[:sequence_insert][0] # DISCUSS: should we use Replace here or rather the option(s)?
94
+ id, sequence = ctx[:id], ctx[:sequence]
95
+ raise "ID #{id} is already taken. Please specify an `:id`." if sequence.find { |row| row[3][:id] == id }
86
96
 
87
- if insert != Linear::Insert.method(:Replace)
88
- raise "ID #{id} is already taken. Please specify an `:id`." if sequence.find { |row| row[3][:id] == id }
89
- end
97
+ return Right, [ctx, flow_options]
98
+ end
99
+
100
+ def clone_duplicate_activity((ctx, flow_options), *)
101
+ return Right, [ctx, flow_options] unless ctx[:task].is_a?(Class)
102
+
103
+ task, sequence = ctx[:task], ctx[:sequence]
104
+ ctx = ctx.merge(task: task.clone) if sequence.find { |row| row[1] == task }
90
105
 
91
106
  return Right, [ctx, flow_options]
92
107
  end
@@ -104,12 +119,12 @@ module Trailblazer
104
119
  prepend_to_path(
105
120
  sequence,
106
121
 
107
- "path.outputs" => method(:merge_path_outputs),
108
- "path.connections" => method(:merge_path_connections),
109
- "path.sequence_insert" => method(:normalize_sequence_insert),
110
- "path.raise_on_duplicate_id" => method(:raise_on_duplicate_id),
111
- "path.magnetic_to" => method(:normalize_magnetic_to),
112
- "path.wirings" => Linear::Normalizer.method(:compile_wirings),
122
+ "path.outputs" => method(:merge_path_outputs),
123
+ "path.connections" => method(:merge_path_connections),
124
+ "path.sequence_insert" => method(:normalize_sequence_insert),
125
+ "path.normalize_duplications" => method(:normalize_duplications),
126
+ "path.magnetic_to" => method(:normalize_magnetic_to),
127
+ "path.wirings" => Linear::Normalizer.method(:compile_wirings),
113
128
  )
114
129
  end
115
130
 
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.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-04 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity