csv_step_importer 0.5.9 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/csv_step_importer/chunk.rb +3 -3
- data/lib/csv_step_importer/file.rb +10 -1
- data/lib/csv_step_importer/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: b1e5338a5f85c4bf4ce6ee7468530b97e4d57ce9f655de834090c664a9169ca9
|
4
|
+
data.tar.gz: 7ae3d14aeb80a8214c0259de960823090e1dbfa47f5da15a32226f58ab452a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb52c96e5f7a3a156cf02bba30f3976664b86579c5ec87dc6bc3423663b98b1db28e7b891d79a5c87311dd0ffd46b24fc21f6bfc89d9e37c824e1270040dc9c1
|
7
|
+
data.tar.gz: d0dbd81d88fd1f8b827c5882fedebab80ff5627d8cd53e39e91fb6148d9ad1027d7ef70107dbf6969c69f84287b010a1632cf0dd9e1a9f4595da90bd24890f9c
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module CSVStepImporter
|
4
4
|
class Chunk < CSVStepImporter::Node
|
5
|
-
attr_accessor :cache, :rows
|
5
|
+
attr_accessor :cache, :rows, :first_row
|
6
6
|
|
7
|
-
def initialize(rows: [], row_class: CSVStepImporter::Row, processor_classes: nil, **attributes)
|
7
|
+
def initialize(rows: [], row_class: CSVStepImporter::Row, processor_classes: nil, first_row: 2, **attributes)
|
8
8
|
super **attributes
|
9
9
|
|
10
10
|
self.cache = {}
|
@@ -16,7 +16,7 @@ module CSVStepImporter
|
|
16
16
|
row_parent_node = CSVStepImporter::Node.new parent: self
|
17
17
|
|
18
18
|
unless rows.empty? || rows.first.is_a?(row_class)
|
19
|
-
row_number =
|
19
|
+
row_number = self.first_row - 1
|
20
20
|
rows = rows.collect do |row|
|
21
21
|
row_class.new(parent: row_parent_node, row_number: row_number += 1, **row)
|
22
22
|
end
|
@@ -31,9 +31,18 @@ module CSVStepImporter
|
|
31
31
|
def load_csv
|
32
32
|
raise CSVFileNotFoundError.new unless ::File.exists? path
|
33
33
|
|
34
|
+
first_row = 2
|
35
|
+
|
34
36
|
::SmarterCSV.process(path, **csv_options.deep_dup) do |rows|
|
35
37
|
self.headers ||= rows.first&.keys
|
36
|
-
add_children chunk_class.new
|
38
|
+
add_children chunk_class.new(
|
39
|
+
first_row: first_row,
|
40
|
+
parent: self,
|
41
|
+
processor_classes: processor_classes,
|
42
|
+
row_class: row_class,
|
43
|
+
rows: rows,
|
44
|
+
)
|
45
|
+
first_row += rows.size
|
37
46
|
end
|
38
47
|
rescue EOFError => exception
|
39
48
|
self.csv_load_error = exception
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_step_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian-Manuel Butzke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|