core-pipeline 0.5.2 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +41 -28
- data/lib/core/pipeline/action.rb +4 -4
- data/lib/core/pipeline/actions/block.rb +2 -2
- data/lib/core/pipeline/actions/method.rb +2 -2
- data/lib/core/pipeline/behavior/controller.rb +23 -0
- data/lib/core/pipeline/callable.rb +7 -7
- data/lib/core/pipeline/compiler.rb +4 -28
- data/lib/core/pipeline/signals/halted.rb +2 -2
- data/lib/core/pipeline/signals/rejected.rb +2 -2
- data/lib/core/pipeline/version.rb +1 -1
- data/lib/core/pipeline.rb +113 -2
- metadata +13 -14
- data/lib/is/pipeline/controller.rb +0 -21
- data/lib/is/pipeline.rb +0 -113
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44d424c0972800b001899d14050c9e8dd4ce9222fe9e41aaccb0824f83e8f75e
|
|
4
|
+
data.tar.gz: f2ab047a40c9f8bb693af5a021fd44b791750e1b9ed5cf6b00fb1c08473b9467
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d1dfba6cf558d16f8cf0356e02a44a738da2f7ea172024e5c289fe2eac8afdf601819b8bf11b08c6a42460dd4e74adf24290fbab788b709f671f8a8c5e70c26
|
|
7
|
+
data.tar.gz: 4c5bc79f03e307c3e2d43dea785dd1fec7524b99981957eed72658f125d291bd996a6e7b1a33396833a4748f22a7151cdb6351566233c6e07ba11057ffd5023e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,65 +1,78 @@
|
|
|
1
|
-
## [v0.
|
|
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)
|
|
9
|
+
|
|
10
|
+
*released on 2023-07-16*
|
|
11
|
+
|
|
12
|
+
* `fix` [#133](https://github.com/bryanp/corerb/pull/133) Isolate pipelines when subclassed ([bryanp](https://github.com/bryanp))
|
|
13
|
+
|
|
14
|
+
## [v0.5.2](https://github.com/bryanp/corerb/releases/tag/2022-06-02)
|
|
2
15
|
|
|
3
16
|
*released on 2022-06-02*
|
|
4
17
|
|
|
5
|
-
* `fix` [#130](https://github.com/
|
|
18
|
+
* `fix` [#130](https://github.com/bryanp/corerb/pull/130) Accept all arguments in prepended finalize ([bryanp](https://github.com/bryanp))
|
|
6
19
|
|
|
7
|
-
## [v0.5.1](https://github.com/
|
|
20
|
+
## [v0.5.1](https://github.com/bryanp/corerb/releases/tag/2021-11-23.1)
|
|
8
21
|
|
|
9
22
|
*released on 2021-11-23*
|
|
10
23
|
|
|
11
|
-
* `chg` [#109](https://github.com/
|
|
24
|
+
* `chg` [#109](https://github.com/bryanp/corerb/pull/109) Prefer `__send__` to `send` ([bryanp](https://github.com/bryanp))
|
|
12
25
|
|
|
13
|
-
## [v0.5.0](https://github.com/
|
|
26
|
+
## [v0.5.0](https://github.com/bryanp/corerb/releases/tag/2021-11-06)
|
|
14
27
|
|
|
15
28
|
*released on 2021-11-06*
|
|
16
29
|
|
|
17
|
-
* `add` [#105](https://github.com/
|
|
30
|
+
* `add` [#105](https://github.com/bryanp/corerb/pull/105) Move pipeline control methods to their own module ([bryanp](https://github.com/bryanp))
|
|
18
31
|
|
|
19
|
-
## [v0.4.1](https://github.com/
|
|
32
|
+
## [v0.4.1](https://github.com/bryanp/corerb/releases/tag/2021-11-03)
|
|
20
33
|
|
|
21
34
|
*released on 2021-11-03*
|
|
22
35
|
|
|
23
|
-
* `fix` [#99](https://github.com/
|
|
36
|
+
* `fix` [#99](https://github.com/bryanp/corerb/pull/99) Prevent pipelines from being recompiled unnecessarily ([bryanp](https://github.com/bryanp))
|
|
24
37
|
|
|
25
|
-
## [v0.4.0](https://github.com/
|
|
38
|
+
## [v0.4.0](https://github.com/bryanp/corerb/releases/tag/2021-11-02.1)
|
|
26
39
|
|
|
27
40
|
*released on 2021-11-02*
|
|
28
41
|
|
|
29
|
-
* `add` [#98](https://github.com/
|
|
42
|
+
* `add` [#98](https://github.com/bryanp/corerb/pull/98) Add a finalizer to pipelines ([bryanp](https://github.com/bryanp))
|
|
30
43
|
|
|
31
|
-
## [v0.3.0](https://github.com/
|
|
44
|
+
## [v0.3.0](https://github.com/bryanp/corerb/releases/tag/2021-11-02)
|
|
32
45
|
|
|
33
46
|
*released on 2021-11-02*
|
|
34
47
|
|
|
35
|
-
* `chg` [#97](https://github.com/
|
|
36
|
-
* `chg` [#89](https://github.com/
|
|
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))
|
|
37
50
|
|
|
38
|
-
## [v0.2.0](https://github.com/
|
|
51
|
+
## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2021-10-24)
|
|
39
52
|
|
|
40
53
|
*released on 2021-10-24*
|
|
41
54
|
|
|
42
|
-
* `chg` [#77](https://github.com/
|
|
55
|
+
* `chg` [#77](https://github.com/bryanp/corerb/pull/77) Add recompile support to pipelines ([bryanp](https://github.com/bryanp))
|
|
43
56
|
|
|
44
|
-
## [v0.1.0](https://github.com/
|
|
57
|
+
## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2021-07-15)
|
|
45
58
|
|
|
46
59
|
*released on 2021-07-15*
|
|
47
60
|
|
|
48
|
-
* `fix` [#81](https://github.com/
|
|
49
|
-
* `add` [#80](https://github.com/
|
|
50
|
-
* `fix` [#69](https://github.com/
|
|
51
|
-
* `add` [#64](https://github.com/
|
|
52
|
-
* `chg` [#63](https://github.com/
|
|
53
|
-
* `chg` [#61](https://github.com/
|
|
54
|
-
* `fix` [#59](https://github.com/
|
|
55
|
-
* `chg` [#58](https://github.com/
|
|
56
|
-
* `chg` [#57](https://github.com/
|
|
57
|
-
* `add` [#54](https://github.com/
|
|
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))
|
|
58
71
|
|
|
59
|
-
## [v0.0.0](https://github.com/
|
|
72
|
+
## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-07-07)
|
|
60
73
|
|
|
61
74
|
*released on 2021-07-07*
|
|
62
75
|
|
|
63
|
-
* `add` [#37](https://github.com/
|
|
76
|
+
* `add` [#37](https://github.com/bryanp/corerb/pull/37) Initial implementation of core-pipeline ([bryanp](https://github.com/bryanp))
|
|
64
77
|
|
|
65
78
|
|
data/lib/core/pipeline/action.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
4
|
-
require "
|
|
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
|
|
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
|
|
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 "
|
|
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
|
|
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 "
|
|
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
|
|
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 "
|
|
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?(
|
|
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?(
|
|
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?(
|
|
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.
|
|
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
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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 "
|
|
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
|
|
9
|
+
include Core::Inspect
|
|
10
10
|
|
|
11
11
|
def initialize(value)
|
|
12
12
|
@value = value
|
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.
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
54
|
+
version: '0.2'
|
|
55
55
|
description: Turns Ruby objects into pipelines.
|
|
56
|
-
email: bryan@
|
|
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
|
-
|
|
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: '
|
|
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.
|
|
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,113 +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
|
-
end
|
|
59
|
-
|
|
60
|
-
extends :implementation, dependencies: [Is::Pipeline::Controller] do
|
|
61
|
-
# [public] Calls a pipeline with arguments.
|
|
62
|
-
#
|
|
63
|
-
def call(...)
|
|
64
|
-
@pipeline.call(self, ...)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# [public] Defines a pipeline action, isolated to the instance.
|
|
68
|
-
#
|
|
69
|
-
def action(*args, before: nil, after: nil, context: nil, curry: false, &block)
|
|
70
|
-
pipeline.relocate(singleton_class)
|
|
71
|
-
pipeline.action(*args, before: before, after: after, context: context, curry: curry, &block)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# [public] Skips the given action, isolated to the instance.
|
|
75
|
-
#
|
|
76
|
-
def skip_action(name)
|
|
77
|
-
pipeline.relocate(singleton_class)
|
|
78
|
-
pipeline.skip(name)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# [public] Replaces existing actions with actions from the given pipeline, isolated to the instance.
|
|
82
|
-
#
|
|
83
|
-
def use_pipeline(other_pipeline)
|
|
84
|
-
pipeline.relocate(singleton_class)
|
|
85
|
-
pipeline.use(other_pipeline)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# [public] Includes actions from the given pipeline, isolated to the instance.
|
|
89
|
-
#
|
|
90
|
-
def include_pipeline(other_pipeline)
|
|
91
|
-
pipeline.relocate(singleton_class)
|
|
92
|
-
pipeline.include(other_pipeline)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# [public] Excludes actions from the given pipeline, isolated to the instance.
|
|
96
|
-
#
|
|
97
|
-
def exclude_pipeline(other_pipeline)
|
|
98
|
-
pipeline.relocate(singleton_class)
|
|
99
|
-
pipeline.exclude(other_pipeline)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
extends :implementation, prepend: true do
|
|
104
|
-
# [public]
|
|
105
|
-
#
|
|
106
|
-
def finalize(...)
|
|
107
|
-
super if defined?(super)
|
|
108
|
-
pipeline.finalize
|
|
109
|
-
self
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|