valigator-csv 2.0.1 → 3.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
  SHA256:
3
- metadata.gz: b2692d18252a45a4c9dc01d461c95fd6b1bbb806a0ef8fe37e8e768b22caa9d7
4
- data.tar.gz: 4c0bdb9ccd0d7a924c58691b78d6d9881ee2d0e848ef407f2f0b48b1887b4170
3
+ metadata.gz: 02166b59856576cf3db8b7dac53df4c1ff17e902730f86935e511b132d045672
4
+ data.tar.gz: 573bb1ac2546969ed4f7b92652e9e1d29d94d2f0678abeca8d9b79a799b2fcc8
5
5
  SHA512:
6
- metadata.gz: '0819d08b91a25fc7f8658f6b251e63b71ba5bf078a5be7482c7ebe65a00c5c748b70c493b82050815405ba58a0a2bd96bec746d8083ab86b0349fc16766f1e80'
7
- data.tar.gz: 95de9a9d896da7e9da0b21af185591467c8a5dec3f936c457583b7a0f46f13d2995a9040c03e23207efc134e323ff8bf98b928111e3ebde2011abd191013ddd2
6
+ metadata.gz: c0d741f3710be17f48dde03c36a6c3c5c21e0ab94315e22167d56310bd60e34bb0b250642ffb2f2774b0cbb05a5c7056d098c8d974d9a668a62ad6d71430d213
7
+ data.tar.gz: 0f671034a6511193c7fa5156ae946c4a2454b576463ff379298f3b04b3fab2d00acaf80d9ddc8d4b1d8ad619161b49357e283022215edcd72be47552c1e7f0d2
@@ -3,17 +3,13 @@ module Valigator
3
3
  class ErrorsLimitReachedError < StandardError
4
4
  end
5
5
 
6
-
7
6
  class UnhandledTypeError < StandardError
8
7
  end
9
8
 
10
-
11
9
  class Error
12
10
 
13
11
  attr_reader :row, :type, :message, :field, :details
14
12
 
15
-
16
-
17
13
  def initialize(error)
18
14
  case error
19
15
  when Hash
@@ -23,14 +19,10 @@ module Valigator
23
19
  end
24
20
  end
25
21
 
26
-
27
-
28
22
  def ==(other)
29
23
  row == other.row && message == other.message && type == other.type && field == other.field && details == other.details
30
24
  end
31
25
 
32
-
33
-
34
26
  def to_hash
35
27
  {
36
28
  row: row,
@@ -41,36 +33,26 @@ module Valigator
41
33
  }
42
34
  end
43
35
 
44
-
45
-
46
36
  private
47
37
 
48
38
  def build_from_hash(error)
49
39
  build error[:type], error[:message], error[:row], error[:field], error[:details]
50
40
  end
51
41
 
52
-
53
-
54
42
  def build_from_error(error)
55
43
  error_message = standardize_message(error.message)
56
44
  build map_to_type(error_message), error_message, determine_row(error_message)
57
45
  end
58
46
 
59
-
60
-
61
47
  def standardize_message(message)
62
48
  message.sub('Do not allow except col_sep_split_separator after quoted fields', 'Missing or stray quote')
63
49
  end
64
50
 
65
-
66
-
67
51
  def determine_row(message)
68
52
  matches = /line (?<lineno>\d+)/.match(message)
69
53
  matches[:lineno].to_i if matches
70
54
  end
71
55
 
72
-
73
-
74
56
  def build(type, message, row, field = nil, details = nil)
75
57
  @type = type
76
58
  @row = row
@@ -79,8 +61,6 @@ module Valigator
79
61
  @details = details
80
62
  end
81
63
 
82
-
83
-
84
64
  def map_to_type(message)
85
65
  case message
86
66
  when /Missing or stray quote/
@@ -96,11 +76,9 @@ module Valigator
96
76
  when /invalid byte sequence/i, /incompatible encoding/i, /incompatible character encodings/i
97
77
  'invalid_encoding'
98
78
  else
99
- raise UnhandledTypeError, message
79
+ 'unknown_error'
100
80
  end
101
81
  end
102
-
103
-
104
82
  end
105
83
  end
106
84
  end
@@ -1,5 +1,5 @@
1
1
  module Valigator
2
2
  module CSV
3
- VERSION = "2.0.1"
3
+ VERSION = "3.0"
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.1'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec"
27
27
  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: 2.0.1
4
+ version: '3.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Nagy
@@ -11,22 +11,22 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-03-02 00:00:00.000000000 Z
14
+ date: 2019-12-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '1.10'
22
+ version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '1.10'
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement