csv_importable 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81002b05d608a444919a03ca6622f4282cb9a3f1
4
- data.tar.gz: 0f8d006c2a2ea37fc1f48c5e00c206ea6db6b23f
3
+ metadata.gz: b24ce628fef6200d22e2a893af528412aa0bd770
4
+ data.tar.gz: 192aedab823e106a0e75e22469a11797ab129b54
5
5
  SHA512:
6
- metadata.gz: 85e4494d68bb74edb63040bd8b68dc19ecbefa99e21ee3251c010e6bcae5e308636231346e6174f0a8406053977272def9cb888eb1a2326583fd4f37d1c75ef5
7
- data.tar.gz: 707bb25d7b7ee78403e4ffdbc007f53f4ce960d1019f10b5e0e6f223f0bedf72e20fb5502feddcf92b3a593c11f5f26985ec09d1b5915ebedb54056acef459a2
6
+ metadata.gz: 2436754123fed4d793391e4acd6323fc871370288ff233fa79489e574a7bd4deb44cd3c3aae300860343a81558d9d270136df89fd9a6b50eefe92360b06b321f
7
+ data.tar.gz: 8cdb9d8a0d3d14e9bd412794444e52daa6cc6798863901e0ba52eca02a0353d6cebe5aed2ab9142864eab5fcdd1d532f52c7d863ba872b68aa030773426a4707
data/README.md CHANGED
@@ -62,7 +62,16 @@ class Import < ApplicationRecord
62
62
  include CSVImportable::Importable
63
63
 
64
64
  has_attached_file :file
65
- validates_attachment :file, content_type: { content_type: ['text/csv']}, message: "is not in CSV format"
65
+ validates_attachment :file,
66
+ content_type: {
67
+ content_type: [
68
+ 'text/plain',
69
+ 'text/csv',
70
+ 'application/vnd.ms-excel',
71
+ 'application/octet-stream'
72
+ ]
73
+ },
74
+ message: "is not in CSV format"
66
75
 
67
76
  validates :file, presence: true
68
77
 
@@ -96,6 +105,14 @@ class Import < ApplicationRecord
96
105
  end
97
106
  ```
98
107
 
108
+ And create a new file at config/initializers/paperclip.rb:
109
+
110
+ ```
111
+ Paperclip.options[:content_type_mappings] = {
112
+ csv: ['application/vnd.ms-excel', 'application/octet-stream', 'text/csv', 'text/plain', 'text/comma-separated-values']
113
+ }
114
+ ```
115
+
99
116
  And then create a subclass that should correspond to the specific importing task you are implementing. For example, if you are trying to import users from a CSV, you might implement a `UserImport` class which inherits from `Import`:
100
117
 
101
118
  app/models/user_import.rb:
@@ -12,7 +12,7 @@ module CSVImportable
12
12
  option.downcase if option.respond_to?(:downcase)
13
13
  end
14
14
  raise unless opts.include?(val)
15
- val
15
+ value
16
16
  end
17
17
 
18
18
  def error_message
@@ -1,3 +1,3 @@
1
1
  module CsvImportable
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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-18 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler