csv_importable 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/csv_importable/csv_importer.rb +1 -0
- data/lib/csv_importable/importable.rb +1 -1
- data/lib/csv_importable/type_parser.rb +1 -1
- data/lib/csv_importable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08a19b1bc64a60ce3c55879dc56570baf6a65878
|
4
|
+
data.tar.gz: 77c5aa2a3a557be40a01a10f2adf37706b770c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c1c9954d78f6b6e1b9f2aaf9cbdaea9c323c73a3d85db6ccc637d29fc5b517d4ebeb71e1b935b7aeab806a1769a0031c4f7a6e10bafa1481420f013cec3b553
|
7
|
+
data.tar.gz: 2878b730d4ef523e3c8d8cf28e04fbce63c6faa32cbba609ce2883724a944d2a8c517a718d1b38ef949b11c06dbf92f26c6c2c9798c1526f942aafc9ef53ddec
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ class Import < ApplicationRecord
|
|
80
80
|
## you may need to implement something different
|
81
81
|
## for a different background job processor
|
82
82
|
# handle_asynchronously :process_in_background
|
83
|
-
|
83
|
+
|
84
84
|
|
85
85
|
def read_file
|
86
86
|
# needs to return StringIO of file
|
@@ -134,7 +134,7 @@ The `RowImporter` class handles the logic surrounding how one row in the CSV sho
|
|
134
134
|
```ruby
|
135
135
|
class UserRowImporter < CSVImportable::RowImporter
|
136
136
|
def import_row
|
137
|
-
|
137
|
+
User.create(
|
138
138
|
email: pull_string('email', required: true),
|
139
139
|
first_name: pull_string('first_name', required: true),
|
140
140
|
last_name: pull_string('last_name', required: true),
|
@@ -325,11 +325,11 @@ class CustomDateTypeParser < CSVImportable::TypeParser
|
|
325
325
|
end
|
326
326
|
```
|
327
327
|
|
328
|
-
Now, in your `RowImporter` class you can call: `CustomDateTypeParser.new('my_date_field', row: row)` to return a date object when the data is in the right format. If the parser fails to parse the field, it will add the correct error message for your user to review and resolve.
|
328
|
+
Now, in your `RowImporter` class you can call: `CustomDateTypeParser.new('my_date_field', row: row).parse_val` to return a date object when the data is in the right format. If the parser fails to parse the field, it will add the correct error message for your user to review and resolve.
|
329
329
|
|
330
330
|
#### Ignoring Parsers
|
331
331
|
|
332
|
-
Inside a `RowImporter` class, you have access to `row` and `headers` methods. For example, you can call `row.field('field_name')` to pull data directly from the CSV.
|
332
|
+
Inside a `RowImporter` class, you have access to `row` and `headers` methods. For example, you can call `row.field('field_name')` to pull data directly from the CSV.
|
333
333
|
|
334
334
|
### ActiveAdmin
|
335
335
|
|
@@ -495,7 +495,7 @@ class ImportsController < ApplicationController
|
|
495
495
|
# def valid_type?
|
496
496
|
# Import::Types::ALL.include?(type)
|
497
497
|
# end
|
498
|
-
|
498
|
+
|
499
499
|
# def redirect_invalid_type
|
500
500
|
# flash.now[:alert] = 'Not a valid import type'
|
501
501
|
# return redirect_to :back
|
@@ -18,6 +18,7 @@ module CSVImportable
|
|
18
18
|
@importable_class = args[:importable_class]
|
19
19
|
@big_file_threshold = args[:big_file_threshold]
|
20
20
|
@import_obj = importable_class.find(import_id) if import_id
|
21
|
+
@import_obj = args[:import_obj] if args[:import_obj]
|
21
22
|
# because we can't pass file_string to delayed job
|
22
23
|
@file_string = @import_obj.read_file if @import_obj
|
23
24
|
@should_replace = args.fetch(:should_replace, false)
|
@@ -130,7 +130,7 @@ module CSVImportable
|
|
130
130
|
}.merge(importer_options)
|
131
131
|
|
132
132
|
if new_record? && !processing? # e.g. new record that's not async
|
133
|
-
args = args.merge(file_string: read_file)
|
133
|
+
args = args.merge(file_string: read_file, import_obj: self)
|
134
134
|
else
|
135
135
|
args = args.merge(import_id: id, importable_class: importable_class)
|
136
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_importable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Francis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.6.13
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Import CSV files from users
|