valigator-csv 2.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +6 -4
- data/lib/valigator/csv/error.rb +2 -26
- data/lib/valigator/csv/version.rb +1 -1
- data/lib/valigator/csv.rb +1 -0
- data/lib/valigator.rb +0 -1
- data/repo-info.json +7 -0
- data/valigator-csv.gemspec +4 -2
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cae1d12cef1a58332b4209fbc24e7c751de7f648ec466b023e3d38a2e55b580
|
4
|
+
data.tar.gz: 9135d59abc835d065cb75d53684f9d1279b1bed466c7176092618d0116da177e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44bb35b8e5b982b1d880e108b75822cbd9fda23b83eaae4fe15abd194553c36467cb6ca843c86c082f8497d59d3bfe5512becfedbe22395c054b4f27e68ab096
|
7
|
+
data.tar.gz: 6136354c3e47c384271f0f73bcb31526e7f66e6181669953c8da30f642d02353996f256f7dc62b8f4abc8641f0df779d2c87b67d24d88141a1e72a56d2f7447b
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.3
|
data/.travis.yml
CHANGED
data/lib/valigator/csv/error.rb
CHANGED
@@ -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,15 +61,11 @@ 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
|
-
when /Missing or stray quote/
|
87
|
-
'stray_quote'
|
88
66
|
when /Unquoted fields do not allow/
|
89
67
|
'line_breaks'
|
90
|
-
when /Illegal quoting/
|
68
|
+
when /Missing or stray quote/, /Illegal quoting/, /Any value after quoted field isn't allowed/
|
91
69
|
'illegal_quoting'
|
92
70
|
when /Field size exceeded/
|
93
71
|
'field_size'
|
@@ -96,11 +74,9 @@ module Valigator
|
|
96
74
|
when /invalid byte sequence/i, /incompatible encoding/i, /incompatible character encodings/i
|
97
75
|
'invalid_encoding'
|
98
76
|
else
|
99
|
-
|
77
|
+
'unknown_error'
|
100
78
|
end
|
101
79
|
end
|
102
|
-
|
103
|
-
|
104
80
|
end
|
105
81
|
end
|
106
82
|
end
|
data/lib/valigator/csv.rb
CHANGED
data/lib/valigator.rb
CHANGED
data/repo-info.json
ADDED
data/valigator-csv.gemspec
CHANGED
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.
|
23
|
-
|
22
|
+
spec.required_ruby_version = '>= 2.3.8'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake", '>= 13.0'
|
24
26
|
spec.add_development_dependency "rspec"
|
25
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:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nagy
|
@@ -11,36 +11,36 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-09-16 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: '
|
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: '
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- - "
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '13.0'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "
|
41
|
+
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '13.0'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: rspec
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/valigator/csv/row_validators/ragged.rb
|
88
88
|
- lib/valigator/csv/validator.rb
|
89
89
|
- lib/valigator/csv/version.rb
|
90
|
+
- repo-info.json
|
90
91
|
- valigator-csv.gemspec
|
91
92
|
homepage: https://github.com/emartech/valigator-csv
|
92
93
|
licenses:
|
@@ -100,14 +101,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
101
|
requirements:
|
101
102
|
- - ">="
|
102
103
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
+
version: 2.3.8
|
104
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
106
|
requirements:
|
106
107
|
- - ">="
|
107
108
|
- !ruby/object:Gem::Version
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.1.6
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Yet another CSV validator library
|