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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 408c79edf8a6541c2528a98c012101c211b3f767c93aacf6095a809d08c15fb8
4
- data.tar.gz: d5bcd638fbbf3796836c4c3db40d9c3d86751d08401646189397fcdfe3f3c27c
3
+ metadata.gz: 4cae1d12cef1a58332b4209fbc24e7c751de7f648ec466b023e3d38a2e55b580
4
+ data.tar.gz: 9135d59abc835d065cb75d53684f9d1279b1bed466c7176092618d0116da177e
5
5
  SHA512:
6
- metadata.gz: f206524bb271dcaf77d726bd532309dc6aed1628561a6927662e7751a9fd23b5c22de0c3175648106e9a7060a9d7934966ea090ec7f64fa4eaca2e2e434c689c
7
- data.tar.gz: e6b1c1d114919bc2bf634669960cfccbb9cae857397a02dc550da6cef35e827c675051915d62640d2d43660279220de242154cc5c294ac7ae8eda59e2e45f016
6
+ metadata.gz: 44bb35b8e5b982b1d880e108b75822cbd9fda23b83eaae4fe15abd194553c36467cb6ca843c86c082f8497d59d3bfe5512becfedbe22395c054b4f27e68ab096
7
+ data.tar.gz: 6136354c3e47c384271f0f73bcb31526e7f66e6181669953c8da30f642d02353996f256f7dc62b8f4abc8641f0df779d2c87b67d24d88141a1e72a56d2f7447b
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- .idea/
10
+ .idea/
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.7.3
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.7
4
- - 2.2.3
5
- - 2.6.0
6
- before_install: gem install bundler -v 1.10.6
3
+ - 2.3.8
4
+ - 2.4.9
5
+ - 2.5.7
6
+ - 2.6.2
7
+ - 2.6.5
8
+ before_install: gem install bundler
@@ -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
- raise UnhandledTypeError, message
77
+ 'unknown_error'
100
78
  end
101
79
  end
102
-
103
-
104
80
  end
105
81
  end
106
82
  end
@@ -1,5 +1,5 @@
1
1
  module Valigator
2
2
  module CSV
3
- VERSION = "2.0"
3
+ VERSION = "4.0.1"
4
4
  end
5
5
  end
data/lib/valigator/csv.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'csv'
1
2
  require 'valigator/csv/version'
2
3
 
3
4
  module Valigator
data/lib/valigator.rb CHANGED
@@ -1,2 +1 @@
1
- require 'csv'
2
1
  require 'valigator/csv'
data/repo-info.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "is_in_production": true,
3
+ "is_scannable": true,
4
+ "is_critical": false,
5
+ "contact": "g-gsuite-smartinsight@emarsys.com",
6
+ "hosted": null
7
+ }
@@ -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.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "rake", "~> 10.0"
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: '2.0'
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: 2019-03-02 00:00:00.000000000 Z
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: '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
33
33
  requirements:
34
- - - "~>"
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '10.0'
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: '10.0'
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: '0'
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.0.1
111
+ rubygems_version: 3.1.6
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Yet another CSV validator library