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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff830cd1bad0287cbffc5ab322b6602cfe96392d
4
- data.tar.gz: 2a51f21c64af6f890a141abbd9e1094a2536ce23
3
+ metadata.gz: 170abf203c29a7cdf2543ced369e864844a8c2d8
4
+ data.tar.gz: d220e53500d76ab4ee8d4a63e38ffee6cf291c59
5
5
  SHA512:
6
- metadata.gz: 809ae1b7602956ecdf53c591e79dc42ba42b55d04fcfd1c474cb4441a6a6e3f66baaf6615ee73198ce78cd1cf63c73f025d1987e9d55d4e9bec2b776713507e9
7
- data.tar.gz: 9ca6d4f36aab4939e5aeb1c7195cfd83819f9b2bf8e79d63a8df07c17a2f35408b5554913e3981fa9c84d25b67fca9957ea75512e14024a47944a7db87d89dd0
6
+ metadata.gz: 667130ce6748b198ee754439b7492d91f0e168d2fbeebb38a6fa7af4e06f6d7ba0597b22bc40a45f6bba2601b9ba4bf7dd01c4c52630eb6fbbf1d145e662231a
7
+ data.tar.gz: 4891810ae82bbe5428c1447b4d3149432994c05915e8f7808ef578402bb99c21b8c5aefddbf7aefcca9c42234f264f7510ce57f28b505ce7a3ffa93e6cc215db
@@ -0,0 +1 @@
1
+ 2.2.3
@@ -1,6 +1,7 @@
1
1
  module Valigator
2
2
  module CSV
3
3
  autoload :Error, 'valigator/csv/error'
4
+ autoload :UnhandledTypeError, 'valigator/csv/error'
4
5
  autoload :Validator, 'valigator/csv/validator'
5
6
  autoload :Version, 'valigator/csv/version'
6
7
  end
@@ -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 ArgumentError, 'unknown type'
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
@@ -1,5 +1,5 @@
1
1
  module Valigator
2
2
  module CSV
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  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.1.3
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-02 00:00:00.000000000 Z
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