eco-helpers 2.4.3 → 2.4.4

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: 84e0b3626647d968a77ecc7dbc9dbe052be392ff7590f9f32c2402d4a0fdb45b
4
- data.tar.gz: cfd6e253e91d50bd62ffb4cbad8556214a3519ccaf9fdd148c681170ad150466
3
+ metadata.gz: 3c2d5e728987bee135ac2297b0a84858dfb14eab79b3decebc59ced1a74ccc4a
4
+ data.tar.gz: b906c449d80dbc1440c1b7e7d91565bad53409167cae3c07b0788870f842cf5e
5
5
  SHA512:
6
- metadata.gz: 4162b785935a8f161ad5030e8ffbd72defd3ed10f50b6d4944b219c0faed84f5cd57efee5a1c43ed41c2f4efdbbcb5ab7356c426dbecd2ebaca2a0da79bba90a
7
- data.tar.gz: 5c5ad42b25f53b92fcac214555fb7b2ab9b5af0c033367b375b6ae55334ce0ffa7ecca74d05bac7dd3a75aba7761d9f7be91d5fab44310eb664eeed3df758f83
6
+ metadata.gz: e7a9781490f01e1d9ffafdec19179d492d760c9dca676e2e6f2771b61a8f422d5c9f481bb03c71563c91df97b72f89cee0e8aa664be42dcf1dd5d99576177add
7
+ data.tar.gz: 44eed6e779b8ffdfdc1bea5913090713cc15dba649b7c2eddc9f333a8be67f92afa1ec6e1d06b0c31bcf2b29d062b92cac26c7c53b07404e50d089ae56698202
data/CHANGELOG.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.4.4] - 2023-03-xx
4
+ ## [2.4.5] - 2023-03-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.4.4] - 2023-03-29
11
+
12
+ ### Added
13
+ - `Eco::API:Organization::TagTree`
14
+ - Added **methods** `#each` and `#all_nodes` allow to loop through all nodes
15
+ - Added `parent` to refer to the parent node.
16
+
17
+ ### Changed
18
+ - `Eco::API:Organization::TagTree` made **Enumerable**
19
+
20
+ ### Fixed
21
+ - `Eco:API::Session#live_tree` pass `enviro`
22
+ - `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
23
+ - Fix typo on error message.
24
+
10
25
  ## [2.4.3] - 2023-03-23
11
26
 
12
27
  ### Fixed
@@ -7,10 +7,13 @@ module Eco
7
7
  alias_method :tag, :id
8
8
  attr_accessor :name
9
9
 
10
+ attr_reader :parent
10
11
  attr_reader :nodes, :children_count
11
12
  attr_reader :depth, :path
12
13
  attr_reader :enviro
13
14
 
15
+ include Enumerable
16
+
14
17
  # @example Node format:
15
18
  # {"tag": "NODE NAME", "nodes": subtree}
16
19
  # @example Tree/subtree format:
@@ -21,8 +24,9 @@ module Eco
21
24
  # ]}]
22
25
  # tree = TagTree.new(tree.to_json)
23
26
  # @param tagtree [String] representation of the tagtree in json.
24
- def initialize(tagtree = [], name: nil, id: nil, depth: -1, path: [], enviro: nil)
25
- @depth = depth
27
+ def initialize(tagtree = [], name: nil, id: nil, depth: -1, path: [], parent: nil, enviro: nil)
28
+ @depth = depth
29
+ @parent = parent
26
30
 
27
31
  case tagtree
28
32
  when String
@@ -48,7 +52,7 @@ module Eco
48
52
  @path.push(@id) unless top?
49
53
 
50
54
  @nodes = @row_nodes.map do |cnode|
51
- TagTree.new(cnode, depth: depth + 1, path: @path.dup, enviro: @enviro)
55
+ TagTree.new(cnode, depth: depth + 1, path: @path.dup, parent: self, enviro: @enviro)
52
56
  end
53
57
 
54
58
  init_hashes
@@ -59,6 +63,27 @@ module Eco
59
63
  self.class.new(as_json)
60
64
  end
61
65
 
66
+ # Iterate through all the nodes of this tree
67
+ # @yield [node] do some stuff with one of the nodes of the tree
68
+ # @yieldparam node [Eco::API::Organization::TagTree] a node of the tree
69
+ # @return [Enumerable<Eco::API::Organization::TagTree>]
70
+ def each(&block)
71
+ return to_enum(:each) unless block
72
+ all_nodes.each(&block)
73
+ end
74
+
75
+ # All actual nodes of this tree
76
+ # @note order is that of the parent to child relationships
77
+ # @return [Array[]]
78
+ def all_nodes(&block)
79
+ [].tap do |all_nodes|
80
+ all_nodes.push(self) unless top?
81
+ nodes.each do |node|
82
+ all_nodes.concat(node.all_nodes)
83
+ end
84
+ end
85
+ end
86
+
62
87
  # @return [Array] with the differences
63
88
  def diff(tagtree, differences: {}, level: 0, **options)
64
89
  require 'hashdiff'
@@ -46,7 +46,7 @@ module Eco
46
46
 
47
47
  # @see Eco::API::Session::Config#live_tree
48
48
  def live_tree
49
- config.live_tree
49
+ config.live_tree(enviro: enviro)
50
50
  end
51
51
 
52
52
  # @see Eco::API::Session::Config#schemas
@@ -109,7 +109,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
109
109
  if dirty?(pending)
110
110
  msg = "Inconsistent search results. "
111
111
  msg << "Launching update on '#{object_reference(pending)}' to be able to queue it back"
112
- console.warn msg
112
+ logger.warn msg
113
113
  update_ooze(pending)
114
114
  end
115
115
  end
@@ -118,7 +118,7 @@ class Eco::API::UseCases::OozeSamples::RegisterUpdateCase < Eco::API::UseCases::
118
118
  yield(ooz)
119
119
  else
120
120
  @non_retrieved_oozes += 1
121
- console.warn "Could not get page #{page_result.id}"
121
+ logger.warn "Could not get page #{page_result.id}"
122
122
  end
123
123
  end
124
124
  update_oozes
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.4.3"
2
+ VERSION = "2.4.4"
3
3
  end
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.4.3
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura