core-pipeline 0.2.0 → 0.3.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 +7 -0
- data/lib/core/pipeline/action.rb +3 -3
- data/lib/core/pipeline/callable.rb +6 -1
- data/lib/core/pipeline/compiler.rb +27 -18
- data/lib/core/pipeline/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53ee7741ae5354263c5f7d426eb7ad9b500c01bb4a1ee4c665ce11d054819cea
|
4
|
+
data.tar.gz: 8c7e495b2681c54b59e38cc066987e0f52e3ba8a5673f8285c821a38eea98e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 757e21b99dbb927b0d75f4dbd8f036e3235a982aa9a449260bcb4e4ff09f3a20afb788c3ddcd213d2a75d5b44e105f69bf512a6515991cc97282e584e4a617f7
|
7
|
+
data.tar.gz: 241b54f107db94c7fa5afeb1a075d2df1b3cd92c97bc54c9cb3935c283d6b2085d67eb1aeb85d2cb724b0cc6785f3bacb64062233ab50c5150f44bfd70603636
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [v0.3.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
|
2
|
+
|
3
|
+
*released on 2021-11-02*
|
4
|
+
|
5
|
+
* `chg` [#97](https://github.com/metabahn/corerb/pull/97) Designate internal state with leading and trailing double underscores ([bryanp](https://github.com/bryanp))
|
6
|
+
* `chg` [#89](https://github.com/metabahn/corerb/pull/89) Allow the pipeline compiler to be extended ([bryanp](https://github.com/bryanp))
|
7
|
+
|
1
8
|
## [v0.2.0](https://github.com/metabahn/corerb/releases/tag/2021-10-24)
|
2
9
|
|
3
10
|
*released on 2021-10-24*
|
data/lib/core/pipeline/action.rb
CHANGED
@@ -10,7 +10,7 @@ module Core
|
|
10
10
|
#
|
11
11
|
class Action
|
12
12
|
include Is::Stateful
|
13
|
-
state :
|
13
|
+
state :__used_random_suffixes__, default: []
|
14
14
|
|
15
15
|
class << self
|
16
16
|
# [public] Builds an action for a given target.
|
@@ -40,10 +40,10 @@ module Core
|
|
40
40
|
|
41
41
|
def build_name
|
42
42
|
suffix = generate_random_suffix
|
43
|
-
if
|
43
|
+
if __used_random_suffixes__.include?(suffix)
|
44
44
|
build_name
|
45
45
|
else
|
46
|
-
|
46
|
+
__used_random_suffixes__ << suffix
|
47
47
|
"action_#{suffix}"
|
48
48
|
end
|
49
49
|
end
|
@@ -19,6 +19,7 @@ module Core
|
|
19
19
|
@actions = []
|
20
20
|
@skipped = []
|
21
21
|
@compiled = false
|
22
|
+
@compiler = Compiler
|
22
23
|
end
|
23
24
|
|
24
25
|
def initialize_copy(...)
|
@@ -30,6 +31,10 @@ module Core
|
|
30
31
|
attr_reader :actions
|
31
32
|
attr_reader :skipped
|
32
33
|
|
34
|
+
# [public]
|
35
|
+
#
|
36
|
+
attr_writer :compiler
|
37
|
+
|
33
38
|
# [public] Relocates to another object context.
|
34
39
|
#
|
35
40
|
def relocate(object)
|
@@ -101,7 +106,7 @@ module Core
|
|
101
106
|
end
|
102
107
|
|
103
108
|
private def compile
|
104
|
-
instance_eval(
|
109
|
+
instance_eval(@compiler.compile(self, @object), __FILE__, __LINE__ - 1)
|
105
110
|
@compiled = true
|
106
111
|
self
|
107
112
|
end
|
@@ -21,32 +21,39 @@ module Core
|
|
21
21
|
CODE
|
22
22
|
end
|
23
23
|
|
24
|
+
# [public]
|
25
|
+
#
|
24
26
|
private def compile_call(callable, object)
|
25
27
|
compiled = +""
|
26
|
-
finalized_actions(callable, object).
|
27
|
-
compiled << "begin
|
28
|
+
finalized_actions(callable, object).each_value do |action|
|
29
|
+
compiled << "begin\n"
|
30
|
+
compiled << compile_action(action, object)
|
31
|
+
compiled << "rescue Core::Pipeline::Signals::Rejected\n"
|
32
|
+
compiled << "end\n"
|
33
|
+
end
|
28
34
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
compiled
|
36
|
+
end
|
37
|
+
|
38
|
+
# [public]
|
39
|
+
#
|
40
|
+
private def compile_action(action, object)
|
41
|
+
case action[:finalized]
|
42
|
+
when Symbol
|
43
|
+
if object.private_method_defined?(action[:finalized])
|
44
|
+
"object.send(#{action[:finalized].inspect}, ...)\n"
|
36
45
|
else
|
37
|
-
"
|
46
|
+
"object.#{action[:finalized]}(...)\n"
|
38
47
|
end
|
39
|
-
|
40
|
-
|
48
|
+
else
|
49
|
+
"@__finalized_actions__[#{action[:object_id]}][:finalized].call(...)\n"
|
41
50
|
end
|
42
|
-
|
43
|
-
compiled
|
44
51
|
end
|
45
52
|
|
46
53
|
private def finalized_actions(callable, object)
|
47
54
|
validate_skipped_actions(callable)
|
48
55
|
finalized_actions = build_finalized_actions(callable, object)
|
49
|
-
callable.instance_variable_set(:@
|
56
|
+
callable.instance_variable_set(:@__finalized_actions__, finalized_actions)
|
50
57
|
end
|
51
58
|
|
52
59
|
private def validate_skipped_actions(callable)
|
@@ -63,13 +70,15 @@ module Core
|
|
63
70
|
}.map { |action|
|
64
71
|
finalized = action.finalize(object)
|
65
72
|
|
66
|
-
if action.curried?
|
73
|
+
finalized = if action.curried?
|
67
74
|
wrap_finalized_action_for_context(finalized, action.context || object)
|
68
75
|
else
|
69
76
|
finalized
|
70
77
|
end
|
78
|
+
|
79
|
+
{object: action, finalized: finalized, object_id: finalized.object_id}
|
71
80
|
}.each_with_object({}) { |action, lookup|
|
72
|
-
lookup[action
|
81
|
+
lookup[action[:object_id]] = action
|
73
82
|
}
|
74
83
|
end
|
75
84
|
|
@@ -137,7 +146,7 @@ module Core
|
|
137
146
|
|
138
147
|
code = <<~CODE
|
139
148
|
def #{wrapped_name}(*args, **kwargs, &block)
|
140
|
-
|
149
|
+
self.#{finalized}(#{signature})
|
141
150
|
end
|
142
151
|
CODE
|
143
152
|
|
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.3.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: 2021-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: core-extension
|