trailblazer-activity-dsl-linear 0.2.9 → 0.3.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: 979e2d306818d28e7dfaafbb9f312c1a1ad9e629d48466b37f1f86c11cb96263
4
- data.tar.gz: 1de9bba59e9ddfa45e2c330200294c3b5b45c214ecacbc89b4e6a0bebe3c3fb5
3
+ metadata.gz: f64e4cda0443bb3635a41f04a79ea5f12193ace7aac22d613eb3ce0749d3d303
4
+ data.tar.gz: ade9350dfbf4475edb0a67190d4e9cd37cbca8f838b27c63c5be21780b9d466d
5
5
  SHA512:
6
- metadata.gz: 25c6ec869be2f6802188e3ae3ea7f5db7e445fa36a3739f8224830d5543a1837b77d02a84ebd4cdc4cd5f61a99f243c1d01399afe5a82d7070289ee23e69f25b
7
- data.tar.gz: 58a92185b6dc1959a0698262123798493a72e0cef542c3c197b14f628793c8a9bb52b5cb11e995a04ec2fdfcced67a65dec0c3eedfada174cddc45727f03818b
6
+ metadata.gz: f2ad5a07613723c38ec2a29100b33a4b983451eca8d34884da03b6a98a3441709aa8e2f4c05d7717aebcbe3b6d47b3f3a07b389469396bea8cb6befd24ea1c1b
7
+ data.tar.gz: 1ac0b62f981d089cec84331ccb524b20f2f7aca089ed8e944ce422de126646176f0e66752a878d124cdf828d6261fd2d52e2e9ec63c2ade7eba658fa4bb9f3da
data/CHANGES.md CHANGED
@@ -1,3 +1,25 @@
1
+ # 0.3.4
2
+
3
+ * Allow DSL helpers such as `End()` in `Path()`.
4
+ * Introduce `Path(..., before: )` option to insert all path member steps before a certain element.
5
+ * Allow `Path(..., connect_to: Track(..))`.
6
+
7
+ # 0.3.3
8
+
9
+ * Fix for registering `PassFast` & `FailFast` ends in `FastTrack` to fix circuit interface callables which emits those signals.
10
+
11
+ # 0.3.2
12
+
13
+ * Updrading `trailblazer-activity` version to utilise new `trailblazer-context` :drum:
14
+
15
+ # 0.3.1
16
+
17
+ * Fixes in circuit interface normalization when given task is a {Symbol}, consider additional {task} options (like {id}) and assign {task} symbol as an {id}.
18
+
19
+ # 0.3.0
20
+
21
+ * Fix circuit interface callable to make `step task: :instance_method` use circuit signature.
22
+
1
23
  # 0.2.9
2
24
 
3
25
  * The `Path()` helper, when used with `:end_task` will now automatically _append_ the end task (or terminus) to `End.success`.
@@ -43,33 +43,16 @@ module Trailblazer
43
43
  Id.new(id).freeze
44
44
  end
45
45
 
46
- def Path(track_color: "track_#{rand}", end_id:"path_end_#{rand}", connect_to:nil, **options, &block)
47
- # DISCUSS: here, we use the global normalizer and don't allow injection.
48
- state = Activity::Path::DSL::State.new(Activity::Path::DSL.OptionsForState(track_name: track_color, end_id: end_id, **options)) # TODO: test injecting {:normalizers}.
46
+ def Path(track_color: "track_#{rand}", connect_to: nil, before: false, **options, &block)
47
+ path = Activity::Path(track_name: track_color, **options)
48
+ activity = Class.new(path) { self.instance_exec(&block) }
49
49
 
50
- # seq = block.call(state) # state changes.
51
- state.instance_exec(&block)
52
-
53
- seq = state.to_h[:sequence]
54
-
55
- _end_id =
56
- if connect_to
57
- end_id
58
- else
59
- nil
60
- end
61
-
62
- seq = strip_start_and_ends(seq, end_id: _end_id) # don't cut off end unless {:connect_to} is set.
50
+ seq = activity.instance_variable_get(:@state).to_h[:sequence] # TODO: fix @state interface
51
+ # Strip default ends `Start.default` and `End.success` (if present).
52
+ seq = seq[1..-1].reject{ |row| row[3][:stop_event] && row[3][:id] == 'End.success' }
63
53
 
64
54
  if connect_to
65
- output, _ = seq[-1][2][0].(seq, seq[-1]) # FIXME: the Forward() proc contains the row's Output, and the only current way to retrieve it is calling the search strategy. It should be Forward#to_h
66
-
67
- searches = [Search.ById(output, connect_to.value)]
68
-
69
- row = seq[-1]
70
- row = row[0..1] + [searches] + [row[3]] # FIXME: not mutating an array is so hard: we only want to replace the "searches" element, index 2
71
-
72
- seq = seq[0..-2] + [row]
55
+ seq = connect_for_sequence(seq, connect_to: connect_to)
73
56
  end
74
57
 
75
58
  # Add the path elements before {End.success}.
@@ -80,9 +63,12 @@ module Trailblazer
80
63
  # the terminus of the path goes _after_ {End.success} into the "end group".
81
64
  insert_method = options[:stop_event] ? Insert.method(:Append) : Insert.method(:Prepend)
82
65
 
66
+ insert_target = "End.success" # insert before/after
67
+ insert_target = before if before && connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Track) # FIXME: this is a bit hacky, of course!
68
+
83
69
  {
84
70
  row: row,
85
- insert: [insert_method, "End.success"]
71
+ insert: [insert_method, insert_target]
86
72
  }
87
73
  end
88
74
 
@@ -90,6 +76,23 @@ module Trailblazer
90
76
  return Track.new(track_color, adds, {})
91
77
  end
92
78
 
79
+ # Connect last row of the {sequence} to the given step via its {Id}
80
+ # Useful when steps needs to be inserted in between {Start} and {connect Id()}.
81
+ private def connect_for_sequence(sequence, connect_to:)
82
+ output, _ = sequence[-1][2][0].(sequence, sequence[-1]) # FIXME: the Forward() proc contains the row's Output, and the only current way to retrieve it is calling the search strategy. It should be Forward#to_h
83
+
84
+ # searches = [Search.ById(output, connect_to.value)]
85
+ searches = [Search.ById(output, connect_to.value)] if connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Id)
86
+ searches = [Search.Forward(output, connect_to.color)] if connect_to.instance_of?(Trailblazer::Activity::DSL::Linear::Helper::Track) # FIXME: use existing mapping logic!
87
+
88
+ row = sequence[-1]
89
+ row = row[0..1] + [searches] + [row[3]] # FIXME: not mutating an array is so hard: we only want to replace the "searches" element, index 2
90
+
91
+ sequence = sequence[0..-2] + [row]
92
+
93
+ sequence
94
+ end
95
+
93
96
  # Computes the {:outputs} options for {activity}.
94
97
  def Subprocess(activity, patch: {})
95
98
  activity = Patch.customize(activity, options: patch)
@@ -54,22 +54,27 @@ module Trailblazer
54
54
  # Specific to the "step DSL": if the first argument is a callable, wrap it in a {step_interface_builder}
55
55
  # since its interface expects the step interface, but the circuit will call it with circuit interface.
56
56
  def normalize_step_interface((ctx, flow_options), *)
57
- options = case (step_args = ctx[:options]) # either a <#task> or {} from macro
57
+ options = case ctx[:options]
58
58
  when Hash
59
- # extract task for interfaces like `step task: :instance_method_name`
60
- step_args[:task].is_a?(Symbol) ? step_args[:task] : step_args
59
+ # Circuit Interface
60
+ task = ctx[:options].fetch(:task)
61
+ id = ctx[:options][:id]
62
+
63
+ if task.is_a?(Symbol)
64
+ # step task: :find, id: :load
65
+ { **ctx[:options], id: (id || task), task: Trailblazer::Option( task ) }
66
+ else
67
+ # step task: Callable, ... (Subprocess, Proc, macros etc)
68
+ ctx[:options] # NOOP
69
+ end
61
70
  else
62
- step_args
71
+ # Step Interface
72
+ # step :find, ...
73
+ # step Callable, ... (Method, Proc etc)
74
+ { task: ctx[:options], wrap_task: true }
63
75
  end
64
76
 
65
- unless options.is_a?(::Hash)
66
- # task = wrap_with_step_interface(task: options, step_interface_builder: ctx[:user_options][:step_interface_builder]) # TODO: make this optional with appropriate wiring.
67
- task = options
68
-
69
- ctx = ctx.merge(options: {task: task, wrap_task: true})
70
- end
71
-
72
- return Trailblazer::Activity::Right, [ctx, flow_options]
77
+ return Trailblazer::Activity::Right, [ctx.merge(options: options), flow_options]
73
78
  end
74
79
 
75
80
  def wrap_task_with_step_interface((ctx, flow_options), **)
@@ -74,7 +74,7 @@ module Trailblazer
74
74
  return args[0], options.merge(evaluated_options)
75
75
  end
76
76
 
77
- def Path(options, &block) # syntactically, we can't access the {do ... end} block here.
77
+ def Path(**options, &block) # syntactically, we can't access the {do ... end} block here.
78
78
  BlockProxy.new(options, block)
79
79
  end
80
80
 
@@ -68,10 +68,10 @@ module Trailblazer
68
68
  end
69
69
 
70
70
  def call((original_ctx, flow_options), **circuit_options)
71
- Trailblazer::Context.for_circuit(
71
+ Trailblazer::Context(
72
72
  @filter.(original_ctx, **circuit_options),
73
73
  {},
74
- [original_ctx, flow_options], circuit_options # these options for {Context.for} are currently unused.
74
+ flow_options[:context_options]
75
75
  )
76
76
  end
77
77
  end
@@ -3,7 +3,7 @@ module Trailblazer
3
3
  module Activity
4
4
  module DSL
5
5
  module Linear
6
- VERSION = "0.2.9"
6
+ VERSION = "0.3.4"
7
7
  end
8
8
  end
9
9
  end
@@ -63,6 +63,11 @@ module Trailblazer
63
63
  def pass_fast_option((ctx, flow_options), *)
64
64
  ctx = merge_connections_for(ctx, ctx, :pass_fast, :success)
65
65
 
66
+ ctx = merge_connections_for(ctx, ctx, :pass_fast, :pass_fast, :pass_fast)
67
+ ctx = merge_outputs_for(ctx,
68
+ pass_fast: Activity.Output(Activity::FastTrack::PassFast, :pass_fast),
69
+ )
70
+
66
71
  return Right, [ctx, flow_options]
67
72
  end
68
73
 
@@ -76,6 +81,11 @@ module Trailblazer
76
81
  def fail_fast_option((ctx, flow_options), *)
77
82
  ctx = merge_connections_for(ctx, ctx, :fail_fast, :failure)
78
83
 
84
+ ctx = merge_connections_for(ctx, ctx, :fail_fast, :fail_fast, :fail_fast)
85
+ ctx = merge_outputs_for(ctx,
86
+ fail_fast: Activity.Output(Activity::FastTrack::FailFast, :fail_fast),
87
+ )
88
+
79
89
  return Right, [ctx, flow_options]
80
90
  end
81
91
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  end
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "trailblazer-activity", ">= 0.9.1", "< 1.0.0"
22
+ spec.add_dependency "trailblazer-activity", ">= 0.11.3", "< 1.0.0"
23
23
 
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
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.9
4
+ version: 0.3.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: 2020-07-02 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trailblazer-activity
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.1
19
+ version: 0.11.3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 0.9.1
29
+ version: 0.11.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.0.0
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.7.6
139
+ rubygems_version: 2.7.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Simple DSL to define Trailblazer activities.