eco-helpers 3.2.6 → 3.2.7
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 +11 -9
- data/lib/eco/data/locations/node_base/builder.rb +8 -4
- data/lib/eco/data/locations/node_base/parsing.rb +16 -5
- data/lib/eco/data/locations/node_base/treeify.rb +17 -1
- data/lib/eco/data/locations/node_base.rb +4 -0
- data/lib/eco/data/locations/node_level.rb +4 -0
- data/lib/eco/data/locations/node_plain.rb +8 -4
- data/lib/eco/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: bfe97cd5583e8650f73c0f7cb2557fde896d3b59b7e729703fdb01f9323d6fbb
|
4
|
+
data.tar.gz: e40c8fdeae21780ca957c043aa7a637d06d9e85088fdbca6eb7c488448c74ab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f28e77164e7f8c439b09dba5d952594c34721457842963cfb9e037c90658de8049545c1029e25e6aa2aadda2a729a4fc103fb04335adcfb6359b1fe946ad60
|
7
|
+
data.tar.gz: '090c4c12745401c0191aec263bb3970bd92e5244c6b57f4d5ef6dd157acab37ab868ed239972d133bd52a4eb11ddcac0e4857a8e760e10321b7236f50a7d3c76'
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.2.
|
5
|
+
## [3.2.8] - 2025-09-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
@@ -10,6 +10,16 @@ All notable changes to this project will be documented in this file.
|
|
10
10
|
|
11
11
|
### Fixed
|
12
12
|
|
13
|
+
## [3.2.7] - 2025-09-09
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `NodeBase` (and subclasses): **added** missed case `#self_parented?`
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- **Added** early detection of `self-parented` nodes (from the input file).
|
22
|
+
|
13
23
|
## [3.2.6] - 2025-09-05
|
14
24
|
|
15
25
|
### Added
|
@@ -24,14 +34,6 @@ All notable changes to this project will be documented in this file.
|
|
24
34
|
- This was a working around due to not using `as_nodes_json` as a **common** converter between `live_tree` and `file_tree` (which was fixed in a previous release).
|
25
35
|
- `as_nodes_json` already does the call to `node_parser_block`, which does the conversion of the **classifications**
|
26
36
|
|
27
|
-
## [3.2.6] - 2025-09-xx
|
28
|
-
|
29
|
-
### Added
|
30
|
-
|
31
|
-
### Changed
|
32
|
-
|
33
|
-
### Fixed
|
34
|
-
|
35
37
|
## [3.2.5] - 2025-09-04
|
36
38
|
|
37
39
|
### Changed
|
@@ -11,15 +11,19 @@ module Eco::Data::Locations::NodeBase
|
|
11
11
|
case data
|
12
12
|
when ::CSV::Table
|
13
13
|
return Eco::Data::Locations::NodePlain if Eco::Data::Locations::NodePlain.csv_matches_format?(csv)
|
14
|
-
|
14
|
+
|
15
|
+
Eco::Data::Locations::NodeLevel if Eco::Data::Locations::NodeLevel.csv_matches_format?(csv)
|
15
16
|
when Array
|
16
|
-
return
|
17
|
+
return unless (sample = data.first)
|
18
|
+
|
17
19
|
node_class(sample)
|
18
20
|
when Eco::Data::Locations::NodeBase
|
19
|
-
return
|
21
|
+
return unless data.class < Eco::Data::Locations::NodeBase
|
22
|
+
|
20
23
|
data.class
|
21
24
|
else
|
22
|
-
|
25
|
+
msg ="Expecting CSV::Table. Given: #{csv.class}"
|
26
|
+
raise ArgumentError, msg unless csv.is_a?(::CSV::Table)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -6,10 +6,19 @@ module Eco::Data::Locations::NodeBase
|
|
6
6
|
# @param csv [CSV::Table]
|
7
7
|
# @return [Array<NodePlain>, Array<NodeLevel>] with integrity issues resolved.
|
8
8
|
def nodes_from_csv(csv)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
msg = "Expecting CSV::Table. Given: #{csv.class}"
|
10
|
+
raise ArgumentError, msg unless csv.is_a?(::CSV::Table)
|
11
|
+
|
12
|
+
if Eco::Data::Locations::NodePlain.csv_matches_format?(csv)
|
13
|
+
return Eco::Data::Locations::NodePlain.nodes_from_csv(csv)
|
14
|
+
end
|
15
|
+
|
16
|
+
if Eco::Data::Locations::NodeLevel.csv_matches_format?(csv)
|
17
|
+
return Eco::Data::Locations::NodeLevel.nodes_from_csv(csv)
|
18
|
+
end
|
19
|
+
|
20
|
+
msg = "The input csv does not have the required format to read a locations structure."
|
21
|
+
raise ArgumentError, msg
|
13
22
|
end
|
14
23
|
|
15
24
|
# @yield [node, json] optional custom serializer
|
@@ -18,7 +27,9 @@ module Eco::Data::Locations::NodeBase
|
|
18
27
|
# @yieldreturn [Hash] the serialized Node
|
19
28
|
# @return [Array<Hash>] a hierarchical tree of nested Hashes via `nodes` key.
|
20
29
|
def hash_tree_from_csv(csv, &block)
|
21
|
-
|
30
|
+
msg = "Expecting CSV::Table. Given: #{csv.class}"
|
31
|
+
raise ArgumentError, msg unless csv.is_a?(::CSV::Table)
|
32
|
+
|
22
33
|
treeify(nodes_from_csv(csv), &block)
|
23
34
|
end
|
24
35
|
|
@@ -55,8 +55,25 @@ module Eco::Data::Locations::NodeBase
|
|
55
55
|
# @return [Hash] where `key`s are all the `parentId` of the nodes
|
56
56
|
# and `value` and `Array` of those nodes that have that `parentId`
|
57
57
|
def parents_hash(nodes)
|
58
|
+
self_parented = []
|
59
|
+
|
58
60
|
nodes.each_with_object({}) do |node, parents|
|
61
|
+
next self_parented.push(node) if node.self_parented?
|
62
|
+
|
59
63
|
(parents[node.parentId] ||= []).push(node)
|
64
|
+
end.tap do
|
65
|
+
next if self_parented.empty?
|
66
|
+
|
67
|
+
log(:error) {
|
68
|
+
msg = "#{self_parented.count} nodes are self-parented: "
|
69
|
+
msg << self_parented.map(&:id).map do |node_id|
|
70
|
+
"'#{node_id}'"
|
71
|
+
end.join(', ')
|
72
|
+
msg << "\nPlease amend the data."
|
73
|
+
msg
|
74
|
+
}
|
75
|
+
|
76
|
+
exit 1
|
60
77
|
end
|
61
78
|
end
|
62
79
|
|
@@ -138,7 +155,6 @@ module Eco::Data::Locations::NodeBase
|
|
138
155
|
# skipped keys is inherent, as they were excluded because of id clash with done_ids
|
139
156
|
unlinked_parent_ids = (parents.keys - done_ids.keys).compact
|
140
157
|
|
141
|
-
|
142
158
|
# The reason of missing nodes in the output tree is unknown!
|
143
159
|
if skipped.empty? && unlinked_parent_ids.empty?
|
144
160
|
msg = []
|
@@ -30,10 +30,6 @@ module Eco::Data::Locations
|
|
30
30
|
# backwards compatibility
|
31
31
|
alias_method :tag, :id
|
32
32
|
|
33
|
-
def name
|
34
|
-
super || id
|
35
|
-
end
|
36
|
-
|
37
33
|
def parent_id
|
38
34
|
clean_id(
|
39
35
|
super,
|
@@ -43,6 +39,14 @@ module Eco::Data::Locations
|
|
43
39
|
end
|
44
40
|
alias_method :parentId, :parent_id # rubocop:disable Naming/MethodName
|
45
41
|
|
42
|
+
def self_parented?
|
43
|
+
id == parent_id
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
super || id
|
48
|
+
end
|
49
|
+
|
46
50
|
def archived
|
47
51
|
value = super
|
48
52
|
return false if value.nil? || value == false
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|