eco-helpers 2.4.6 → 2.4.7

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: 4c4f7620deee8791ef8b6bfa5552e6040657575fa2ee071efdf7ed76e588a998
4
- data.tar.gz: a870243619d2b8842ef97525676097330b76a0686f4793f7c6720e4c658173aa
3
+ metadata.gz: 0ab1e50c5ccc57fd84bd6b21b40a9d455455e3457c89248f7bf60177fe82293a
4
+ data.tar.gz: 169a31ded9574a5fd8a135a0cfe3f388fe71c48e87f7f67969e12036ba40ab3f
5
5
  SHA512:
6
- metadata.gz: 5eef75b2a425b14b6bd17db7d58c153752ad121a708665f27736f9e4457c2eca5f06ec5af1344fe941478419c3271d0debdb3b09fda826eecd06414bf9a06405
7
- data.tar.gz: 50c9b2e722457a10eae9da4723816f906efb816b82a485562779251ad80dea4c737cc0bd572c5e80eff3b9e2f6b3b909245bf65b766781f7cbdb63a8d5d68daf
6
+ metadata.gz: 7de4657000ee0181e9c7dcea3536365c5a66fc26d5b25999715129ce4ebed459ba67042de42736b96879b617aba2adc063f92403f0ff063cac13fd5301562191
7
+ data.tar.gz: e9518629a51f623b07d795eedad394682b53bc23edf1389cb2185f34519ccaed8cf2c746eba8c8ae0c4e12b41068b7444f2f6f263e3a30cd5ab91aa45be09185
data/CHANGELOG.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.4.7] - 2023-04-xx
4
+ ## [2.4.8] - 2023-04-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.4.7] - 2023-04-03
11
+
12
+ ### Added
13
+ - `Eco::Data::Hashes::ArrayDiff#diffs?`
14
+ - `Eco::API::Organization::TagTree` added methods:
15
+ - `#source` => to expose the original doc
16
+ - `#all_nodes` => to implement the block call
17
+
18
+ ### Changed
19
+ - Upgraded `ecoportal-api-graphql` **gem**
20
+
21
+ ### Fixed
22
+ - `Eco::API::Session::Config::Api` **new `graphql` api** was missing `host`
23
+ - `Eco::API::UseCases::DefaultCases::CsvToTree::Helper`
24
+ - `#nodes_from_csv` assumed unique top level tag and not present
25
+ - This fix completes this feature (as top level tags were not there)
26
+
10
27
  ## [2.4.6] - 2023-04-02
11
28
 
12
29
  ### Added
data/eco-helpers.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency 'ecoportal-api', '>= 0.9.3', '< 0.10'
34
34
  spec.add_dependency 'ecoportal-api-v2', '>= 1.1.1', '< 1.2'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.3', '< 0.4'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.3.5', '< 0.4'
36
36
  spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
37
37
  spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
38
38
  spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
@@ -13,6 +13,8 @@ module Eco
13
13
  attr_reader :depth, :path
14
14
  attr_reader :enviro
15
15
 
16
+ attr_reader :source
17
+
16
18
  include Enumerable
17
19
 
18
20
  # @example Node format:
@@ -42,20 +44,20 @@ module Eco
42
44
  if @source.is_a?(Array)
43
45
  @id = id
44
46
  @name = name
45
- @row_nodes = @source
47
+ @raw_nodes = @source
46
48
  else
47
49
  @id = @source.values_at('tag', 'id').compact.first&.upcase
48
50
  @name = @source['name']
49
- @archived = @source.fetch('archived', false)
50
- @archived_token = @source['archived_token']
51
- @weight = @source.fetch('weight', _weight)
52
- @row_nodes = @source['nodes'] || []
51
+ @archived = @source['archived'] || false
52
+ @archived_token = @source['archived_token']
53
+ @source['weight'] = @weight = @source['weight'] || _weight
54
+ @raw_nodes = @source['nodes'] || []
53
55
  end
54
56
 
55
57
  @path = path || []
56
58
  @path.push(@id) unless top?
57
59
 
58
- @nodes = @row_nodes.map.with_index do |cnode, idx|
60
+ @nodes = @raw_nodes.map.with_index do |cnode, idx|
59
61
  TagTree.new(cnode, depth: depth + 1, path: @path.dup, parent: self, _weight: idx, enviro: @enviro)
60
62
  end
61
63
 
@@ -84,10 +86,13 @@ module Eco
84
86
  # @note order is that of the parent to child relationships
85
87
  # @return [Array[]]
86
88
  def all_nodes(&block)
87
- [].tap do |all_nodes|
88
- all_nodes.push(self) unless top?
89
+ [].tap do |out_nodes|
90
+ unless top?
91
+ out_nodes.push(self)
92
+ yield(self) if block_given?
93
+ end
89
94
  nodes.each do |node|
90
- all_nodes.concat(node.all_nodes)
95
+ out_nodes.concat(node.all_nodes(&block))
91
96
  end
92
97
  end
93
98
  end
@@ -171,7 +171,7 @@ module Eco
171
171
  when :v2
172
172
  klass.new(user_key: user_key, org_key: external_key, host: host, logger: logger)
173
173
  when :graphql
174
- klass.new(org_id: org_id, email: email, pass: pass)
174
+ klass.new(host: host, org_id: org_id, email: email, pass: pass)
175
175
  end.tap do |api|
176
176
  unless !api || log_connection?
177
177
  @logger.info("Created api#{self.version(version)} connection on '#{name}' enviro, pointing to '#{host}' in '#{mode}' mode")
@@ -25,11 +25,16 @@ class Eco::API::UseCases::DefaultCases::CsvToTree
25
25
  node = Node.new(i, *values)
26
26
  prev_node ||= node
27
27
 
28
- if prev_node.raw_level <= node.raw_level
28
+ # If node is nested in prev_node or is a sibling thereof
29
+ if prev_node.raw_level <= node.raw_level\
30
+ # Make sure parent is among upper level tags
29
31
  node.set_high_levels(prev_node)
30
32
  else
31
33
  if parent_node = prev_nodes[node.raw_level - 1]
32
34
  node.set_high_levels(parent_node)
35
+ elsif node.raw_level == 1
36
+ # It is expected not to have parent
37
+ #puts "Node '#{node.raw_tag}' doesn't have parent, but it's top level tag"
33
38
  else
34
39
  raise "Node '#{node.raw_tag}' (#{node.row_num} row) doesn't have parent"
35
40
  end
@@ -44,7 +44,7 @@ class Eco::API::UseCases::DefaultCases::HrisCase < Eco::API::Common::Loaders::Us
44
44
  other_people = people.group_by_schema.values_at(*other_schemas).map(&:to_a).flatten
45
45
  if other_people.length > 3
46
46
  msg = "There are #{other_people.length} people in schemas other than #{active_schema.name}."
47
- msg << " Please, use the filter option '-schema_id SchemaName' for the 'hris' case to only include those of that schema"
47
+ msg << " Please, use the filter option '-schema-id SchemaName' for the 'hris' case to only include those of that schema"
48
48
  msg << " in the current update. The HRIS case identifies people that are not in the file as leavers"
49
49
  msg << " (as it will remove the account of all the people of other schemas if they are not in the input file)."
50
50
  msg << "\n For example: -schema-id '#{active_schema.name.downcase}'"
@@ -56,15 +56,24 @@ module Eco
56
56
  # - It also allows to know the original value
57
57
  # @return [Hash] where `key` is the key of the record, and `value` a `DiffResult` object
58
58
  def diffs
59
- @diffs ||= paired_sources.each_with_object([]) do |(src1, src2), diffs|
59
+ @diffs ||= source_results.select do |res|
60
+ res.diff?
61
+ end
62
+ end
63
+
64
+ # @return [Boolean] wheter or not there are differences.
65
+ def diffs?
66
+ !diffs.empty?
67
+ end
68
+
69
+ def source_results
70
+ @source_results ||= paired_sources.each_with_object([]) do |(src1, src2), res|
60
71
  args = {
61
72
  key: key,
62
73
  compare: compared_attrs,
63
74
  case_sensitive: case_sensitive?
64
75
  }
65
- diff_result_class.new(src1, src2, **args).tap do |res|
66
- diffs << res if res.diff?
67
- end
76
+ res << diff_result_class.new(src1, src2, **args)
68
77
  end
69
78
  end
70
79
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.4.6"
2
+ VERSION = "2.4.7"
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.6
4
+ version: 2.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -156,7 +156,7 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 0.3.3
159
+ version: 0.3.5
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0.4'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 0.3.3
169
+ version: 0.3.5
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.4'