eco-helpers 2.0.37 → 2.0.38

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: 0a1e3f56c23a45ecb80f852556b02b1ac7cc3a2546a72bcb5d2d05283bbc66b6
4
- data.tar.gz: 82250daa8e645c1a68d79d047d938fd3371c909d9eeb04dca58548d5bd907543
3
+ metadata.gz: 0e84f7c290837d063ed13e63165dadaf272219105227d90b983b9af16d338fe5
4
+ data.tar.gz: 38ea16433f7a5689cfdcbde0b3bd4f1065e8adb9e742493c097a87c684b97b86
5
5
  SHA512:
6
- metadata.gz: d93e88f2f6dab9ca740d7c21741be6c6aec2885c98336fe7d0d247964e995b519603aaf989872073a3ff93234f64cce3cb62bece56ed4c33d7597de186f70bae
7
- data.tar.gz: 4cd351d33ef0f66d178273d64ba52b39356204a8b31aabc358bda6267892af678c785b17537eb2ca2b00533a81b2ee600b3e648f40891b4438162a7362d33825
6
+ metadata.gz: cef2930cc5941db9baab1a726fd04fb6186b57d9498cb8112589b2b12e40e53ae061ca2b68f062a197111ba85f47acafcf512f4aa3559e043b924412b23ba038
7
+ data.tar.gz: e79992f8ed299014a4c30b62c18773c1741a1961c4777560bbd137a60adc265920a3d35b18085256b42ce6cf467b9d4a950ba06e28adf50770a71aa94b3236ad
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.0.38] - 2021-09-07
5
+
6
+ ### Added
7
+ - `Eco::CSV::Table` some more helpers to manage input `csv`s
8
+ - `#transform_headers` that allows to pass a block to decide the new name
9
+ - `#merge_same_header_names` that allows to deal with value of columns with same header name
10
+ - `#duplicated_header_names` that identifies repeated header names
11
+
12
+ ### Changed
13
+ - Changed the `workflow` to prevent re-cache of people when `people` was not used
14
+
15
+ ### Fixed
16
+
4
17
  ## [2.0.37] - 2021-09-03
5
18
 
6
19
  ### Added
@@ -12,7 +25,7 @@ All notable changes to this project will be documented in this file.
12
25
  - stop downloading the people manager
13
26
  - `Eco::API::UseCases::OozeSamples::RegisterUpdateCase`
14
27
  - prevent queuing non page objects
15
-
28
+
16
29
  ## [2.0.36] - 2021-08-31
17
30
 
18
31
  ### Fixed
@@ -146,8 +146,11 @@ ASSETS.cli.config do |config|
146
146
  get_people = io.options.dig(:people, :get)
147
147
  partial_update = get_people && get_people.dig(:type) == :partial
148
148
  unless !io.options[:end_get] || io.options[:dry_run] || partial_update
149
- people = io.session.micro.people_cache
150
- io = io.new(people: people)
149
+ # Prevent getting people when there were no use cases that used them
150
+ unless io.people
151
+ people = io.session.micro.people_cache
152
+ io = io.new(people: people)
153
+ end
151
154
  end
152
155
  io
153
156
  end
data/lib/eco/csv/table.rb CHANGED
@@ -15,6 +15,46 @@ module Eco
15
15
  end
16
16
  end
17
17
 
18
+ # @return [Eco::CSV::Table]
19
+ def transform_headers
20
+ header = self.headers
21
+ cols = self.columns
22
+ cols.each do |col|
23
+ col[0] = yield(col.first)
24
+ end
25
+ columns_to_table(cols)
26
+ end
27
+
28
+ # @return [Eco::CSV::Table]
29
+ def merge_same_header_names
30
+ dups = self.duplicated_header_names
31
+ out_rows = self.map do |row|
32
+ row.to_a.each_with_object({}) do |(name, value), out|
33
+ if dups.include?(name) && out.key?(name)
34
+ if block_given?
35
+ yield(value, out[name], name)
36
+ else
37
+ # resolve
38
+ value || out[name]
39
+ end
40
+ elsif out.key?(name)
41
+ out[name]
42
+ else
43
+ value
44
+ end.tap do |final_value|
45
+ out[name] = final_value
46
+ end
47
+ end
48
+ end
49
+ self.class.new(out_rows)
50
+ end
51
+
52
+ # @return [Array<String>] list of duplicated header names
53
+ def duplicated_header_names
54
+ header = self.headers
55
+ header.select {|e| header.count(e) > 1}.uniq
56
+ end
57
+
18
58
  # @return [Eco::CSV::Table]
19
59
  def transform_values
20
60
  transformed_rows = rows.map do |row|
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.37"
2
+ VERSION = "2.0.38"
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.0.37
4
+ version: 2.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura