valigator-csv 1.5.1 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/LICENSE.txt +7 -0
- data/README.md +2 -0
- data/lib/valigator.rb +1 -0
- data/lib/valigator/csv.rb +2 -1
- data/lib/valigator/csv/error.rb +9 -2
- data/lib/valigator/csv/validator.rb +5 -4
- data/lib/valigator/csv/version.rb +1 -1
- data/valigator-csv.gemspec +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 408c79edf8a6541c2528a98c012101c211b3f767c93aacf6095a809d08c15fb8
|
4
|
+
data.tar.gz: d5bcd638fbbf3796836c4c3db40d9c3d86751d08401646189397fcdfe3f3c27c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f206524bb271dcaf77d726bd532309dc6aed1628561a6927662e7751a9fd23b5c22de0c3175648106e9a7060a9d7934966ea090ec7f64fa4eaca2e2e434c689c
|
7
|
+
data.tar.gz: e6b1c1d114919bc2bf634669960cfccbb9cae857397a02dc550da6cef35e827c675051915d62640d2d43660279220de242154cc5c294ac7ae8eda59e2e45f016
|
data/.rspec
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.1
|
data/.travis.yml
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright © 2018 Emarsys
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Valigator::CSV
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/emartech/valigator-csv.svg?branch=master)](https://travis-ci.org/emartech/valigator-csv)
|
4
|
+
|
3
5
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/valigator/csv`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
6
|
|
5
7
|
TODO: Delete this and the text above, and describe your gem
|
data/lib/valigator.rb
CHANGED
data/lib/valigator/csv.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'valigator/csv/version'
|
2
|
+
|
1
3
|
module Valigator
|
2
4
|
module CSV
|
3
5
|
autoload :Error, 'valigator/csv/error'
|
@@ -6,6 +8,5 @@ module Valigator
|
|
6
8
|
autoload :Validator, 'valigator/csv/validator'
|
7
9
|
autoload :FieldValidators, 'valigator/csv/field_validators'
|
8
10
|
autoload :RowValidators, 'valigator/csv/row_validators'
|
9
|
-
autoload :Version, 'valigator/csv/version'
|
10
11
|
end
|
11
12
|
end
|
data/lib/valigator/csv/error.rb
CHANGED
@@ -52,7 +52,14 @@ module Valigator
|
|
52
52
|
|
53
53
|
|
54
54
|
def build_from_error(error)
|
55
|
-
|
55
|
+
error_message = standardize_message(error.message)
|
56
|
+
build map_to_type(error_message), error_message, determine_row(error_message)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
def standardize_message(message)
|
62
|
+
message.sub('Do not allow except col_sep_split_separator after quoted fields', 'Missing or stray quote')
|
56
63
|
end
|
57
64
|
|
58
65
|
|
@@ -86,7 +93,7 @@ module Valigator
|
|
86
93
|
'field_size'
|
87
94
|
when /Unclosed quoted field/
|
88
95
|
'unclosed_quote'
|
89
|
-
when /invalid byte sequence
|
96
|
+
when /invalid byte sequence/i, /incompatible encoding/i, /incompatible character encodings/i
|
90
97
|
'invalid_encoding'
|
91
98
|
else
|
92
99
|
raise UnhandledTypeError, message
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'csv'
|
2
|
-
|
3
1
|
module Valigator
|
4
2
|
module CSV
|
5
3
|
class Validator
|
@@ -9,6 +7,7 @@ module Valigator
|
|
9
7
|
|
10
8
|
def initialize(filename)
|
11
9
|
@filename = filename
|
10
|
+
@current_row_number = 0
|
12
11
|
@errors = []
|
13
12
|
@config = default_config
|
14
13
|
end
|
@@ -17,8 +16,10 @@ module Valigator
|
|
17
16
|
|
18
17
|
def validate(options = {})
|
19
18
|
config.merge! options
|
19
|
+
@current_row_number = csv_options(options)[:headers] ? 1 : 0
|
20
20
|
|
21
21
|
::CSV.foreach(filename, csv_options(options)) do |row|
|
22
|
+
@current_row_number += 1
|
22
23
|
validate_fields row, options
|
23
24
|
validate_row row, options
|
24
25
|
|
@@ -105,7 +106,7 @@ module Valigator
|
|
105
106
|
{
|
106
107
|
type: validator.error_type,
|
107
108
|
message: validator.error_message,
|
108
|
-
row:
|
109
|
+
row: @current_row_number,
|
109
110
|
field: field
|
110
111
|
}
|
111
112
|
end
|
@@ -115,4 +116,4 @@ module Valigator
|
|
115
116
|
end
|
116
117
|
end
|
117
118
|
end
|
118
|
-
end
|
119
|
+
end
|
data/valigator-csv.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Valigator::CSV::VERSION
|
9
9
|
spec.authors = ['Daniel Nagy', 'Istvan Demeter', 'Tamas Drahos', 'Milan Unicsovics']
|
10
10
|
spec.email = ['naitodai@gmail.com', 'demeter.istvan@gmail.com', 'drahostamas@gmail.com', 'u.milan@gmail.com']
|
11
|
+
spec.license = 'MIT'
|
11
12
|
|
12
13
|
spec.summary = %q{Yet another CSV validator library}
|
13
14
|
spec.description = %q{Yet another CSV validator library. Just better.}
|
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: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nagy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2019-03-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- ".ruby-version"
|
72
72
|
- ".travis.yml"
|
73
73
|
- Gemfile
|
74
|
+
- LICENSE.txt
|
74
75
|
- README.md
|
75
76
|
- Rakefile
|
76
77
|
- lib/valigator.rb
|
@@ -88,7 +89,8 @@ files:
|
|
88
89
|
- lib/valigator/csv/version.rb
|
89
90
|
- valigator-csv.gemspec
|
90
91
|
homepage: https://github.com/emartech/valigator-csv
|
91
|
-
licenses:
|
92
|
+
licenses:
|
93
|
+
- MIT
|
92
94
|
metadata: {}
|
93
95
|
post_install_message:
|
94
96
|
rdoc_options: []
|
@@ -105,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
107
|
- !ruby/object:Gem::Version
|
106
108
|
version: '0'
|
107
109
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.4.5.1
|
110
|
+
rubygems_version: 3.0.1
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: Yet another CSV validator library
|