valigator-csv 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/valigator/csv/validator.rb +13 -1
- data/lib/valigator/csv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded0cc9a296b760d8b566f1f948672210a2ff9ac
|
4
|
+
data.tar.gz: 6df32436f942a618336e78f513f46f2c3e1eef64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f53067e4a2bb4abc6f440070a4ecd823d4c1c02af520d531406e59eba16e0e7b62a479957fce985aee516dc564a8fefae6c8ddab1bf3fa3bd82969e9de7c18c
|
7
|
+
data.tar.gz: 8db08753f5518c6268275ed8feb786ef30a93df624e9529e504c7d9e4d76bcbd11d501f95803c908f982ec45c49f9c1985d24f1be71d82d093800760d0b94a21
|
@@ -15,11 +15,23 @@ module Valigator
|
|
15
15
|
|
16
16
|
|
17
17
|
def validate(options = {})
|
18
|
-
::CSV.foreach(@filename,
|
18
|
+
::CSV.foreach(@filename, build_options(options)) { |_row|}
|
19
19
|
rescue ::CSV::MalformedCSVError, ArgumentError => error
|
20
20
|
@errors << CSV::Error.new(error)
|
21
21
|
end
|
22
22
|
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def build_options(options = {})
|
28
|
+
{
|
29
|
+
col_sep: options[:col_sep] || ',',
|
30
|
+
quote_char: options[:quote_char] || '"',
|
31
|
+
encoding: options[:encoding] || 'UTF-8'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
23
35
|
end
|
24
36
|
end
|
25
37
|
end
|