trailblazer-activity-dsl-linear 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -3
  3. data/CHANGES.md +100 -0
  4. data/Gemfile +7 -4
  5. data/Rakefile +1 -1
  6. data/lib/trailblazer/activity/dsl/linear/feature/merge.rb +2 -2
  7. data/lib/trailblazer/activity/dsl/linear/feature/patch.rb +9 -5
  8. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/dsl.rb +241 -156
  9. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb +276 -0
  10. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping.rb +70 -226
  11. data/lib/trailblazer/activity/dsl/linear/helper/path.rb +37 -18
  12. data/lib/trailblazer/activity/dsl/linear/helper.rb +38 -17
  13. data/lib/trailblazer/activity/dsl/linear/normalizer/extensions.rb +63 -0
  14. data/lib/trailblazer/activity/dsl/linear/normalizer/inherit.rb +90 -0
  15. data/lib/trailblazer/activity/dsl/linear/normalizer/output_tuples.rb +160 -0
  16. data/lib/trailblazer/activity/dsl/linear/normalizer/terminus.rb +26 -29
  17. data/lib/trailblazer/activity/dsl/linear/normalizer.rb +99 -160
  18. data/lib/trailblazer/activity/dsl/linear/sequence/builder.rb +3 -2
  19. data/lib/trailblazer/activity/dsl/linear/sequence/compiler.rb +21 -17
  20. data/lib/trailblazer/activity/dsl/linear/sequence/search.rb +2 -8
  21. data/lib/trailblazer/activity/dsl/linear/strategy.rb +56 -17
  22. data/lib/trailblazer/activity/dsl/linear/version.rb +1 -1
  23. data/lib/trailblazer/activity/dsl/linear.rb +13 -1
  24. data/lib/trailblazer/activity/fast_track.rb +96 -67
  25. data/lib/trailblazer/activity/path.rb +35 -53
  26. data/lib/trailblazer/activity/railway.rb +63 -65
  27. data/trailblazer-activity-dsl-linear.gemspec +8 -8
  28. metadata +27 -18
  29. data/lib/trailblazer/activity/dsl/linear/feature/variable_mapping/inherit.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91482f9f8f3191ea94fccb525e24e55b95edb1f089ee24dd7748364af140476b
4
- data.tar.gz: f85598f3e6796e6df4aa6a3927654dc882dae26e2e8c39eff4ea2b4a86db98f7
3
+ metadata.gz: 555d1c8af700e756c437e913546c302f4630cb0ba3066b97cae7deb67e25f055
4
+ data.tar.gz: e0fc5141498776365ff62c873d9d379bbd2f3bbfebc177939e7e18057503ee6c
5
5
  SHA512:
6
- metadata.gz: 88644ff777e10df4e7e6337742f4684e487bdac3e2899d5168f9f4769563171c68638608b2d3de495b66467d9046c2d3f2c12c94ebd4d046c9ec66bbb364cce6
7
- data.tar.gz: 53279e4799c2e08909e4a60e55a139c8455faf1d12b8f2fa78a5c80eef6446981e5468e0f962569be1538ce87a4567aef3ef271923be56e8cb17a83ae11610c9
6
+ metadata.gz: 7d57fa76cde08343769eb8d5feba10f830635738db77c6c732c3df1adadd13e0a6b865a3e5ff2ba6b6cdb3f4adce898f163fb8614e318d9070c98ef896c7322e
7
+ data.tar.gz: d2691ec2bf75287fd88b089d3764baccdfb2eaa0234b11a2954afae891e63e7262979004eb81d8fc7b204ba2c415f70a75177594400acb1a2ef736050b008864
@@ -5,11 +5,10 @@ jobs:
5
5
  strategy:
6
6
  fail-fast: false
7
7
  matrix:
8
- # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
9
- ruby: [2.5, 2.6, 2.7, '3.0', head, jruby]
8
+ ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', 'head', 'jruby']
10
9
  runs-on: ubuntu-latest
11
10
  steps:
12
- - uses: actions/checkout@v2
11
+ - uses: actions/checkout@v3
13
12
  - uses: ruby/setup-ruby@v1
14
13
  with:
15
14
  ruby-version: ${{ matrix.ruby }}
data/CHANGES.md CHANGED
@@ -1,3 +1,103 @@
1
+ # 1.2
2
+
3
+ ## Introspect
4
+
5
+ * As `Activity::Introspect::TaskMap` got removed, use `Activity::Introspect.Nodes(activity)` for introspecting. See https://trailblazer.to/2.1/docs/activity#activity-internals-introspection-api
6
+
7
+ ## Normalizer
8
+
9
+ * Extract `normalizer/extension.rb` to implement `Extension() => myext`
10
+ * Extract `normalizer/inherit.rb` to implement `inherit: true`.
11
+ * Extract `normalizer/output_tuples.rb` which represents code for the Wiring API.
12
+ * Connectors (`Track()`, `Id()` and `End()`) now contain the logic that returns the search builder. This used to sit in `#normalize_connections_from_dsl`.
13
+ * What used to be the `"path.outputs"` step is now a separate, nested pipeline named `"activity.default_outputs"`. See https://trailblazer.to/2.1/docs/internals#internals-wiring-api-outputs-defaulting
14
+ Basically, The default step's outputs are set in that separate pipeline under `"activity.default_outputs"`.
15
+ * Rename `"path.connections"` to `"path.step.add_success_connector"` for consistency.
16
+ * Move `Railway::DSL::NormalizerForPass` to `Railway::DSL::Pass::Normalizer` (same for `Fail`).
17
+ * Move `FastTrack::DSL::NormalizerForPass` to `FastTrack::DSL::Pass::Normalizer` (same for `Fail`).
18
+ * Remove `"activity.normalize_outputs_from_dsl"` as this all happens in `#compile_wirings` now.
19
+
20
+ ## Various
21
+
22
+ * Deprecate `Path(end_id:, end_task:)` options in favor of `Path(terminus: :semantic)`.
23
+ * `FastTrack` outputs for non-`Subprocess()` are only added when `fast_track: true` is set.
24
+ As a result, this will throw an exception `No `pass_fast` output found for :find_model`.
25
+
26
+ ```ruby
27
+ step :find_model, Output(:pass_fast) # throws "no output" exception.
28
+ ```
29
+
30
+ and needs to be changed to
31
+
32
+ ```ruby
33
+ step :find_model,
34
+ fast_track: true,
35
+ Output(:pass_fast)
36
+ ```
37
+ * Fixed a bug where `Subprocess(Path)` would accidentially add a `:failure` connection.
38
+ As a result, this doesn't work anymore
39
+
40
+ ```ruby
41
+ step Subprocess(Path), Output(:failure) => ...
42
+ ```
43
+ * Allow inheriting of `:fail_fast`, `:pass_fast` and `:fast_track`.
44
+ * The `:outputs` option for `#step` is now a private concept. When passed explicitely to the normalizer (as it happens with `Subprocess()`) it's no longer extended or defaulted.
45
+ * `Strategy.End()` now returns an `OutputTuples::End` instance. Use `Activity.End()` for the original behavior.
46
+ * Removed the `:connections` option in favor of simply using output tuples for setting connections. We also don't inherit `:connections` anymore, but the output tuples.
47
+ * Removed the `VariableMapping::Inherit` module as we can use generic inheritance logic.
48
+ * Finally add the `Extension() => my_ext` option to painlessly add extensions. This means you don't have to manually merge `:extensions` anymore.
49
+ * Extensions are now properly inherited (if `generic?` is false) using the universal inheritance mechanism.
50
+ * `Strategy.invoke` now passes on keyword arguments, too.
51
+ * A terminus step no longer maintains any wirings (as per `trailblazer-activity-0.16.0`), resulting in a terminus `Sequence` row as follows.
52
+
53
+ ```ruby
54
+ [
55
+ :success,
56
+ implementing::Success,
57
+ [], # no outputs anymore!
58
+ {id: "End.success", stop_event: true, semantic: :success}, # instead, {:semantic} is passed as a data option.
59
+ ]
60
+ ```
61
+ * Remove `Search::Noop` as an empty wirings array in `Sequence` are allowed now.
62
+
63
+ # 1.1.1
64
+
65
+ * When using `step ..., inherit: true, replace: :find_model` you can now omit `:id`. The ID from
66
+ `:replace` is used automatically in that case.
67
+ * Deprecate `:override` option for `#step`.
68
+ * Simplify `inherit: [:variable_mapping]` by recording the `:in_filters` and `:out_filters` variables
69
+ instead of the compiled pipelines. This fixes #61.
70
+ * Introduce `#patch` to simplify modifying nested activities. Instead of `Subprocess(<activity>, patch: ...)` you can use
71
+ the dedicated DSL function.
72
+
73
+ # 1.1.0
74
+
75
+ * Use `trailblazer-activity` 0.15.0.
76
+ * Remove `Path::DSL.OptionsForSequenceBuilder` and move concrete code to `Path::DSL.options_for_sequence_build`
77
+ which returns a set:
78
+
79
+ 1. default termini instructions for the concrete strategy
80
+ 2. options specific for this strategy subclass.
81
+
82
+ Everything else, such as merging user options, computing and adding termini, etc, now happens in
83
+ `Strategy::DSL.OptionsForSequenceBuilder`.
84
+ * Adding `Subprocess(Create, strict: true)` to wire all outputs of `Create` automatically.
85
+ Each output will be wired to its same named Track(semantic).
86
+ * Adding `Strategy(termini: )`
87
+ * For `output:` in combination with `:output_with_outer_ctx`, deprecate the second positional argument and make it
88
+ the `:outer_ctx` keyword argument instead.
89
+ * Introduce `Linear.Patch` as the public entry point for patching activities.
90
+ * Remove `Runtime.initial_aggregate` step for the input and output pipelines which results in slightly better runtime performance and less code.
91
+
92
+ ## Variable Mapping
93
+
94
+ * Simplify the architecture in `VariableMapping`, filters are now added directly into the `Pipeline`.
95
+ Performance increase from 17k to 25k from 1.0.0 to this version.
96
+ * Introduce `Inject(:variable)` to supersede the version receiving a big mapping hash.
97
+ * Add `Inject(:variable, override: true)` to always write a variable to ctx, regardless of its presence.
98
+ * Fix a bug where `Inject()` would override `In()` filters even though the latter was added latest. This
99
+ is fixed by treating both filter types equally and in the order they were added by the user (and the macro).
100
+
1
101
  # 1.0.0
2
102
 
3
103
  ## Additions
data/Gemfile CHANGED
@@ -5,11 +5,14 @@ gemspec
5
5
 
6
6
  gem "minitest-line"
7
7
 
8
- gem "rubocop", require: false
9
-
10
- gem "trailblazer-developer", path: "../trailblazer-developer"
8
+ # gem "trailblazer-developer", path: "../trailblazer-developer"
11
9
  # gem "trailblazer-developer", github: "trailblazer/trailblazer-developer"
12
10
  # gem "trailblazer-declarative", path: "../trailblazer-declarative"
13
- # gem "trailblazer-activity", path: "../trailblazer-activity"
11
+ # gem "trailblazer-activity", path: "../trailblazer-activity"
14
12
  # gem "trailblazer-activity", github: "trailblazer/trailblazer-activity"
15
13
  # gem "trailblazer-activity", path: "../circuit"
14
+
15
+ # gem "benchmark-ips"
16
+ # gem "stackprof"
17
+ # gem "standard"
18
+ # gem "trailblazer-core-utils", path: "../trailblazer-core-utils"
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require "rake/testtask"
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.test_files = FileList["test/**/*_test.rb"] - FileList["test/docs/autogenerated/*"]
8
8
  end
9
9
 
10
10
  task :default => :test
@@ -21,14 +21,14 @@ class Trailblazer::Activity
21
21
 
22
22
  _seq = Adds.apply_adds(
23
23
  old_seq,
24
- new_seq.collect { |row| {insert: [Adds::Insert.method(:Prepend), end_id], row: row } }
24
+ new_seq.collect { |row| {insert: [Adds::Insert.method(:Prepend), end_id], row: row} }
25
25
  )
26
26
  end
27
27
 
28
28
  def self.strip_start_and_ends(seq, end_id:)
29
29
  cut_off_index = end_id.nil? ? seq.size : Adds::Insert.find_index(seq, end_id) # find the "first" end.
30
30
 
31
- seq[1..cut_off_index-1]
31
+ seq[1..cut_off_index - 1]
32
32
  end
33
33
  end # Merge
34
34
  end
@@ -2,11 +2,10 @@ class Trailblazer::Activity
2
2
  module DSL
3
3
  module Linear
4
4
  module Patch
5
- # DISCUSS: we could make this a generic DSL option, not just for Subprocess().
6
5
  # Currently, this is called from the Subprocess() helper.
7
6
  def self.customize(activity, options:)
8
7
  options = options.is_a?(Proc) ?
9
- { [] => options } : # hash-wrapping with empty path, for patching given activity itself
8
+ {[] => options} : # hash-wrapping with empty path, for patching given activity itself
10
9
  options
11
10
 
12
11
  options.each do |path, patch|
@@ -16,12 +15,12 @@ class Trailblazer::Activity
16
15
  activity
17
16
  end
18
17
 
19
- def self.call(activity, path, customization)
18
+ def self.call(activity, path, customization, patched_activity: Class.new(activity))
20
19
  task_id, *path = path
21
20
 
22
21
  patch =
23
22
  if task_id
24
- segment_activity = Introspect::Graph(activity).find(task_id).task
23
+ segment_activity = Introspect.Nodes(activity, id: task_id).task
25
24
  patched_segment_activity = call(segment_activity, path, customization)
26
25
 
27
26
  # Replace the patched subprocess.
@@ -30,10 +29,15 @@ class Trailblazer::Activity
30
29
  customization # apply the *actual* patch from the Subprocess() call.
31
30
  end
32
31
 
33
- patched_activity = Class.new(activity)
34
32
  patched_activity.class_exec(&patch)
35
33
  patched_activity
36
34
  end
35
+
36
+ module DSL
37
+ def patch(*path, &block)
38
+ Patch.call(self, path, block, patched_activity: self)
39
+ end
40
+ end
37
41
  end # Patch
38
42
  end
39
43
  end