filetype_validation 0.1.3 → 0.1.4

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: 750c8f2c447e4ae03d43f260b9567b22d37b5aaa
4
- data.tar.gz: 128de4a56514ebc870dbe39b8cb78533aebea4b3
3
+ metadata.gz: a938a1467a255f48672027f5e59ee1f3653ac14f
4
+ data.tar.gz: 9e9d8ff18f5fc5db51e0cedf8614ea8821f32f95
5
5
  SHA512:
6
- metadata.gz: a71841e0b4423cefce14b91d8b39cf8590d0a73165faded3da32dac18f9c2e7cf7e3d28df1526278b0ce8533a9acf01b6875259a6f93664a851870510a73b44c
7
- data.tar.gz: b2d55993b6e74a48878e35a3df39fe4f3f0b3056a7600ed855d9361f4c3a26282adcc4e6a5f3a44890552a39edd495ad330cb1d4e49a4a82761c2e25bc42b35d
6
+ metadata.gz: 8e650852e7d10c8d76210a0d98bf180f79a54cfa4a76d3e6a476e46e1c9880f9abe5a98a5b8f4bb6f21a07a97d345a8843d72bfa609c8dcc4ed0c3df04ff9e63
7
+ data.tar.gz: 1b241d88e21174e10fc3c9782ccf1300d0769255e4d1fe00de8e1ea585c65988cfb6642ff4c8beb0a79ba87cbbc219b1dfbe38adcb981a6222b832f7d6b4fed9
@@ -4,8 +4,9 @@ require 'filetype_validation/base_validator'
4
4
  module FiletypeValidation
5
5
  # aka Comma Separated Valuedator <--- hahahahhahah
6
6
  class CsvValidator < BaseValidator
7
- MAX_LINES = 25
8
- HEADERS = true
7
+ MAX_LINES = 25
8
+ HEADERS = true
9
+ UTF_OPTIONS = { invalid: :replace, undef: :replace, replace: '' }.freeze
9
10
 
10
11
  # Evaluates whether the file is a csv
11
12
  #
@@ -35,10 +36,12 @@ module FiletypeValidation
35
36
  file_sample = File.foreach(file.path)
36
37
  .first(options[:max_lines] || MAX_LINES)
37
38
  .join
38
- CSV.parse(file_sample, headers: options[:headers] || HEADERS)
39
+ .encode('UTF-16', UTF_OPTIONS)
40
+ .encode('UTF-8', UTF_OPTIONS)
39
41
 
42
+ CSV.parse(file_sample, headers: options[:headers] || HEADERS)
40
43
  true
41
- rescue ArgumentError
44
+ rescue CSV::MalformedCSVError
42
45
  false
43
46
  end
44
47
  end
@@ -1,3 +1,3 @@
1
1
  module FiletypeValidation
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filetype_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Jacob
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler