row_boat 0.1.0.alpha.1 → 0.1.0.alpha.2

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
  SHA1:
3
- metadata.gz: 24f37ad61ddc7230fb617df52bd0740cb0139bdf
4
- data.tar.gz: 3f6476e3903adb0faaf307765bb841c8dd38eb56
3
+ metadata.gz: a52e0cc320cec32723d8004c8664b20db8b2f08c
4
+ data.tar.gz: 44976205d05e7290b9cc520e4af0a2b8bb864928
5
5
  SHA512:
6
- metadata.gz: b27935d1cfb96fb2ed08c08705484da6af08ee9132f66f2a0ce526708af49dd5829259088c8ad2ecf275a0a81cecbf69eff5357874c5aca6b380626a75df5e8d
7
- data.tar.gz: 8b797634c16b66f84adeadbf73763d996cefcfb4071de6b631d812fa13d538a748121873068037a339f819943f5f28a28d3eda60a69ebfc1c82c9c54614bf1e2
6
+ metadata.gz: d0cd75d81d723f853a42d8dd4eeee8a9a03bc783b46778457d6b01db3006b3e276531237f57dec9fb26d36447f14d95b9b138b710bab8e7485caf6f761b03c6c
7
+ data.tar.gz: 2dce2747abf8ba12b093a393c6db92a06c7e35a61892184c8c85c4dda557ddec75b9a59446bb38d987e9ca67598111a6972da54c7e11accc124addfa6db962d6
data/lib/row_boat/base.rb CHANGED
@@ -27,7 +27,11 @@ module RowBoat
27
27
  end
28
28
  end
29
29
 
30
- { invalid_records: import_results.flat_map(&:failed_instances) }
30
+ import_results.each_with_object(invalid_records: [], total_inserted: 0, inserted_ids: []) do |import_result, total_results|
31
+ total_results[:invalid_records] += import_result.failed_instances
32
+ total_results[:total_inserted] += import_result.num_inserts
33
+ total_results[:inserted_ids] += import_result.ids
34
+ end
31
35
  end
32
36
 
33
37
  def import_into
@@ -38,10 +42,21 @@ module RowBoat
38
42
  raise NotImplementedError, not_implemented_error_message(__method__)
39
43
  end
40
44
 
45
+ def preprocess_row(row)
46
+ row
47
+ end
48
+
49
+ def import_rows(rows)
50
+ import_options = ::RowBoat::Helpers.extract_import_options(options)
51
+ preprocessed_rows = rows.map { |row| preprocess_row(row) }
52
+ import_into.import(preprocessed_rows, import_options)
53
+ end
54
+
41
55
  def options
42
56
  {
43
57
  chunk_size: 500,
44
58
  key_mapping: column_mapping,
59
+ recursive: true,
45
60
  remove_unmapped_keys: true,
46
61
  validate: true,
47
62
  wrap_in_transaction: true
@@ -59,11 +74,6 @@ module RowBoat
59
74
  ::SmarterCSV.process(csv_source, csv_options, &block)
60
75
  end
61
76
 
62
- def import_rows(rows)
63
- import_options = ::RowBoat::Helpers.extract_import_options(options)
64
- import_into.import(rows, import_options)
65
- end
66
-
67
77
  def transaction_if_needed(&block)
68
78
  options[:wrap_in_transaction] ? import_into.transaction(&block) : yield
69
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RowBoat
4
- VERSION = "0.1.0.alpha.1"
4
+ VERSION = "0.1.0.alpha.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: row_boat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha.1
4
+ version: 0.1.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crismali