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 +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/eco/api/common/people/person_parser.rb +1 -0
- data/lib/eco/api/usecases/default/utils/split_csv_case.rb +9 -2
- data/lib/eco/csv/split.rb +20 -5
- data/lib/eco/csv.rb +4 -2
- 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: 4768a5497ea319bbd31f09bceeb42c9d43567446b01c4e58894928ad6dec84c3
|
4
|
+
data.tar.gz: 4179baf86c6f45f8424fa6690eecc0d1fc5be0daf4059c0af63050e70fcc8a3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
-
).
|
20
|
-
|
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
|
-
|
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
|
-
# @
|
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
|
-
).
|
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
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.
|
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-
|
11
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|