trailblazer-activity 0.5.1 → 0.5.2

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: 92e2284135d0c4f569c3b6de38647a5f4dfae359b90a6461539d67fe2a8d58fc
4
- data.tar.gz: d71820d9da38a2099713bb5fd5005b4680f01c1181e4f6bb919cd84a4ec80443
3
+ metadata.gz: 14060aa9266dec50a2538bfddacb622d1fcefeba94b92fade757e039ea8aab4f
4
+ data.tar.gz: 4bcd28d5b77dc9023c43edb0d762a4ac228fa36012a275f3830f56db9e71e795
5
5
  SHA512:
6
- metadata.gz: c13c41f9631224f688190808efea928dda6b6cfac0d9fa7c53edc0e77d998b3d9b27ff0f9753394f0403dc2cb0783f2731cfd4b5993cce63ba71518c83006459
7
- data.tar.gz: 6c2c4ead668c87454a1129254d88cd9a9558336896e7796441f391223ca6e40b5ba4cdb8fae52c4bcc4c0d3fd8a17bfe1f48c1832f88e44a3bfaa0b05e55a21c
6
+ metadata.gz: 95e528103b854970aa5b168ce89e8164ae0bdd64ffa21deec24fbd05aa6ca8700d2aa252f5ee3b7b12d2ffe9e592fbb6f3424a9208aa86be96b167fb7bc0c036
7
+ data.tar.gz: '09e520f7372cd6d604dc5444484bc561e29e4c1462fd2298bc6d9d4d6a1571eadb37dd7150988cf94a53fe0b218a94529e0fd38e5e2fb31a57ca3ae017640dbc'
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.5.2
2
+
3
+ * In `Path()`, we removed the `#path` method in favor of a cleaner `task` DSL method. We now use the default plus_poles `success` and `failure` everywhere for consistency. This means that a `task` has two outputs, and if you referenced `Output(:success)`, that would be only one of them. We're planning to have `pass` back which has one `success` plus_pole, only. This change makes the DSL wiring behavior much more consistent.
4
+ * Changed `TaskBuilder::Builder.()` to a function `TaskBuilder::Builder()`.
5
+
1
6
  # 0.5.1
2
7
 
3
8
  * Include all end events without outgoing connections into `Activity.outputs`. In earlier versions, we were filtering out end events without incoming connections, which reduces the number of outputs, but might not represent the desired interface of an activity.
@@ -6,7 +6,7 @@ module Trailblazer
6
6
  #
7
7
  # The Normalizer sits in the `@builder`, which receives all DSL calls from the Operation subclass.
8
8
  class Normalizer
9
- def self.build(task_builder: Activity::TaskBuilder::Binary, default_outputs: Builder::Path.default_outputs, pipeline: Pipeline, extension:[], **options)
9
+ def self.build(task_builder: Activity::TaskBuilder.method(:Binary), default_outputs: Builder::Path.default_outputs, pipeline: Pipeline, extension:[], **options)
10
10
  return new(
11
11
  default_outputs: default_outputs,
12
12
  extension: extension,
@@ -93,10 +93,10 @@ module Trailblazer
93
93
  .merge(local_options)
94
94
  end
95
95
 
96
- task Activity::TaskBuilder::Binary.( method(:normalize_for_macro) ), id: "normalize_for_macro"
97
- task Activity::TaskBuilder::Binary.( method(:split_options) ), id: "split_options"
98
- task Activity::TaskBuilder::Binary.( method(:normalize_extension_option) ), id: "normalize_extension_option"
99
- task Activity::TaskBuilder::Binary.( method(:initialize_plus_poles) ), id: "initialize_plus_poles"
96
+ task Activity::TaskBuilder::Binary( method(:normalize_for_macro) ), id: "normalize_for_macro"
97
+ task Activity::TaskBuilder::Binary( method(:split_options) ), id: "split_options"
98
+ task Activity::TaskBuilder::Binary( method(:normalize_extension_option) ), id: "normalize_extension_option"
99
+ task Activity::TaskBuilder::Binary( method(:initialize_plus_poles) ), id: "initialize_plus_poles"
100
100
  # task ->((ctx, _), **) { pp ctx; [Activity::Right, [ctx, _]] }
101
101
  end
102
102
  end # Normalizer
@@ -14,9 +14,12 @@ module Trailblazer
14
14
  )
15
15
  end
16
16
 
17
+ # In most cases, a task has a binary signal, which is why we decided to make that
18
+ # the default output set.
17
19
  def self.default_outputs
18
20
  {
19
- success: Activity.Output(Activity::Right, :success)
21
+ :success => Activity.Output(Activity::Right, :success),
22
+ :failure => Activity.Output(Activity::Left, :failure)
20
23
  }
21
24
  end
22
25
 
@@ -10,12 +10,6 @@ module Trailblazer
10
10
  )
11
11
  end
12
12
 
13
- def self.default_outputs
14
- Path.default_outputs.merge(
15
- :failure => Activity.Output(Activity::Left, :failure),
16
- )
17
- end
18
-
19
13
  # Adds the End.failure end to the Path sequence.
20
14
  # @return [Adds] list of Adds instances that can be chained or added to an existing sequence.
21
15
  def self.InitialAdds(failure_color:raise, failure_end: Activity.End(failure_color), **builder_options)
@@ -11,13 +11,13 @@ module Trailblazer
11
11
  {
12
12
  builder_class: Magnetic::Builder::Path, # we use the Activity-based Normalizer
13
13
  normalizer_class: Magnetic::Normalizer,
14
- default_outputs: Magnetic::Builder::Path.default_outputs,
14
+ default_outputs: Magnetic::Builder::Path.default_outputs, # binary outputs
15
15
  extension: [ Introspect.method(:add_introspection) ],
16
16
 
17
17
  extend: [
18
- DSL.def_dsl(:task, Magnetic::Builder::Path, :TaskPolarizations),
18
+ # DSL.def_dsl(:task, Magnetic::Builder::Path, :PassPolarizations),
19
19
  DSL.def_dsl(:_end, Magnetic::Builder::Path, :EndEventPolarizations),
20
- DSL.def_dsl(:pass, Magnetic::Builder::Railway, :PassPolarizations),
20
+ DSL.def_dsl(:task, Magnetic::Builder::Railway, :PassPolarizations),
21
21
  ],
22
22
  }
23
23
  end
@@ -9,7 +9,7 @@ module Trailblazer
9
9
  def self.config
10
10
  Path.config.merge(
11
11
  builder_class: Magnetic::Builder::Railway,
12
- default_outputs: Magnetic::Builder::Railway.default_outputs,
12
+ default_outputs: Magnetic::Builder::Path.default_outputs,
13
13
  extend: [
14
14
  DSL.def_dsl(:step, Magnetic::Builder::Railway, :StepPolarizations),
15
15
  DSL.def_dsl(:fail, Magnetic::Builder::Railway, :FailPolarizations),
@@ -2,36 +2,34 @@ module Trailblazer
2
2
  module Activity::TaskBuilder
3
3
  # every step is wrapped by this proc/decider. this is executed in the circuit as the actual task.
4
4
  # Step calls step.(options, **options, flow_options)
5
- # Output direction binary: true=>Right, false=>Left.
5
+ # Output signal binary: true=>Right, false=>Left.
6
6
  # Passes through all subclasses of Direction.~~~~~~~~~~~~~~~~~
7
- module Binary
8
- def self.call(user_proc)
9
- Task.new( Trailblazer::Option::KW( user_proc ), user_proc )
10
- end
7
+ def self.Binary(user_proc)
8
+ Task.new(Trailblazer::Option::KW( user_proc ), user_proc)
9
+ end
11
10
 
12
- # Translates the return value of the user step into a valid signal.
13
- # Note that it passes through subclasses of {Signal}.
14
- def self.binary_direction_for(result, on_true, on_false)
15
- result.is_a?(Class) && result < Activity::Signal ? result : (result ? on_true : on_false)
16
- end
11
+ # Translates the return value of the user step into a valid signal.
12
+ # Note that it passes through subclasses of {Signal}.
13
+ def self.binary_signal_for(result, on_true, on_false)
14
+ result.is_a?(Class) && result < Activity::Signal ? result : (result ? on_true : on_false)
17
15
  end
18
16
 
19
17
  class Task
20
18
  def initialize(task, user_proc)
21
- @task = task
22
- @user_proc = user_proc
19
+ @task = task
20
+ @user_proc = user_proc
23
21
 
24
22
  freeze
25
23
  end
26
24
 
27
- def call( (options, *args), **circuit_args )
25
+ def call( (ctx, flow_options), **circuit_options )
28
26
  # Execute the user step with TRB's kw args.
29
- result = @task.( options, **circuit_args ) # circuit_args contains :exec_context.
27
+ result = @task.( ctx, **circuit_options ) # circuit_options contains :exec_context.
30
28
 
31
29
  # Return an appropriate signal which direction to go next.
32
- direction = Binary.binary_direction_for( result, Activity::Right, Activity::Left )
30
+ signal = Activity::TaskBuilder.binary_signal_for( result, Activity::Right, Activity::Left )
33
31
 
34
- [ direction, [ options, *args ], **circuit_args ]
32
+ return signal, [ ctx, flow_options ]
35
33
  end
36
34
 
37
35
  def inspect
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  class Activity < Module
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -11,6 +11,8 @@ module Trailblazer
11
11
  #
12
12
  # @see Activity
13
13
  # @api semi-private
14
+ #
15
+ # This is the "pipeline operator"'s implementation.
14
16
  class Circuit
15
17
  def initialize(map, stop_events, name: nil, start_task: map.keys.first)
16
18
  @map = map
@@ -33,13 +35,15 @@ module Trailblazer
33
35
  # @param flow_options Library-specific flow control data
34
36
  # @return [last_signal, options, flow_options, *args]
35
37
  #
36
- # DISCUSS: returned circuit_options are ignored when calling the runner.
38
+ # NOTE: returned circuit_options are discarded when calling the runner.
37
39
  def call(args, task: @start_task, runner: Run, **circuit_options)
40
+ circuit_options = circuit_options.merge( runner: runner ).freeze # TODO: set the :runner option via arguments_for_call to save the merge?
41
+
38
42
  loop do
39
- last_signal, args, _ignored_circuit_options = runner.(
43
+ last_signal, args, _discarded_circuit_options = runner.(
40
44
  task,
41
45
  args,
42
- circuit_options.merge( runner: runner ) # options for runner, to be discarded.
46
+ circuit_options
43
47
  )
44
48
 
45
49
  # Stop execution of the circuit when we hit a stop event (< End). This could be an task's End or Suspend.
@@ -47,7 +51,7 @@ module Trailblazer
47
51
 
48
52
  task = next_for(task, last_signal) do |next_task, in_map|
49
53
  raise IllegalInputError.new("#{task}") unless in_map
50
- raise IllegalOutputSignalError.new("#{@name}[#{task}][ #{last_signal.inspect} ]") unless next_task
54
+ raise IllegalOutputSignalError.new("<#{@name}>[#{task}][ #{last_signal.inspect} ]") unless next_task
51
55
  end
52
56
  end
53
57
  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.5.1
4
+ version: 0.5.2
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-03-03 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hirb