csv_step_importer 0.5.9 → 0.6.0

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: efa10582ecd21a5f4729925c35e02583619a9011b822a394c5248d71db47b39a
4
- data.tar.gz: d7aa3861a60f25639d3299581aacd850cf9c6884034457df50e6081945a24b8b
3
+ metadata.gz: b1e5338a5f85c4bf4ce6ee7468530b97e4d57ce9f655de834090c664a9169ca9
4
+ data.tar.gz: 7ae3d14aeb80a8214c0259de960823090e1dbfa47f5da15a32226f58ab452a5b
5
5
  SHA512:
6
- metadata.gz: 22755630a073a267ddb4d80cfc491ae0edac53efc5bf07649b9e93700b33d153b603d52cc61f22c40a0deeee21c52cd8023bf58460733a3f7da2401a6120d3e5
7
- data.tar.gz: 437a846ef177c47403c6fb131734ff9dd158c88a0b2726b67019dd17145e4ad0f0cf6f2040d7535fc6f17314715c7034af5d752d05234ebdb09c02687e95557f
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 = 0
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 parent: self, rows: rows, row_class: row_class, processor_classes: processor_classes
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSVStepImporter
4
- VERSION = "0.5.9"
4
+ VERSION = "0.6.0"
5
5
  end
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.5.9
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-18 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler