eco-helpers 2.6.0 → 2.6.2
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 +91 -1
- data/README.md +5 -0
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/class_helpers.rb +1 -1
- data/lib/eco/api/common/loaders/base.rb +5 -0
- data/lib/eco/api/common/loaders/case_base.rb +0 -2
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +78 -0
- data/lib/eco/api/common/loaders/config/workflow.rb +11 -0
- data/lib/eco/api/common/loaders/config.rb +29 -0
- data/lib/eco/api/common/loaders/error_handler.rb +0 -2
- data/lib/eco/api/common/loaders/parser.rb +0 -1
- data/lib/eco/api/common/loaders/policy.rb +0 -2
- data/lib/eco/api/common/loaders.rb +1 -0
- data/lib/eco/api/common/session/mailer.rb +3 -1
- data/lib/eco/api/common/version_patches/exception.rb +2 -2
- data/lib/eco/api/common/version_patches/ruby3/object.rb +18 -0
- data/lib/eco/api/common/version_patches/ruby3.rb +1 -0
- data/lib/eco/api/common/version_patches.rb +3 -0
- data/lib/eco/api/custom/config.rb +10 -0
- data/lib/eco/api/custom/mailer.rb +9 -0
- data/lib/eco/api/custom/namespace.rb +2 -0
- data/lib/eco/api/custom/workflow.rb +9 -0
- data/lib/eco/api/custom.rb +3 -0
- data/lib/eco/api/session/batch/base_policy.rb +13 -5
- data/lib/eco/api/session/batch/job.rb +10 -7
- data/lib/eco/api/session/config/tagtree.rb +15 -1
- data/lib/eco/api/session/config/workflow.rb +94 -58
- data/lib/eco/api/session/config.rb +2 -2
- data/lib/eco/api/usecases/base_io.rb +50 -4
- data/lib/eco/api/usecases/cli/dsl.rb +23 -13
- data/lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb +5 -0
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +12 -4
- data/lib/eco/api/usecases/graphql/helpers/location/base.rb +1 -2
- data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +62 -0
- data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +59 -0
- data/lib/eco/api/usecases/ooze_samples/helpers.rb +2 -0
- data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +2 -1
- data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +2 -26
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +64 -47
- data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +8 -0
- data/lib/eco/api/usecases/use_case.rb +12 -2
- data/lib/eco/assets.rb +2 -2
- data/lib/eco/cli_default/workflow.rb +102 -120
- data/lib/eco/data/locations/node_base/tag_validations.rb +19 -9
- data/lib/eco/data/locations/node_base/treeify.rb +193 -18
- data/lib/eco/data/locations/node_diff/nodes_diff.rb +11 -9
- data/lib/eco/data/locations/node_diff/selectors.rb +1 -1
- data/lib/eco/data/locations/node_level.rb +1 -1
- data/lib/eco/data/locations/node_plain/parsing.rb +1 -1
- data/lib/eco/data/locations/node_plain/serial.rb +1 -1
- data/lib/eco/data/locations/node_plain.rb +4 -3
- data/lib/eco/language/klass/when_inherited.rb +17 -0
- data/lib/eco/language/klass.rb +8 -0
- data/lib/eco/language/methods/delegate_missing.rb +28 -0
- data/lib/eco/language/methods/dsl_able.rb +25 -0
- data/lib/eco/language/methods.rb +9 -0
- data/lib/eco/language.rb +2 -0
- data/lib/eco/version.rb +1 -1
- metadata +18 -3
@@ -12,14 +12,31 @@ module Eco::Data::Locations::NodeBase
|
|
12
12
|
# @yieldreturn [Hash] custom hash model when treeifying (allows to set more keys/properties).
|
13
13
|
# @nodes [Array<NodeBase>] list of nodes
|
14
14
|
# @return [Array<Hash>] a hierarchical tree of nested Hashes via `nodes` key.
|
15
|
-
def treeify(nodes, &block)
|
15
|
+
def treeify(nodes, skipped: [], unlinked_trees: [], &block)
|
16
16
|
return [] if nodes.empty?
|
17
17
|
block ||= nodes.first.class.serializer
|
18
|
-
|
18
|
+
done_ids = {}
|
19
|
+
warns = []
|
20
|
+
parents = parents_hash(nodes)
|
21
|
+
get_children(nil, parents, done_ids: done_ids, skipped: skipped, warns: warns, &block).tap do |tree|
|
22
|
+
check_results(
|
23
|
+
tree,
|
24
|
+
nodes,
|
25
|
+
parents,
|
26
|
+
done_ids: done_ids,
|
27
|
+
skipped: skipped,
|
28
|
+
unlinked_trees: unlinked_trees,
|
29
|
+
warns: warns,
|
30
|
+
&block
|
31
|
+
)
|
32
|
+
log(:warn) { warns.join("\n") } unless warns.empty?
|
33
|
+
end
|
19
34
|
end
|
20
35
|
|
21
36
|
private
|
22
37
|
|
38
|
+
# @return [Hash] where `key`s are all the `parentId` of the nodes
|
39
|
+
# and `value` and `Array` of those nodes that have that `parentId`
|
23
40
|
def parents_hash(nodes)
|
24
41
|
nodes.each_with_object({}) do |node, parents|
|
25
42
|
(parents[node.parentId] ||= []).push(node)
|
@@ -32,12 +49,21 @@ module Eco::Data::Locations::NodeBase
|
|
32
49
|
# 3. The above can translate into some
|
33
50
|
# @yield [node]
|
34
51
|
# @yieldreturn [Hash] custom hash model when treeifying
|
35
|
-
def get_children(node_id, parents, parent: nil, done_ids: {},
|
52
|
+
def get_children(node_id, parents, parent: nil, level: 0, done_ids: {}, skipped: [], warns: [], &block)
|
36
53
|
level_ids = []
|
37
54
|
(parents[node_id] ||= []).each_with_object([]) do |child, results|
|
38
55
|
# Skipping done id. Add proper warnings...
|
39
56
|
# => rely on `done_ids` to identify if an `id` has already been done
|
40
|
-
next report_skipped_node(
|
57
|
+
next report_skipped_node(
|
58
|
+
child,
|
59
|
+
parent,
|
60
|
+
done_ids,
|
61
|
+
level,
|
62
|
+
level_ids,
|
63
|
+
parents,
|
64
|
+
skipped: skipped,
|
65
|
+
warns: warns
|
66
|
+
) if done_ids[child.id]
|
41
67
|
|
42
68
|
# Fill in tracking data
|
43
69
|
child.parent = parent
|
@@ -52,8 +78,26 @@ module Eco::Data::Locations::NodeBase
|
|
52
78
|
node_hash.merge(yield(child)) if block_given?
|
53
79
|
# we must register the `id` before recursing down
|
54
80
|
done_ids[child.id] = child
|
81
|
+
|
82
|
+
children = get_children(
|
83
|
+
child.id,
|
84
|
+
parents,
|
85
|
+
parent: child,
|
86
|
+
done_ids: done_ids,
|
87
|
+
level: level + 1,
|
88
|
+
skipped: skipped,
|
89
|
+
warns: warns,
|
90
|
+
&block
|
91
|
+
).tap do |desc|
|
92
|
+
if (nil_count = desc.count(nil)) > 0
|
93
|
+
log(:debug) {
|
94
|
+
"get_children gave #{nil_count} nil values for nodes of #{child.id}"
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
55
99
|
results << node_hash.merge({
|
56
|
-
"nodes" =>
|
100
|
+
"nodes" => children.compact
|
57
101
|
})
|
58
102
|
end
|
59
103
|
end
|
@@ -70,8 +114,138 @@ module Eco::Data::Locations::NodeBase
|
|
70
114
|
"#{" " * level}"
|
71
115
|
end
|
72
116
|
|
73
|
-
#
|
74
|
-
|
117
|
+
# Method to ensure the results are consistent
|
118
|
+
# @param skipped [Array<NodePlain>] those skipped because repeated
|
119
|
+
# 1. It will add children of them that were skipped. This won't clash with unlinked nodes
|
120
|
+
# because otherwise would be part of `done_ids` anyway.
|
121
|
+
# @param unlinked_trees [Array<Hash>] by excluding those done and skipped,
|
122
|
+
# it will treeify the unlinked nodes (the exclusion applies to `parants_hash`)
|
123
|
+
def check_results(tree, nodes, parents, done_ids: {}, skipped: [], unlinked_trees: [], warns: [], &block)
|
124
|
+
update_skipped(skipped, parents, done_ids: done_ids) unless skipped.empty?
|
125
|
+
|
126
|
+
if done_ids.count != nodes.count
|
127
|
+
tracked_nodes = done_ids.values
|
128
|
+
untracked_nodes = nodes - tracked_nodes - skipped
|
129
|
+
# skipped keys is inherent, as they were excluded because of id clash with done_ids
|
130
|
+
unlinked_parent_ids = (parents.keys - done_ids.keys).compact
|
131
|
+
|
132
|
+
msg = []
|
133
|
+
|
134
|
+
# The reason of missing nodes in the output tree is unknown!
|
135
|
+
if skipped.empty? && unlinked_parent_ids.empty?
|
136
|
+
msg << "BUG in this library (open issue with maintainers)."
|
137
|
+
msg << "There were no skipped nodes nor missin referred parents, and yet:"
|
138
|
+
msg << " • the tree nodes count: #{done_ids.count} ..."
|
139
|
+
msg << " • doesn't match the original nodes count: #{nodes.count}"
|
140
|
+
raise msg.join("\n")
|
141
|
+
end
|
142
|
+
|
143
|
+
unless unlinked_parent_ids.empty?
|
144
|
+
msg << "There are #{unlinked_parent_ids.count} referred parent_id's NOT linked to the root:"
|
145
|
+
msg << " • total_nodes: #{nodes.count}"
|
146
|
+
msg << " • tracked_nodes: #{tracked_nodes.count}"
|
147
|
+
msg << " • untracked_nodes: #{untracked_nodes.count}"
|
148
|
+
msg << " • unlinked_parents: #{unlinked_parent_ids.count}"
|
149
|
+
msg << " • skipped (repeated) nodes: #{skipped.count}" unless skipped.empty?
|
150
|
+
|
151
|
+
unlinked_nodes = nodes - skipped
|
152
|
+
unlinked_parents = parents.slice(*unlinked_parent_ids) # doesn'thave skipped ones
|
153
|
+
|
154
|
+
residual_skipped = []
|
155
|
+
unlinked_trees.concat \
|
156
|
+
get_unlinked_trees(
|
157
|
+
unlinked_nodes,
|
158
|
+
unlinked_parents,
|
159
|
+
done_ids: done_ids,
|
160
|
+
skipped: residual_skipped,
|
161
|
+
warns: warns,
|
162
|
+
&block
|
163
|
+
)
|
164
|
+
|
165
|
+
update_skipped(skipped, parents, with: residual_skipped, done_ids: done_ids) unless residual_skipped.empty?
|
166
|
+
|
167
|
+
tracked_nodes = done_ids.values
|
168
|
+
untracked_nodes = nodes - tracked_nodes - skipped
|
169
|
+
unlinked_parent_ids = (parents.keys - done_ids.keys).compact
|
170
|
+
|
171
|
+
msg << "After treeifying via the unlinked_parents:"
|
172
|
+
msg << " • total_nodes: #{nodes.count}"
|
173
|
+
msg << " • tracked_nodes: #{tracked_nodes.count}"
|
174
|
+
msg << " • untracked_nodes: #{untracked_nodes.count}"
|
175
|
+
msg << " • unlinked_parents: #{unlinked_parent_ids.count}"
|
176
|
+
msg << " • skipped in this step: #{residual_skipped.count}"
|
177
|
+
end
|
178
|
+
|
179
|
+
msg << " • total skipped (repeated) nodes: #{skipped.count} !!" unless skipped.empty?
|
180
|
+
warns << msg.join("\n")
|
181
|
+
nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Treeifies the unlinked nodes by scoping existing parent ids.
|
186
|
+
def get_unlinked_trees(nodes, parents, done_ids: {}, skipped: [], warns: [], &block)
|
187
|
+
node_ids = nodes.map(&:id)
|
188
|
+
parent_ids = parents.keys & node_ids
|
189
|
+
missing_parent_ids = parents.keys - parent_ids
|
190
|
+
missing_parents = parents.slice(*missing_parent_ids)
|
191
|
+
warns << " • missing_parents: #{missing_parents.count}"
|
192
|
+
nil_parent_nodes = missing_parents.each_with_object([]) do |(id, nodes), mem|
|
193
|
+
nodes.each {|node| node.parent_id = nil}
|
194
|
+
mem.concat(nodes)
|
195
|
+
end
|
196
|
+
rest_parents = parents.slice(*parent_ids).merge({
|
197
|
+
nil => nil_parent_nodes
|
198
|
+
})
|
199
|
+
get_children(nil, rest_parents, done_ids: done_ids, skipped: skipped, warns: warns, &block)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Same as `get_children` but not performing checks and with
|
203
|
+
# option to retrieve the source nodes (rather than parsing to `Hash`).
|
204
|
+
# @note serves the purpose to identify what linked children got inherently
|
205
|
+
# skipped, because their parent was skipped.
|
206
|
+
def get_tree_nodes_raw(node_id, parents, src_plain: true, &block)
|
207
|
+
(parents[node_id] ||= []).each_with_object([]) do |child, results|
|
208
|
+
unless src_plain
|
209
|
+
node_hash = {
|
210
|
+
"id" => child.id,
|
211
|
+
"name" => child.name,
|
212
|
+
"parent_id" => node_id
|
213
|
+
}
|
214
|
+
node_hash.merge(yield(child)) if block_given?
|
215
|
+
end
|
216
|
+
|
217
|
+
descendants = get_tree_nodes_raw(child.id, parents, src_plain: src_plain, &block).tap do |desc|
|
218
|
+
if (nil_count = desc.count(nil)) > 0
|
219
|
+
puts "get_tree_nodes_raw gave #{nil_count} nil values for nodes of #{child.id}"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
if src_plain
|
224
|
+
results.concat(descendants)
|
225
|
+
else
|
226
|
+
results << node_hash.merge({
|
227
|
+
"nodes" => descendants.compact
|
228
|
+
})
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
# It goes through the `with` skipped nodes, and adds them to the `skipped` ones
|
234
|
+
# by including their not tracked/done/included children.
|
235
|
+
def update_skipped(skipped, parents, with: skipped, done_ids: {})
|
236
|
+
raw_skipped_children = with.each_with_object([]) do |node, mem|
|
237
|
+
mem << node
|
238
|
+
mem.concat get_tree_nodes_raw(node.id, parents)
|
239
|
+
end.uniq
|
240
|
+
skipped_children = raw_skipped_children - done_ids.values
|
241
|
+
skipped.concat(skipped_children).uniq!
|
242
|
+
skipped
|
243
|
+
end
|
244
|
+
|
245
|
+
# With given a skipped `node` (repeated `id`), it gives different warnings,
|
246
|
+
# provided that the context in which the double-up `id` happened is identified.
|
247
|
+
def report_skipped_node(node, parent, done_ids, level, level_ids, parents, skipped: [], warns: [])
|
248
|
+
skipped << node
|
75
249
|
lev = level + 1
|
76
250
|
done_node = done_ids[node.id]
|
77
251
|
prev_parent = node.parent
|
@@ -84,6 +258,9 @@ module Eco::Data::Locations::NodeBase
|
|
84
258
|
row_str = row_num ? "(Row: #{row_num}) " : ''
|
85
259
|
node_str = "#{row_str}Node '#{node.id}' #{level_msg(lev)} (#{parent_msg(parent)})"
|
86
260
|
|
261
|
+
msg = []
|
262
|
+
msg << "#{indent(level)}Skipping #{node_str}."
|
263
|
+
|
87
264
|
# Implementation integrity guard
|
88
265
|
# => as we don't register in `done_ids` those that are skipped,
|
89
266
|
# when a `node` has already a tracked `parent` or `level`,
|
@@ -114,18 +291,15 @@ module Eco::Data::Locations::NodeBase
|
|
114
291
|
cyclic = multi_parent && done_node == node
|
115
292
|
double_up = node_dup || lev_dup
|
116
293
|
|
117
|
-
msg = []
|
118
|
-
msg << "#{indent(level)}WARNING: Skipping #{node_str}."
|
119
|
-
|
120
294
|
if cyclic
|
121
|
-
str = "#{indent(level
|
295
|
+
str = "#{indent(level + 1)}Cyclic definition. By skipping the node, "
|
122
296
|
str << "it will remain as #{parent_msg(done_node.parent)} (#{level_msg(prev_level)})."
|
123
297
|
msg << str
|
124
298
|
end
|
125
299
|
|
126
300
|
if double_up
|
127
|
-
str = "#{indent(level
|
128
|
-
str << "as #{parent_msg(
|
301
|
+
str = "#{indent(level + 1)}Node ID was already tracked as #{level_msg(done_node.tracked_level)}, "
|
302
|
+
str << "as #{parent_msg(done_node.parent)} "
|
129
303
|
str << "(same parent)." if lev_dup
|
130
304
|
str << "(different parent)." if multi_parent
|
131
305
|
msg << str
|
@@ -133,18 +307,19 @@ module Eco::Data::Locations::NodeBase
|
|
133
307
|
|
134
308
|
unless cyclic || double_up
|
135
309
|
str = "Integrity issue in Treeify. "
|
136
|
-
str
|
310
|
+
str << "Skipping is only applicable to double_ups or cyclic nodes."
|
137
311
|
str << "\n • #{node_str}."
|
138
312
|
raise str
|
139
313
|
end
|
140
314
|
|
141
|
-
|
142
|
-
str = "#{indent(level
|
143
|
-
str << children.map {|
|
315
|
+
unless (children = parents[node.id] || []).empty?
|
316
|
+
str = "#{indent(level + 1)}Immediate children of skipped node (will probably be missing): "
|
317
|
+
str << children.map {|ch| "'#{ch.id}'"}.join(", ")
|
144
318
|
msg << str
|
145
319
|
end
|
146
320
|
|
147
|
-
|
321
|
+
warns << msg.join("\n")
|
322
|
+
nil
|
148
323
|
end
|
149
324
|
end
|
150
325
|
end
|
@@ -50,30 +50,32 @@ class Eco::Data::Locations::NodeDiff
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def diffs_summary
|
53
|
-
|
54
|
-
|
53
|
+
comp = "(#{source2.count} vs #{source1.count} nodes)"
|
54
|
+
return "There were no differences identified #{comp}" if diffs.empty?
|
55
|
+
msg = []
|
56
|
+
msg << "Identified #{diffs.count} differences #{comp}:"
|
55
57
|
msg << when_present(insert, '') do |count|
|
56
|
-
" • #{count} nodes to insert
|
58
|
+
" • #{count} nodes to insert"
|
57
59
|
end
|
58
60
|
msg << when_present(update, '') do |count|
|
59
|
-
" • #{count} nodes to update
|
61
|
+
" • #{count} nodes to update"
|
60
62
|
end
|
61
63
|
# msg << when_present(id, '') do |count|
|
62
64
|
# " • #{count} nodes to change id\n"
|
63
65
|
# end
|
64
66
|
msg << when_present(name, '') do |count|
|
65
|
-
" • #{count} nodes to change name
|
67
|
+
" • #{count} nodes to change name"
|
66
68
|
end
|
67
69
|
msg << when_present(move, '') do |count|
|
68
|
-
" • #{count} nodes to move
|
70
|
+
" • #{count} nodes to move"
|
69
71
|
end
|
70
72
|
msg << when_present(unarchive, '') do |count|
|
71
|
-
" • #{count} nodes to unarchive
|
73
|
+
" • #{count} nodes to unarchive"
|
72
74
|
end
|
73
75
|
msg << when_present(archive, '') do |count|
|
74
|
-
" • #{count} nodes to archive
|
76
|
+
" • #{count} nodes to archive"
|
75
77
|
end
|
76
|
-
msg
|
78
|
+
msg.join("\n")
|
77
79
|
end
|
78
80
|
|
79
81
|
private
|
@@ -20,7 +20,7 @@ class Eco::Data::Locations::NodePlain
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# It builds each NodePlain from the input csv.
|
23
|
-
# @param `csv` [CSV::Table]
|
23
|
+
# @param `csv` [CSV::Table] with specific headers
|
24
24
|
# @return [Array<NodePlain>]
|
25
25
|
def nodes_from_csv(csv)
|
26
26
|
raise ArgumentError, "Expecting CSV::Table. Given: #{csv.class}" unless csv.is_a?(::CSV::Table)
|
@@ -6,7 +6,7 @@ class Eco::Data::Locations::NodePlain
|
|
6
6
|
def serializer
|
7
7
|
@serializer ||= proc do |node|
|
8
8
|
raise "Expecting NodePlain. Given: #{node.class}" unless node.is_a?(Eco::Data::Locations::NodePlain)
|
9
|
-
keys = Eco::Data::Locations::NodePlain::
|
9
|
+
keys = Eco::Data::Locations::NodePlain::ALL_ATTRS
|
10
10
|
node.to_h(*keys)
|
11
11
|
end
|
12
12
|
end
|
@@ -15,7 +15,7 @@ module Eco::Data::Locations
|
|
15
15
|
PROP_ATTRS = ALL_ATTRS - ADDITIONAL_ATTRS
|
16
16
|
|
17
17
|
def id
|
18
|
-
clean_id(super)
|
18
|
+
clean_id(super, ref: "(Row: #{self.row_num}) ")
|
19
19
|
end
|
20
20
|
# backwards compatibility
|
21
21
|
alias_method :tag, :id
|
@@ -24,8 +24,9 @@ module Eco::Data::Locations
|
|
24
24
|
super || self.id
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
self.parent_id
|
27
|
+
def parent_id
|
28
|
+
clean_id(super, notify: false, ref: "(Row: #{self.row_num} - parent_id) ")
|
29
29
|
end
|
30
|
+
alias_method :parentId, :parent_id
|
30
31
|
end
|
31
32
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
module Klass
|
4
|
+
module WhenInherited
|
5
|
+
def inherited(subclass)
|
6
|
+
super
|
7
|
+
subclass.instance_exec(&when_inherited)
|
8
|
+
end
|
9
|
+
|
10
|
+
def when_inherited(&block)
|
11
|
+
return @when_inherited unless block_given?
|
12
|
+
@when_inherited = block
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
module Methods
|
4
|
+
module DelegateMissing
|
5
|
+
def delegate_missing_to(meth)
|
6
|
+
@delegate_missing_to = meth
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(method_name, *args, **kargs, &block)
|
10
|
+
super unless receiver = object_missing_delegated_to
|
11
|
+
receiver.send(method_name, *args, **kargs, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to_missing?(method_name, include_private = false)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# retrieve the delegate_missing_to object
|
21
|
+
def object_missing_delegated_to
|
22
|
+
return nil unless @delegate_missing_to
|
23
|
+
self.method(@delegate_missing_to).call
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
module Methods
|
4
|
+
module DslAble
|
5
|
+
# It runs the `block` within this object context
|
6
|
+
# @note if the object misses any method, redirects the method to the
|
7
|
+
# original evaluate caller.
|
8
|
+
def evaluate(*args, **kargs, &block)
|
9
|
+
return unless block_given?
|
10
|
+
@self_before_evaluate = eval "self", block.binding
|
11
|
+
instance_exec(*args, **kargs, &block).tap do
|
12
|
+
@self_before_evaluate = nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# When it's the case, redirect to the original `evaluate` caller
|
17
|
+
# @see https://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation
|
18
|
+
def method_missing(method, *args, **kargs, &block)
|
19
|
+
super unless @self_before_evaluate
|
20
|
+
@self_before_evaluate.send(method, *args, **kargs, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/eco/language.rb
CHANGED
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -359,7 +359,7 @@ dependencies:
|
|
359
359
|
version: '1.13'
|
360
360
|
- - "<"
|
361
361
|
- !ruby/object:Gem::Version
|
362
|
-
version: '1.
|
362
|
+
version: '1.17'
|
363
363
|
type: :runtime
|
364
364
|
prerelease: false
|
365
365
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -369,7 +369,7 @@ dependencies:
|
|
369
369
|
version: '1.13'
|
370
370
|
- - "<"
|
371
371
|
- !ruby/object:Gem::Version
|
372
|
-
version: '1.
|
372
|
+
version: '1.17'
|
373
373
|
- !ruby/object:Gem::Dependency
|
374
374
|
name: roo
|
375
375
|
requirement: !ruby/object:Gem::Requirement
|
@@ -496,6 +496,9 @@ files:
|
|
496
496
|
- lib/eco/api/common/loaders.rb
|
497
497
|
- lib/eco/api/common/loaders/base.rb
|
498
498
|
- lib/eco/api/common/loaders/case_base.rb
|
499
|
+
- lib/eco/api/common/loaders/config.rb
|
500
|
+
- lib/eco/api/common/loaders/config/workflow.rb
|
501
|
+
- lib/eco/api/common/loaders/config/workflow/mailer.rb
|
499
502
|
- lib/eco/api/common/loaders/error_handler.rb
|
500
503
|
- lib/eco/api/common/loaders/parser.rb
|
501
504
|
- lib/eco/api/common/loaders/policy.rb
|
@@ -542,12 +545,17 @@ files:
|
|
542
545
|
- lib/eco/api/common/version_patches/hash.rb
|
543
546
|
- lib/eco/api/common/version_patches/hash/deep_merge.rb
|
544
547
|
- lib/eco/api/common/version_patches/object.rb
|
548
|
+
- lib/eco/api/common/version_patches/ruby3.rb
|
549
|
+
- lib/eco/api/common/version_patches/ruby3/object.rb
|
545
550
|
- lib/eco/api/custom.rb
|
551
|
+
- lib/eco/api/custom/config.rb
|
546
552
|
- lib/eco/api/custom/error_handler.rb
|
553
|
+
- lib/eco/api/custom/mailer.rb
|
547
554
|
- lib/eco/api/custom/namespace.rb
|
548
555
|
- lib/eco/api/custom/parser.rb
|
549
556
|
- lib/eco/api/custom/policy.rb
|
550
557
|
- lib/eco/api/custom/use_case.rb
|
558
|
+
- lib/eco/api/custom/workflow.rb
|
551
559
|
- lib/eco/api/error.rb
|
552
560
|
- lib/eco/api/error/handler.rb
|
553
561
|
- lib/eco/api/error/handlers.rb
|
@@ -686,10 +694,12 @@ files:
|
|
686
694
|
- lib/eco/api/usecases/ooze_cases/export_register_case.rb
|
687
695
|
- lib/eco/api/usecases/ooze_samples.rb
|
688
696
|
- lib/eco/api/usecases/ooze_samples/helpers.rb
|
697
|
+
- lib/eco/api/usecases/ooze_samples/helpers/creatable.rb
|
689
698
|
- lib/eco/api/usecases/ooze_samples/helpers/exportable_ooze.rb
|
690
699
|
- lib/eco/api/usecases/ooze_samples/helpers/exportable_register.rb
|
691
700
|
- lib/eco/api/usecases/ooze_samples/helpers/filters.rb
|
692
701
|
- lib/eco/api/usecases/ooze_samples/helpers/ooze_handlers.rb
|
702
|
+
- lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb
|
693
703
|
- lib/eco/api/usecases/ooze_samples/helpers/shortcuts.rb
|
694
704
|
- lib/eco/api/usecases/ooze_samples/helpers_migration.rb
|
695
705
|
- lib/eco/api/usecases/ooze_samples/helpers_migration/copying.rb
|
@@ -781,8 +791,13 @@ files:
|
|
781
791
|
- lib/eco/language/curry.rb
|
782
792
|
- lib/eco/language/hash_transform.rb
|
783
793
|
- lib/eco/language/hash_transform_modifier.rb
|
794
|
+
- lib/eco/language/klass.rb
|
795
|
+
- lib/eco/language/klass/when_inherited.rb
|
784
796
|
- lib/eco/language/match.rb
|
785
797
|
- lib/eco/language/match_modifier.rb
|
798
|
+
- lib/eco/language/methods.rb
|
799
|
+
- lib/eco/language/methods/delegate_missing.rb
|
800
|
+
- lib/eco/language/methods/dsl_able.rb
|
786
801
|
- lib/eco/language/models.rb
|
787
802
|
- lib/eco/language/models/class_helpers.rb
|
788
803
|
- lib/eco/language/models/collection.rb
|