trailblazer-activity 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 8acff4e1b4e5f3e922e9e368cf5885de56dcc2b5
4
- data.tar.gz: 3a1a10d63d5cbe7236f0ffac21f4774add92954a
3
+ metadata.gz: 989cc224fca29c0d3150922613537af4a89bab2e
4
+ data.tar.gz: e0937bd45f8804d7f9ad6329256fb7c7140d0523
5
5
  SHA512:
6
- metadata.gz: 6e13c839f0ca6215fe069299de99ead0910557412fb24b40ecc4a1c9e25884108f105bdaa2cc6302a1ad96b83d425932d0cad0d1a2c5e016177eeb087e8278ea
7
- data.tar.gz: f6a774594e754bb0c4ba4082b4a285421850e6d79450d00a5729d96c85c171627aa35dfc14fead7b47190069cebab893eb6ad57150cf10c186f63bd566842107
6
+ metadata.gz: 7714ebf879a4f1f4fa95ce9b5937e3bfcb5419e1be5e38a244a5ef0e86feaed8d0619cc82e2a84a9e6b615d176896116173502b449d933c5409f9baa4fb06f35
7
+ data.tar.gz: 21708524bbc25844a5b6e3d2209d73ea4224bbbacb6e7784ef4c389208bca12c6366cbe15c4bfcded4c98d8fbcf276beea661f98cf665f95ca59dae002926f39
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.3.1
2
+
3
+ * Allow passing a `:normalizer` to the DSL.
4
+ * Builders don't have to provide `keywords` as we can filter them automatically.
5
+
1
6
  # 0.2.2
2
7
 
3
8
  * Remove `Activity#end_events`.
@@ -84,11 +84,6 @@ module Trailblazer
84
84
  Railway.default_plus_poles(*args)
85
85
  end
86
86
 
87
- def self.keywords
88
- [:fail_fast, :pass_fast, :fast_track, :type, :override]
89
- end
90
-
91
-
92
87
  # Adds the End.fail_fast and End.pass_fast end to the Railway sequence.
93
88
  def self.InitialAdds(pass_fast_end: Activity.End("pass_fast", :pass_fast), fail_fast_end: Activity.End("fail_fast", :fail_fast), **builder_options)
94
89
  path_adds = Railway.InitialAdds(**builder_options)
@@ -18,13 +18,8 @@ module Trailblazer
18
18
  plan_for( *Path.for(normalizer, options), &block )
19
19
  end
20
20
 
21
-
22
- def self.keywords
23
- [:type]
24
- end
25
-
26
21
  def task(task, options={}, &block)
27
- polarizations = Path.TaskPolarizations( @builder_options.merge(type: options[:type]) ) # DISCUSS: handle :type here? Really?
22
+ polarizations = Path.TaskPolarizations( @builder_options.merge( type: options[:type] ) ) # DISCUSS: handle :type here? Really?
28
23
 
29
24
  insert_element( Path, polarizations, task, options, &block )
30
25
  end
@@ -14,10 +14,6 @@ module Trailblazer
14
14
  plan_for( *Railway.for(normalizer, options), &block )
15
15
  end
16
16
 
17
- def self.keywords
18
- [:type]
19
- end
20
-
21
17
  def step(task, options={}, &block)
22
18
  insert_element( Railway, Railway.StepPolarizations(@builder_options), task, options, &block )
23
19
  end
@@ -57,12 +57,9 @@ module Trailblazer
57
57
 
58
58
  # Internal top-level entry point to add task(s) and connections.
59
59
  def insert_element(impl, polarizations, task, options, &block)
60
- adds, *returned_options = Builder.adds_for(polarizations, @normalizer, impl.keywords, task, options, &block)
61
- end
60
+ normalizer = options[:normalizer] || @normalizer # DISCUSS: do this at a deeper point?
62
61
 
63
- # Options valid for all DSL calls with this Builder framework.
64
- def self.generic_keywords
65
- [ :id, :plus_poles, :magnetic_to, :adds ]
62
+ adds, *returned_options = Builder.adds_for(polarizations, normalizer, task, options, &block)
66
63
  end
67
64
 
68
65
  def self.sequence_keywords
@@ -81,8 +78,8 @@ module Trailblazer
81
78
  # @return Adds
82
79
  # High level interface for DSL calls like ::task or ::step.
83
80
  # TODO: RETURN ALL OPTIONS
84
- def self.adds_for(polarizations, normalizer, keywords, task, options, &block)
85
- task, local_options, options, sequence_options = normalize_options(normalizer, keywords, task, options)
81
+ def self.adds_for(polarizations, normalizer, task, options, &block)
82
+ task, local_options, options, sequence_options = normalize_options(normalizer, task, options)
86
83
 
87
84
  initial_plus_poles = local_options[:plus_poles]
88
85
  magnetic_to = local_options[:magnetic_to]
@@ -97,16 +94,23 @@ module Trailblazer
97
94
  end
98
95
 
99
96
  # @private
100
- def self.normalize_options(normalizer, keywords, task, options)
97
+ def self.normalize_options(normalizer, task, options)
98
+ keywords = extract_dsl_keywords(options)
99
+
101
100
  # sort through the "original" user DSL options.
102
- options, local_options = normalize( options, generic_keywords+keywords ) # DISCUSS:
103
- options, sequence_options = normalize( options, sequence_keywords )
101
+ options, local_options = normalize( options, keywords ) # DISCUSS:
102
+ local_options, sequence_options = normalize( local_options, sequence_keywords )
104
103
 
105
104
  task, local_options, options, sequence_options = normalizer.(task, local_options, options, sequence_options)
106
105
 
107
106
  return task, local_options, options, sequence_options
108
107
  end
109
108
 
109
+ # Filter out connections, e.g. `Output(:fail_fast) => :success` and return only the keywords like `:id` or `:replace`.
110
+ def self.extract_dsl_keywords(options, connection_classes = [Activity::Output, DSL::Output::Semantic])
111
+ options.keys - options.keys.find_all { |k| connection_classes.include?( k.class ) }
112
+ end
113
+
110
114
  # Low-level interface for DSL calls (e.g. Start, where "you know what you're doing")
111
115
  # @private
112
116
  def self.adds(id, task, initial_plus_poles, polarization, polarizations_from_user_options, options, sequence_options, magnetic_to = nil)
@@ -1,5 +1,5 @@
1
1
  module Trailblazer
2
2
  class Activity
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer-activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer