row_boat 0.4.0 → 0.5.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/API.md +2 -2
- data/gemfiles/csv_import_1.1_and_0.18.gemfile.lock +2 -2
- data/lib/row_boat/base.rb +5 -5
- data/lib/row_boat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35348937cd6f4db06f17a2c28edd13f6597c25c1
|
4
|
+
data.tar.gz: e88eddb7470aa700c9f6224bf35ca74d2e945101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea2b41e6459899550303e8e91e32feb5dc081d4fa98bebd725be0d9ab3bf2aceeec6fc01b9f50695afb987598988d926a0b9875956e05605a4ca9885ff6939e
|
7
|
+
data.tar.gz: c5bc5cf77f6fdfc188e725b34b8b8a05ca5131bd138b7c01dc2343f390421ec686b57132043f35a350c44d0af393184730c35194438878958ac17fc425876b17
|
data/API.md
CHANGED
@@ -46,7 +46,7 @@ Imports database records form the given CSV-like object. The CSV-like object can
|
|
46
46
|
It returns a hash containing
|
47
47
|
|
48
48
|
- `:invalid_records` - an array of all records that failed to import since they were invalid. If you've configured the `:validate` option to be `false` it will be an empty array.
|
49
|
-
- `:
|
49
|
+
- `:total_inserts` - the total number of database inserts that were run.
|
50
50
|
- `:inserted_ids` - an array of all of the ids of records inserted into the database.
|
51
51
|
- `:skipped_rows` - every row skipped by returning `nil` from [`preprocess_row`](#preprocess_row).
|
52
52
|
|
@@ -262,7 +262,7 @@ Whatever you define in this method will be merged into the defaults:
|
|
262
262
|
|
263
263
|
- `:chunk_size` - `500`
|
264
264
|
- `:key_mapping` - `column_mapping`
|
265
|
-
- `:recursive` - `
|
265
|
+
- `:recursive` - `false`
|
266
266
|
- `:remove_unmapped_keys` - `true`
|
267
267
|
- `:validate` - `true`
|
268
268
|
- `:value_converters` - `csv_value_converters`
|
data/lib/row_boat/base.rb
CHANGED
@@ -16,7 +16,7 @@ module RowBoat
|
|
16
16
|
# @overload import(csv_source)
|
17
17
|
# @param csv_source [String, #read] a CSV-like object that SmarterCSV can read.
|
18
18
|
#
|
19
|
-
# @return [Hash] a hash with +:invalid_records+, +:
|
19
|
+
# @return [Hash] a hash with +:invalid_records+, +:total_inserts+, +:inserted_ids+, and +:skipped_rows+.
|
20
20
|
#
|
21
21
|
# @see https://github.com/tilo/smarter_csv#documentation SmarterCSV Docs
|
22
22
|
def import(*args, &block)
|
@@ -40,7 +40,7 @@ module RowBoat
|
|
40
40
|
# Parses the csv and inserts/updates the database. You probably won't call this method directly,
|
41
41
|
# instead you would call {RowBoat::Base.import}.
|
42
42
|
#
|
43
|
-
# @return [Hash] a hash with +:invalid_records+, +:
|
43
|
+
# @return [Hash] a hash with +:invalid_records+, +:total_inserts+, +:inserted_ids+, and +:skipped_rows+.
|
44
44
|
def import
|
45
45
|
import_results = []
|
46
46
|
|
@@ -156,7 +156,7 @@ module RowBoat
|
|
156
156
|
def default_options
|
157
157
|
{
|
158
158
|
chunk_size: 500,
|
159
|
-
recursive:
|
159
|
+
recursive: false,
|
160
160
|
validate: true,
|
161
161
|
value_converters: csv_value_converters,
|
162
162
|
wrap_in_transaction: true
|
@@ -305,12 +305,12 @@ module RowBoat
|
|
305
305
|
def process_import_results(import_results)
|
306
306
|
import_results.each_with_object(
|
307
307
|
invalid_records: [],
|
308
|
-
|
308
|
+
total_inserts: 0,
|
309
309
|
inserted_ids: [],
|
310
310
|
skipped_rows: skipped_rows
|
311
311
|
) do |import_result, total_results|
|
312
312
|
total_results[:invalid_records] += import_result.failed_instances
|
313
|
-
total_results[:
|
313
|
+
total_results[:total_inserts] += import_result.num_inserts
|
314
314
|
total_results[:inserted_ids] += import_result.ids
|
315
315
|
end
|
316
316
|
end
|
data/lib/row_boat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: row_boat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Crismali
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|