filetype_validation 0.1.4 → 0.1.5

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: a938a1467a255f48672027f5e59ee1f3653ac14f
4
- data.tar.gz: 9e9d8ff18f5fc5db51e0cedf8614ea8821f32f95
3
+ metadata.gz: 67e97bd93bc8490382a805ec0dc9db6566e75965
4
+ data.tar.gz: 1d13dc0fa63221c753914b91903ad7570be7d2cf
5
5
  SHA512:
6
- metadata.gz: 8e650852e7d10c8d76210a0d98bf180f79a54cfa4a76d3e6a476e46e1c9880f9abe5a98a5b8f4bb6f21a07a97d345a8843d72bfa609c8dcc4ed0c3df04ff9e63
7
- data.tar.gz: 1b241d88e21174e10fc3c9782ccf1300d0769255e4d1fe00de8e1ea585c65988cfb6642ff4c8beb0a79ba87cbbc219b1dfbe38adcb981a6222b832f7d6b4fed9
6
+ metadata.gz: 5a4e5f9465cb41aab4f7bee318b5c849f10c9a78afa0ff721d557a54ae756da2e46d36f026b068c5f1c4d14b342288b817bae92447a4871379e71d3cde669ede
7
+ data.tar.gz: 941ea67c3e76f1ad457654ee9652c878138b0d3698bfad61329208735be4672689dcb7ea6ce6a4217b787c3e8a08c9c5dc11c74e7a17678af0854a7eaa14e5f2
@@ -4,15 +4,15 @@ 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
9
- UTF_OPTIONS = { invalid: :replace, undef: :replace, replace: '' }.freeze
7
+ MAX_LINES = 25
8
+ HEADERS = true
10
9
 
11
10
  # Evaluates whether the file is a csv
12
11
  #
13
12
  # @return [Boolean] true if it's a csv file
14
13
  def valid?
15
- csv_extension? && FiletypeValidation.plaintext?(file, options) &&
14
+ csv_extension? &&
15
+ FiletypeValidation.plaintext?(file, options) &&
16
16
  parse_csv?
17
17
  end
18
18
 
@@ -36,13 +36,15 @@ module FiletypeValidation
36
36
  file_sample = File.foreach(file.path)
37
37
  .first(options[:max_lines] || MAX_LINES)
38
38
  .join
39
- .encode('UTF-16', UTF_OPTIONS)
40
- .encode('UTF-8', UTF_OPTIONS)
41
39
 
42
40
  CSV.parse(file_sample, headers: options[:headers] || HEADERS)
43
41
  true
42
+ rescue ArgumentError
43
+ # TODO: false, 'Invalid character on line ?.'
44
+ true
44
45
  rescue CSV::MalformedCSVError
45
- false
46
+ # TODO: false, 'Unclosed quoted field on line ?.'
47
+ true
46
48
  end
47
49
  end
48
50
  end
@@ -1,3 +1,3 @@
1
1
  module FiletypeValidation
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.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.4
4
+ version: 0.1.5
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-08-09 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler