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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 50fed79789474fc436055d8d1bd6a13461360410
4
- data.tar.gz: 6f5c92102166f7cb757b8519ace411b83b71818d
2
+ SHA256:
3
+ metadata.gz: 408c79edf8a6541c2528a98c012101c211b3f767c93aacf6095a809d08c15fb8
4
+ data.tar.gz: d5bcd638fbbf3796836c4c3db40d9c3d86751d08401646189397fcdfe3f3c27c
5
5
  SHA512:
6
- metadata.gz: d86d34f1a4cac3d7657adc0f25126adf9617b0308a5015203f166d9ada6387b9ffa3c9e018559ef3961e85454b132ee1683dc54cb79fad3b246904be2573790f
7
- data.tar.gz: 91bf0ec65f6778ce4b58560c78eb0ba57d6919100c1e3e1217651cf110dde2354c42fdac597ff2776e02fc79cc9d7c43d59ecf45227417f118e1d31390a0f5ed
6
+ metadata.gz: f206524bb271dcaf77d726bd532309dc6aed1628561a6927662e7751a9fd23b5c22de0c3175648106e9a7060a9d7934966ea090ec7f64fa4eaca2e2e434c689c
7
+ data.tar.gz: e6b1c1d114919bc2bf634669960cfccbb9cae857397a02dc550da6cef35e827c675051915d62640d2d43660279220de242154cc5c294ac7ae8eda59e2e45f016
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
+ --require spec_helper
1
2
  --format documentation
2
3
  --color
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.6.1
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0-p647
4
3
  - 2.1.7
5
4
  - 2.2.3
5
+ - 2.6.0
6
6
  before_install: gem install bundler -v 1.10.6
@@ -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
@@ -1 +1,2 @@
1
+ require 'csv'
1
2
  require 'valigator/csv'
@@ -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
@@ -52,7 +52,14 @@ module Valigator
52
52
 
53
53
 
54
54
  def build_from_error(error)
55
- build map_to_type(error.message), error.message, determine_row(error.message)
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/, /incompatible encoding/, /incompatible character encodings/
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: $INPUT_LINE_NUMBER,
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
@@ -1,5 +1,5 @@
1
1
  module Valigator
2
2
  module CSV
3
- VERSION = "1.5.1"
3
+ VERSION = "2.0"
4
4
  end
5
5
  end
@@ -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: 1.5.1
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: 2017-07-04 00:00:00.000000000 Z
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
- rubyforge_project:
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