core-pipeline 0.5.3 → 0.6.0

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: 10088703b97af1aeb7a1ac75ef8739b33ddd6196340d419eb616a24421c5bd12
4
- data.tar.gz: 9709eb0cf5a5f543ad14e53c52ff12ed7e90131dc941d4141b38a8f770a7a29b
3
+ metadata.gz: 44d424c0972800b001899d14050c9e8dd4ce9222fe9e41aaccb0824f83e8f75e
4
+ data.tar.gz: f2ab047a40c9f8bb693af5a021fd44b791750e1b9ed5cf6b00fb1c08473b9467
5
5
  SHA512:
6
- metadata.gz: 4d3b50b53674156daeee0c77fc7cf110fa2bffbfe5a1f919d094e8f8a359b183b017cbfab4ba94b3f571e534e768b385fc268964cffe23e7907c8aa04eba63b9
7
- data.tar.gz: 53e529e79fc5fdad3996fb0a7e50cb175b6e567b4e8763350314e706999a450c1552bb8838168c7343c2b3326428dc0612369461273c5183d1e434b3fc359501
6
+ metadata.gz: 2d1dfba6cf558d16f8cf0356e02a44a738da2f7ea172024e5c289fe2eac8afdf601819b8bf11b08c6a42460dd4e74adf24290fbab788b709f671f8a8c5e70c26
7
+ data.tar.gz: 4c5bc79f03e307c3e2d43dea785dd1fec7524b99981957eed72658f125d291bd996a6e7b1a33396833a4748f22a7151cdb6351566233c6e07ba11057ffd5023e
data/CHANGELOG.md CHANGED
@@ -1,71 +1,78 @@
1
- ## [v0.5.3](https://github.com/metabahn/corerb/releases/tag/2023-07-16)
1
+ ## [v0.6.0](https://github.com/bryanp/corerb/releases/tag/2023-12-24)
2
+
3
+ *released on 2023-12-24*
4
+
5
+ * `dep` [#143](https://github.com/bryanp/corerb/pull/143) Deprecate `Is::*` and `Refine::*` namespaces ([bryanp](https://github.com/bryanp))
6
+ * `dep` [#135](https://github.com/bryanp/corerb/pull/135) Remove Ruby 2 support ([bryanp](https://github.com/bryanp))
7
+
8
+ ## [v0.5.3](https://github.com/bryanp/corerb/releases/tag/2023-07-16)
2
9
 
3
10
  *released on 2023-07-16*
4
11
 
5
12
  * `fix` [#133](https://github.com/bryanp/corerb/pull/133) Isolate pipelines when subclassed ([bryanp](https://github.com/bryanp))
6
13
 
7
- ## [v0.5.2](https://github.com/metabahn/corerb/releases/tag/2022-06-02)
14
+ ## [v0.5.2](https://github.com/bryanp/corerb/releases/tag/2022-06-02)
8
15
 
9
16
  *released on 2022-06-02*
10
17
 
11
- * `fix` [#130](https://github.com/metabahn/corerb/pull/130) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
18
+ * `fix` [#130](https://github.com/bryanp/corerb/pull/130) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
12
19
 
13
- ## [v0.5.1](https://github.com/metabahn/corerb/releases/tag/2021-11-23.1)
20
+ ## [v0.5.1](https://github.com/bryanp/corerb/releases/tag/2021-11-23.1)
14
21
 
15
22
  *released on 2021-11-23*
16
23
 
17
- * `chg` [#109](https://github.com/metabahn/corerb/pull/109) Prefer `__send__` to `send` ([bryanp](https://github.com/bryanp))
24
+ * `chg` [#109](https://github.com/bryanp/corerb/pull/109) Prefer `__send__` to `send` ([bryanp](https://github.com/bryanp))
18
25
 
19
- ## [v0.5.0](https://github.com/metabahn/corerb/releases/tag/2021-11-06)
26
+ ## [v0.5.0](https://github.com/bryanp/corerb/releases/tag/2021-11-06)
20
27
 
21
28
  *released on 2021-11-06*
22
29
 
23
- * `add` [#105](https://github.com/metabahn/corerb/pull/105) Move pipeline control methods to their own module ([bryanp](https://github.com/bryanp))
30
+ * `add` [#105](https://github.com/bryanp/corerb/pull/105) Move pipeline control methods to their own module ([bryanp](https://github.com/bryanp))
24
31
 
25
- ## [v0.4.1](https://github.com/metabahn/corerb/releases/tag/2021-11-03)
32
+ ## [v0.4.1](https://github.com/bryanp/corerb/releases/tag/2021-11-03)
26
33
 
27
34
  *released on 2021-11-03*
28
35
 
29
- * `fix` [#99](https://github.com/metabahn/corerb/pull/99) Prevent pipelines from being recompiled unnecessarily ([bryanp](https://github.com/bryanp))
36
+ * `fix` [#99](https://github.com/bryanp/corerb/pull/99) Prevent pipelines from being recompiled unnecessarily ([bryanp](https://github.com/bryanp))
30
37
 
31
- ## [v0.4.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02.1)
38
+ ## [v0.4.0](https://github.com/bryanp/corerb/releases/tag/2021-11-02.1)
32
39
 
33
40
  *released on 2021-11-02*
34
41
 
35
- * `add` [#98](https://github.com/metabahn/corerb/pull/98) Add a finalizer to pipelines ([bryanp](https://github.com/bryanp))
42
+ * `add` [#98](https://github.com/bryanp/corerb/pull/98) Add a finalizer to pipelines ([bryanp](https://github.com/bryanp))
36
43
 
37
- ## [v0.3.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
44
+ ## [v0.3.0](https://github.com/bryanp/corerb/releases/tag/2021-11-02)
38
45
 
39
46
  *released on 2021-11-02*
40
47
 
41
- * `chg` [#97](https://github.com/metabahn/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
42
- * `chg` [#89](https://github.com/metabahn/corerb/pull/89) Allow the pipeline compiler to be extended ([bryanp](https://github.com/bryanp))
48
+ * `chg` [#97](https://github.com/bryanp/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
49
+ * `chg` [#89](https://github.com/bryanp/corerb/pull/89) Allow the pipeline compiler to be extended ([bryanp](https://github.com/bryanp))
43
50
 
44
- ## [v0.2.0](https://github.com/metabahn/corerb/releases/tag/2021-10-24)
51
+ ## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2021-10-24)
45
52
 
46
53
  *released on 2021-10-24*
47
54
 
48
- * `chg` [#77](https://github.com/metabahn/corerb/pull/77) Add recompile support to pipelines ([bryanp](https://github.com/bryanp))
55
+ * `chg` [#77](https://github.com/bryanp/corerb/pull/77) Add recompile support to pipelines ([bryanp](https://github.com/bryanp))
49
56
 
50
- ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-07-15)
57
+ ## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2021-07-15)
51
58
 
52
59
  *released on 2021-07-15*
53
60
 
54
- * `fix` [#81](https://github.com/metabahn/corerb/pull/81) Tie up loose ends around curried pipeline actions ([bryanp](https://github.com/bryanp))
55
- * `add` [#80](https://github.com/metabahn/corerb/pull/80) Define curried pipeline actions ([bryanp](https://github.com/bryanp))
56
- * `fix` [#69](https://github.com/metabahn/corerb/pull/69) Allow pipelines to be called at the class level ([bryanp](https://github.com/bryanp))
57
- * `add` [#64](https://github.com/metabahn/corerb/pull/64) Add a method for checking if a callable pipeline will call any actions ([bryanp](https://github.com/bryanp))
58
- * `chg` [#63](https://github.com/metabahn/corerb/pull/63) Improve inspect output for callable pipelines ([bryanp](https://github.com/bryanp))
59
- * `chg` [#61](https://github.com/metabahn/corerb/pull/61) Refactor pipelines to be more performant for new instances ([bryanp](https://github.com/bryanp))
60
- * `fix` [#59](https://github.com/metabahn/corerb/pull/59) Prevent collisions in auto-defined action names ([bryanp](https://github.com/bryanp))
61
- * `chg` [#58](https://github.com/metabahn/corerb/pull/58) Define pipeline actions with context ([bryanp](https://github.com/bryanp))
62
- * `chg` [#57](https://github.com/metabahn/corerb/pull/57) Avoid cache lookups for action calls when the action is just a method ([bryanp](https://github.com/bryanp))
63
- * `add` [#54](https://github.com/metabahn/corerb/pull/54) Make all pipeline objects inspectable ([bryanp](https://github.com/bryanp))
61
+ * `fix` [#81](https://github.com/bryanp/corerb/pull/81) Tie up loose ends around curried pipeline actions ([bryanp](https://github.com/bryanp))
62
+ * `add` [#80](https://github.com/bryanp/corerb/pull/80) Define curried pipeline actions ([bryanp](https://github.com/bryanp))
63
+ * `fix` [#69](https://github.com/bryanp/corerb/pull/69) Allow pipelines to be called at the class level ([bryanp](https://github.com/bryanp))
64
+ * `add` [#64](https://github.com/bryanp/corerb/pull/64) Add a method for checking if a callable pipeline will call any actions ([bryanp](https://github.com/bryanp))
65
+ * `chg` [#63](https://github.com/bryanp/corerb/pull/63) Improve inspect output for callable pipelines ([bryanp](https://github.com/bryanp))
66
+ * `chg` [#61](https://github.com/bryanp/corerb/pull/61) Refactor pipelines to be more performant for new instances ([bryanp](https://github.com/bryanp))
67
+ * `fix` [#59](https://github.com/bryanp/corerb/pull/59) Prevent collisions in auto-defined action names ([bryanp](https://github.com/bryanp))
68
+ * `chg` [#58](https://github.com/bryanp/corerb/pull/58) Define pipeline actions with context ([bryanp](https://github.com/bryanp))
69
+ * `chg` [#57](https://github.com/bryanp/corerb/pull/57) Avoid cache lookups for action calls when the action is just a method ([bryanp](https://github.com/bryanp))
70
+ * `add` [#54](https://github.com/bryanp/corerb/pull/54) Make all pipeline objects inspectable ([bryanp](https://github.com/bryanp))
64
71
 
65
- ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-07-07)
72
+ ## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-07-07)
66
73
 
67
74
  *released on 2021-07-07*
68
75
 
69
- * `add` [#37](https://github.com/metabahn/corerb/pull/37) Initial implementation of core-pipeline ([bryanp](https://github.com/bryanp))
76
+ * `add` [#37](https://github.com/bryanp/corerb/pull/37) Initial implementation of core-pipeline ([bryanp](https://github.com/bryanp))
70
77
 
71
78
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
4
- require "is/stateful"
3
+ require "core/inspect"
4
+ require "core/state"
5
5
  require "securerandom"
6
6
 
7
7
  module Core
@@ -9,7 +9,7 @@ module Core
9
9
  # [public] A pipeline action.
10
10
  #
11
11
  class Action
12
- include Is::Stateful
12
+ include Core::State
13
13
  state :__used_random_suffixes__, default: []
14
14
 
15
15
  class << self
@@ -53,7 +53,7 @@ module Core
53
53
  end
54
54
  end
55
55
 
56
- include Is::Inspectable
56
+ include Core::Inspect
57
57
 
58
58
  def initialize(name, before: nil, after: nil, context: nil, curry: false)
59
59
  @name = (name || self.class.build_name).to_sym
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
3
+ require "core/inspect"
4
4
 
5
5
  module Core
6
6
  module Pipeline
@@ -8,7 +8,7 @@ module Core
8
8
  # [public] A pipeline action defined as a block.
9
9
  #
10
10
  class Block < Action
11
- include Is::Inspectable
11
+ include Core::Inspect
12
12
 
13
13
  def initialize(name = nil, before: nil, after: nil, context: nil, curry: false, &block)
14
14
  @block = block
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
3
+ require "core/inspect"
4
4
 
5
5
  module Core
6
6
  module Pipeline
@@ -8,7 +8,7 @@ module Core
8
8
  # [public] A pipeline action defined as a method.
9
9
  #
10
10
  class Method < Action
11
- include Is::Inspectable
11
+ include Core::Inspect
12
12
 
13
13
  def initialize(name = nil, before: nil, after: nil, context: nil, curry: false)
14
14
  @method = nil
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Core
4
+ module Pipeline
5
+ module Behavior
6
+ # [public]
7
+ #
8
+ module Controller
9
+ # [public] Halts the execution of the pipeline, setting the pipeline's current value to the given object.
10
+ #
11
+ private def halt(value = nil)
12
+ raise Core::Pipeline::Signals::Halted.new(value)
13
+ end
14
+
15
+ # [public] Rejects the current action, skipping the rest of the action and calling remaining pipeline actions.
16
+ #
17
+ private def reject
18
+ raise Core::Pipeline::Signals::Rejected
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
3
+ require "core/inspect"
4
4
 
5
5
  require_relative "action"
6
6
  require_relative "compiler"
7
7
 
8
8
  module Core
9
9
  module Pipeline
10
- include Is::Inspectable
11
- inspects without: [:@object, :@mutex]
12
-
13
10
  # [public] Calls a pipeline on a pipelined object.
14
11
  #
15
12
  class Callable
13
+ include Core::Inspect
14
+ inspects without: [:@object, :@mutex]
15
+
16
16
  def initialize(object)
17
17
  @object = object
18
18
  @mutex = Mutex.new
@@ -64,7 +64,7 @@ module Core
64
64
  # [public] Replaces existing actions with actions from the given pipeline.
65
65
  #
66
66
  def use(pipeline)
67
- if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Is::Pipeline)
67
+ if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Core::Pipeline)
68
68
  @mutex.synchronize do
69
69
  @actions.clear
70
70
  @actions.concat(pipeline.pipeline.actions)
@@ -78,7 +78,7 @@ module Core
78
78
  # [public] Includes actions from the given pipeline.
79
79
  #
80
80
  def include(pipeline)
81
- if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Is::Pipeline)
81
+ if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Core::Pipeline)
82
82
  @actions.concat(pipeline.pipeline.actions)
83
83
  recompile if compiled?
84
84
  else
@@ -89,7 +89,7 @@ module Core
89
89
  # [public] Excludes actions from the given pipeline.
90
90
  #
91
91
  def exclude(pipeline)
92
- if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Is::Pipeline)
92
+ if (pipeline.is_a?(Class) || pipeline.is_a?(Module)) && pipeline.ancestors.include?(Core::Pipeline)
93
93
  pipeline.pipeline.actions.each do |action|
94
94
  @actions.delete(action)
95
95
  recompile if compiled?
@@ -162,18 +162,8 @@ module Core
162
162
 
163
163
  if callable_accepts_keyword_arguments_splat?(finalized)
164
164
  if callable_accepts_arguments_splat?(finalized)
165
- if RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
166
- proc { |*args, **kwargs, &block|
167
- finalized.call(*args.take(argument_count), *args[argument_count..], **kwargs.slice(*finalized_keywords), **kwargs.reject { |kwarg, _| finalized_keywords.include?(kwarg) }, &block)
168
- }
169
- else
170
- proc { |*args, **kwargs, &block|
171
- finalized.call(*args.take(argument_count), *args[argument_count..], **kwargs.slice(*finalized_keywords), **kwargs.except(*finalized_keywords), &block)
172
- }
173
- end
174
- elsif RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
175
165
  proc { |*args, **kwargs, &block|
176
- finalized.call(*args.take(argument_count), **kwargs.slice(*finalized_keywords), **kwargs.reject { |kwarg, _| finalized_keywords.include?(kwarg) }, &block)
166
+ finalized.call(*args.take(argument_count), *args[argument_count..], **kwargs.slice(*finalized_keywords), **kwargs.except(*finalized_keywords), &block)
177
167
  }
178
168
  else
179
169
  proc { |*args, **kwargs, &block|
@@ -191,18 +181,8 @@ module Core
191
181
  end
192
182
  elsif callable_accepts_keyword_arguments_splat?(finalized)
193
183
  if callable_accepts_arguments_splat?(finalized)
194
- if RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
195
- proc { |*args, **kwargs, &block|
196
- finalized.call(*args, **kwargs.slice(*finalized_keywords), **kwargs.reject { |kwarg, _| finalized_keywords.include?(kwarg) }, &block)
197
- }
198
- else
199
- proc { |*args, **kwargs, &block|
200
- finalized.call(*args, **kwargs.slice(*finalized_keywords), **kwargs.except(*finalized_keywords), &block)
201
- }
202
- end
203
- elsif RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
204
- proc { |*, **kwargs, &block|
205
- finalized.call(**kwargs.slice(*finalized_keywords), **kwargs.reject { |kwarg, _| finalized_keywords.include?(kwarg) }, &block)
184
+ proc { |*args, **kwargs, &block|
185
+ finalized.call(*args, **kwargs.slice(*finalized_keywords), **kwargs.except(*finalized_keywords), &block)
206
186
  }
207
187
  else
208
188
  proc { |*, **kwargs, &block|
@@ -287,11 +267,7 @@ module Core
287
267
  keywords_string = keywords.map { |keyword| ":#{keyword}" }.join(", ")
288
268
 
289
269
  if callable_accepts_keyword_arguments_splat?(method)
290
- if RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
291
- "**kwargs.slice(#{keywords_string}), **kwargs.reject { |kwarg, _| [#{keywords_string}].include?(kwarg) }"
292
- else
293
- "**kwargs.slice(#{keywords_string}), **kwargs.except(*#{keywords_string})"
294
- end
270
+ "**kwargs.slice(#{keywords_string}), **kwargs.except(*#{keywords_string})"
295
271
  else
296
272
  "**kwargs.slice(#{keywords_string})"
297
273
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
3
+ require "core/inspect"
4
4
 
5
5
  module Core
6
6
  module Pipeline
7
7
  module Signals
8
8
  class Halted < Exception
9
- include Is::Inspectable
9
+ include Core::Inspect
10
10
 
11
11
  def initialize(value)
12
12
  @value = value
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "is/inspectable"
3
+ require "core/inspect"
4
4
 
5
5
  module Core
6
6
  module Pipeline
7
7
  module Signals
8
8
  class Rejected < Exception
9
- include Is::Inspectable
9
+ include Core::Inspect
10
10
  end
11
11
  end
12
12
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Pipeline
5
- VERSION = "0.5.3"
5
+ VERSION = "0.6.0"
6
6
 
7
7
  def self.version
8
8
  VERSION
data/lib/core/pipeline.rb CHANGED
@@ -1,9 +1,120 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "core/extension"
4
+ require "core/state"
5
+
3
6
  module Core
7
+ # [public] Turn any object into a pipeline with actions.
8
+ #
4
9
  module Pipeline
10
+ require_relative "pipeline/behavior/controller"
11
+ require_relative "pipeline/callable"
12
+ require_relative "pipeline/compiler"
13
+ require_relative "pipeline/signals/halted"
14
+ require_relative "pipeline/signals/rejected"
5
15
  require_relative "pipeline/version"
16
+
17
+ extend Core::Extension
18
+
19
+ applies do |extended:|
20
+ # [public] The current callable pipeline.
21
+ #
22
+ state :pipeline, default: Callable.new(extended ? singleton_class : self)
23
+ end
24
+
25
+ extends dependencies: [
26
+ Core::State
27
+ ]
28
+
29
+ extends :definition do
30
+ # [public] Defines a pipeline action.
31
+ #
32
+ def action(*args, before: nil, after: nil, context: nil, curry: false, &block)
33
+ pipeline.action(*args, before: before, after: after, context: context, curry: curry, &block)
34
+ end
35
+
36
+ # [public] Skips the given action.
37
+ #
38
+ def skip_action(name)
39
+ pipeline.skip(name)
40
+ end
41
+
42
+ # [public] Replaces existing actions with actions from the given pipeline.
43
+ #
44
+ def use_pipeline(other_pipeline)
45
+ pipeline.use(other_pipeline)
46
+ end
47
+
48
+ # [public] Includes actions from the given pipeline.
49
+ #
50
+ def include_pipeline(other_pipeline)
51
+ pipeline.include(other_pipeline)
52
+ end
53
+
54
+ # [public] Excludes actions from the given pipeline.
55
+ #
56
+ def exclude_pipeline(other_pipeline)
57
+ pipeline.exclude(other_pipeline)
58
+ end
59
+
60
+ def inherited(subclass)
61
+ super
62
+
63
+ subclass.pipeline.relocate(subclass)
64
+ end
65
+ end
66
+
67
+ extends :implementation, dependencies: [Behavior::Controller] do
68
+ # [public] Calls a pipeline with arguments.
69
+ #
70
+ def call(...)
71
+ @pipeline.call(self, ...)
72
+ end
73
+
74
+ # [public] Defines a pipeline action, isolated to the instance.
75
+ #
76
+ def action(*args, before: nil, after: nil, context: nil, curry: false, &block)
77
+ pipeline.relocate(singleton_class)
78
+ pipeline.action(*args, before: before, after: after, context: context, curry: curry, &block)
79
+ end
80
+
81
+ # [public] Skips the given action, isolated to the instance.
82
+ #
83
+ def skip_action(name)
84
+ pipeline.relocate(singleton_class)
85
+ pipeline.skip(name)
86
+ end
87
+
88
+ # [public] Replaces existing actions with actions from the given pipeline, isolated to the instance.
89
+ #
90
+ def use_pipeline(other_pipeline)
91
+ pipeline.relocate(singleton_class)
92
+ pipeline.use(other_pipeline)
93
+ end
94
+
95
+ # [public] Includes actions from the given pipeline, isolated to the instance.
96
+ #
97
+ def include_pipeline(other_pipeline)
98
+ pipeline.relocate(singleton_class)
99
+ pipeline.include(other_pipeline)
100
+ end
101
+
102
+ # [public] Excludes actions from the given pipeline, isolated to the instance.
103
+ #
104
+ def exclude_pipeline(other_pipeline)
105
+ pipeline.relocate(singleton_class)
106
+ pipeline.exclude(other_pipeline)
107
+ end
108
+ end
109
+
110
+ extends :implementation, prepend: true do
111
+ # [public]
112
+ #
113
+ def finalize(...)
114
+ super if defined?(super)
115
+ pipeline.finalize
116
+ self
117
+ end
118
+ end
6
119
  end
7
120
  end
8
-
9
- require_relative "../is/pipeline"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-16 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-extension
@@ -16,44 +16,44 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: core-inspect
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.0'
33
+ version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.0'
40
+ version: '0.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: core-state
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.0'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.0'
54
+ version: '0.2'
55
55
  description: Turns Ruby objects into pipelines.
56
- email: bryan@metabahn.com
56
+ email: bryan@bryanp.org
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
@@ -64,14 +64,13 @@ files:
64
64
  - lib/core/pipeline/action.rb
65
65
  - lib/core/pipeline/actions/block.rb
66
66
  - lib/core/pipeline/actions/method.rb
67
+ - lib/core/pipeline/behavior/controller.rb
67
68
  - lib/core/pipeline/callable.rb
68
69
  - lib/core/pipeline/compiler.rb
69
70
  - lib/core/pipeline/signals/halted.rb
70
71
  - lib/core/pipeline/signals/rejected.rb
71
72
  - lib/core/pipeline/version.rb
72
- - lib/is/pipeline.rb
73
- - lib/is/pipeline/controller.rb
74
- homepage: https://github.com/metabahn/corerb/
73
+ homepage: https://github.com/bryanp/corerb/
75
74
  licenses:
76
75
  - MPL-2.0
77
76
  metadata: {}
@@ -83,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
82
  requirements:
84
83
  - - ">="
85
84
  - !ruby/object:Gem::Version
86
- version: '2.7'
85
+ version: '3.0'
87
86
  required_rubygems_version: !ruby/object:Gem::Requirement
88
87
  requirements:
89
88
  - - ">="
90
89
  - !ruby/object:Gem::Version
91
90
  version: '0'
92
91
  requirements: []
93
- rubygems_version: 3.4.12
92
+ rubygems_version: 3.5.1
94
93
  signing_key:
95
94
  specification_version: 4
96
95
  summary: Turns Ruby objects into pipelines.
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Is
4
- module Pipeline
5
- # [public]
6
- #
7
- module Controller
8
- # [public] Halts the execution of the pipeline, setting the pipeline's current value to the given object.
9
- #
10
- private def halt(value = nil)
11
- raise Core::Pipeline::Signals::Halted.new(value)
12
- end
13
-
14
- # [public] Rejects the current action, skipping the rest of the action and calling remaining pipeline actions.
15
- #
16
- private def reject
17
- raise Core::Pipeline::Signals::Rejected
18
- end
19
- end
20
- end
21
- end
data/lib/is/pipeline.rb DELETED
@@ -1,119 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "is/extension"
4
- require "is/stateful"
5
-
6
- require_relative "pipeline/controller"
7
- require_relative "../core/pipeline/callable"
8
- require_relative "../core/pipeline/compiler"
9
- require_relative "../core/pipeline/signals/halted"
10
- require_relative "../core/pipeline/signals/rejected"
11
-
12
- module Is
13
- # [public] Turns any object into a pipeline with actions.
14
- #
15
- module Pipeline
16
- extend Is::Extension
17
-
18
- applies do |extended:|
19
- # [public] The current callable pipeline.
20
- #
21
- state :pipeline, default: Core::Pipeline::Callable.new(extended ? singleton_class : self)
22
- end
23
-
24
- extends dependencies: [
25
- Is::Stateful
26
- ]
27
-
28
- extends :definition do
29
- # [public] Defines a pipeline action.
30
- #
31
- def action(*args, before: nil, after: nil, context: nil, curry: false, &block)
32
- pipeline.action(*args, before: before, after: after, context: context, curry: curry, &block)
33
- end
34
-
35
- # [public] Skips the given action.
36
- #
37
- def skip_action(name)
38
- pipeline.skip(name)
39
- end
40
-
41
- # [public] Replaces existing actions with actions from the given pipeline.
42
- #
43
- def use_pipeline(other_pipeline)
44
- pipeline.use(other_pipeline)
45
- end
46
-
47
- # [public] Includes actions from the given pipeline.
48
- #
49
- def include_pipeline(other_pipeline)
50
- pipeline.include(other_pipeline)
51
- end
52
-
53
- # [public] Excludes actions from the given pipeline.
54
- #
55
- def exclude_pipeline(other_pipeline)
56
- pipeline.exclude(other_pipeline)
57
- end
58
-
59
- def inherited(subclass)
60
- super
61
-
62
- subclass.pipeline.relocate(subclass)
63
- end
64
- end
65
-
66
- extends :implementation, dependencies: [Is::Pipeline::Controller] do
67
- # [public] Calls a pipeline with arguments.
68
- #
69
- def call(...)
70
- @pipeline.call(self, ...)
71
- end
72
-
73
- # [public] Defines a pipeline action, isolated to the instance.
74
- #
75
- def action(*args, before: nil, after: nil, context: nil, curry: false, &block)
76
- pipeline.relocate(singleton_class)
77
- pipeline.action(*args, before: before, after: after, context: context, curry: curry, &block)
78
- end
79
-
80
- # [public] Skips the given action, isolated to the instance.
81
- #
82
- def skip_action(name)
83
- pipeline.relocate(singleton_class)
84
- pipeline.skip(name)
85
- end
86
-
87
- # [public] Replaces existing actions with actions from the given pipeline, isolated to the instance.
88
- #
89
- def use_pipeline(other_pipeline)
90
- pipeline.relocate(singleton_class)
91
- pipeline.use(other_pipeline)
92
- end
93
-
94
- # [public] Includes actions from the given pipeline, isolated to the instance.
95
- #
96
- def include_pipeline(other_pipeline)
97
- pipeline.relocate(singleton_class)
98
- pipeline.include(other_pipeline)
99
- end
100
-
101
- # [public] Excludes actions from the given pipeline, isolated to the instance.
102
- #
103
- def exclude_pipeline(other_pipeline)
104
- pipeline.relocate(singleton_class)
105
- pipeline.exclude(other_pipeline)
106
- end
107
- end
108
-
109
- extends :implementation, prepend: true do
110
- # [public]
111
- #
112
- def finalize(...)
113
- super if defined?(super)
114
- pipeline.finalize
115
- self
116
- end
117
- end
118
- end
119
- end