valigator-csv 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/lib/valigator/csv.rb +1 -0
- data/lib/valigator/csv/error.rb +5 -1
- data/lib/valigator/csv/validator.rb +8 -0
- data/lib/valigator/csv/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 170abf203c29a7cdf2543ced369e864844a8c2d8
|
4
|
+
data.tar.gz: d220e53500d76ab4ee8d4a63e38ffee6cf291c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667130ce6748b198ee754439b7492d91f0e168d2fbeebb38a6fa7af4e06f6d7ba0597b22bc40a45f6bba2601b9ba4bf7dd01c4c52630eb6fbbf1d145e662231a
|
7
|
+
data.tar.gz: 4891810ae82bbe5428c1447b4d3149432994c05915e8f7808ef578402bb99c21b8c5aefddbf7aefcca9c42234f264f7510ce57f28b505ce7a3ffa93e6cc215db
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.3
|
data/lib/valigator/csv.rb
CHANGED
data/lib/valigator/csv/error.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Valigator
|
2
2
|
module CSV
|
3
|
+
class UnhandledTypeError < StandardError
|
4
|
+
end
|
5
|
+
|
6
|
+
|
3
7
|
class Error
|
4
8
|
|
5
9
|
attr_reader :row, :type, :message
|
@@ -77,7 +81,7 @@ module Valigator
|
|
77
81
|
when /invalid byte sequence/
|
78
82
|
'invalid_encoding'
|
79
83
|
else
|
80
|
-
raise
|
84
|
+
raise UnhandledTypeError, message
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
@@ -17,6 +17,8 @@ module Valigator
|
|
17
17
|
def validate(options = {})
|
18
18
|
::CSV.foreach(@filename, build_options(options)) { |_row|}
|
19
19
|
rescue ::CSV::MalformedCSVError, ArgumentError => error
|
20
|
+
raise if unrelated_error?(error)
|
21
|
+
|
20
22
|
@errors << CSV::Error.new(error)
|
21
23
|
end
|
22
24
|
|
@@ -32,6 +34,12 @@ module Valigator
|
|
32
34
|
}
|
33
35
|
end
|
34
36
|
|
37
|
+
|
38
|
+
|
39
|
+
def unrelated_error?(error)
|
40
|
+
error.is_a?(ArgumentError) && error.message != 'invalid byte sequence in UTF-8'
|
41
|
+
end
|
42
|
+
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valigator-csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nagy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- ".gitattributes"
|
65
65
|
- ".gitignore"
|
66
66
|
- ".rspec"
|
67
|
+
- ".ruby-version"
|
67
68
|
- ".travis.yml"
|
68
69
|
- Gemfile
|
69
70
|
- README.md
|