eco-helpers 3.0.3 → 3.0.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: 4515e1cd31a6ef2104b4502ce26e8c6f881aba08e22ab36650b1de59a9a3fb56
4
- data.tar.gz: c28a4d186bd8850576947aacee7d2b1908a94879ed44ec2b58302153aa8a4c6f
3
+ metadata.gz: 4768a5497ea319bbd31f09bceeb42c9d43567446b01c4e58894928ad6dec84c3
4
+ data.tar.gz: 4179baf86c6f45f8424fa6690eecc0d1fc5be0daf4059c0af63050e70fcc8a3b
5
5
  SHA512:
6
- metadata.gz: a2d252124e3076b348a9928994b12dccfc8ae3207ac889b45bbfd62fa97f07f208d82e76b567e998d9081037c9e8bfda0dc216200e7f53479b8a2ae53d35b751
7
- data.tar.gz: 2f1d3b77a28ae09704dc6ddb7896c7aca91c07ca1b74f837d28d6b5495b74ed5a7752ac2a062f5cf3fd3944cba66d917ec2558c9bf52ad271e67b968a25ce4f7
6
+ metadata.gz: d45b4fa67247ac68ac53122759b934bc6c26d14e684774fb0e63184abfcf7799441e1e17384be726ada0d1a437228a5af152a589b9446fb582a1d4a5bbd140ad
7
+ data.tar.gz: 4cce2123784bdd2730b0052338f52838979aa4ac3435e2a105f56124029e2a3192a481bd2ec694e172763cef24c383485243d06f87b25031dc358d565d858023
data/.rubocop.yml CHANGED
@@ -33,6 +33,8 @@ Style/BlockDelimiters:
33
33
  Style/HashSyntax:
34
34
  EnforcedShorthandSyntax: either
35
35
  EnforcedStyle: no_mixed_keys
36
+ Style/ArgumentsForwarding:
37
+ UseAnonymousForwarding: false
36
38
  Style/ClassAndModuleChildren:
37
39
  Enabled: false
38
40
  Style/FrozenStringLiteralComment:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.
6
6
 
7
7
  ### Added
8
8
 
9
+ - `Eco::Csv::Split` add `total_count` and `copy_count`
10
+ - `Eco::API::Common::People::PersonParser`
11
+ - added core attribute `brand_id`
12
+
9
13
  ### Changed
10
14
 
11
15
  ### Fixed
@@ -19,6 +19,7 @@ module Eco
19
19
  id external_id email name
20
20
  supervisor_id filter_tags
21
21
  contractor_organization_id freemium
22
+ brand_id
22
23
  ].freeze
23
24
  ACCOUNT_ATTRS = %w[
24
25
  policy_group_ids default_tag
@@ -16,8 +16,15 @@ class Eco::API::UseCases::Default::Utils::SplitCsv < Eco::API::Common::Loaders::
16
16
  max_rows: max_rows,
17
17
  start_at: start_at,
18
18
  &filter
19
- ).each do |file|
20
- log(:info) { "Generated file '#{file}'" }
19
+ ).tap do |split|
20
+ msg = []
21
+ msg << "Total rows copied: #{split.copy_count} (out of #{split.total_count})"
22
+ msg << "Generated files:"
23
+ split.out_files.each do |file|
24
+ msg << " * #{file}'"
25
+ end
26
+
27
+ log(:info) { msg.join("\n") }
21
28
  end
22
29
  end
23
30
  end
data/lib/eco/csv/split.rb CHANGED
@@ -13,9 +13,25 @@ module Eco
13
13
  @max_rows = max_rows
14
14
  @start_at = start_at
15
15
  @params = kargs
16
+
16
17
  init
17
18
  end
18
19
 
20
+ # @return [Integer] number of total output rows
21
+ def copy_count
22
+ @copy_count ||= 0
23
+ end
24
+
25
+ # @return [Integer] number of total input rows
26
+ def total_count
27
+ @total_count ||= 0
28
+ end
29
+
30
+ # @return [Array<String>] list of created files
31
+ def out_files
32
+ @out_files ||= []
33
+ end
34
+
19
35
  # @yield [idx, file] a block to spot the filename
20
36
  # @yieldparam idx [Integer] the number of the file
21
37
  # @yieldparam file [String] the default name of the file
@@ -24,8 +40,10 @@ module Eco
24
40
  # @return [Array<String>] names of the generated files
25
41
  def call(&block)
26
42
  stream.for_each(start_at_idx: start_at) do |row, ridx|
43
+ self.total_count += 1
27
44
  copy_row(row, ridx, &block)
28
45
  end
46
+
29
47
  out_files
30
48
  ensure
31
49
  puts "Close at row #{row_idx}"
@@ -49,7 +67,8 @@ module Eco
49
67
  included &&= !block || yield(row, ridx, fidx, file_out)
50
68
  next unless included
51
69
 
52
- csv << row.fields
70
+ self.copy_count += 1
71
+ csv << row.fields
53
72
  end
54
73
  end
55
74
 
@@ -97,10 +116,6 @@ module Eco
97
116
  "0" * 5
98
117
  end
99
118
 
100
- def out_files
101
- @out_files ||= []
102
- end
103
-
104
119
  def input_name
105
120
  @input_name ||= File.basename(input_basename, input_ext)
106
121
  end
data/lib/eco/csv.rb CHANGED
@@ -29,14 +29,16 @@ module Eco
29
29
  # @param max_rows [Integer] number of rows per file
30
30
  # @param start_at [Integer] row that sets the starting point.
31
31
  # Leave empty for the full set of rows.
32
- # @see Eco::CSV::Split#call
32
+ # @return [Eco::CSV::Split]
33
33
  def split(filename, max_rows:, start_at: nil, **kargs, &block)
34
34
  Eco::CSV::Split.new(
35
35
  filename,
36
36
  max_rows: max_rows,
37
37
  start_at: start_at,
38
38
  **kargs
39
- ).call(&block)
39
+ ).tap do |splitter|
40
+ splitter.call(&block)
41
+ end
40
42
  end
41
43
 
42
44
  # @note it excludes headers by default
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.0.3'.freeze
2
+ VERSION = '3.0.4'.freeze
3
3
  end
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.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-12 00:00:00.000000000 Z
11
+ date: 2024-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake