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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a25825a77d48f8d2d0b51327cea6383ce035247
4
- data.tar.gz: 058e4274c4f5fb2d170ffe2ca0e502e8fd67ad0e
3
+ metadata.gz: 08a19b1bc64a60ce3c55879dc56570baf6a65878
4
+ data.tar.gz: 77c5aa2a3a557be40a01a10f2adf37706b770c4f
5
5
  SHA512:
6
- metadata.gz: b0541676bf4b1a8d749bd229edad13c27c13d2b4ebb5bd47167502a549b7e2bc2ca33c9cdd3aa5558c6036de625930850849b8b24fc16c689aed3014380a3f7d
7
- data.tar.gz: 681274ff454dcdbee4bc5e02808fa129aef23a0d69503ad64ba83e81a54e91e183163d476a48b568fb3111bbd62f175dadbf38c4aafd2e3c3d627441fcaa2871
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
- user = User.create(
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
@@ -34,7 +34,7 @@ module CSVImportable
34
34
  def pull_value_from_row
35
35
  return nil unless row
36
36
  # handle both caps and lowercase
37
- row.field(key.upcase) || row.field(key.downcase)
37
+ row.field(key) || row.field(key.upcase) || row.field(key.downcase)
38
38
  end
39
39
 
40
40
  def parse_val
@@ -1,3 +1,3 @@
1
1
  module CsvImportable
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  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.8
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-01-23 00:00:00.000000000 Z
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.5.1
121
+ rubygems_version: 2.6.13
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Import CSV files from users