csvlint 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/push.yml +11 -2
- data/.ruby-version +1 -1
- data/.standard_todo.yml +2 -5
- data/Appraisals +4 -0
- data/README.md +1 -1
- data/csvlint.gemspec +3 -3
- data/gemfiles/activesupport_7.2.gemfile +7 -0
- data/lib/csvlint/cli.rb +2 -2
- data/lib/csvlint/csvw/property_checker.rb +4 -4
- data/lib/csvlint/field.rb +6 -0
- data/lib/csvlint/schema.rb +2 -2
- data/lib/csvlint/validate.rb +3 -5
- data/lib/csvlint/version.rb +1 -1
- data/lib/csvlint.rb +1 -1
- data/spec/validator_spec.rb +2 -2
- metadata +20 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad0e814a8366671d93eb767885e657827a84456f6c141a02e7dbe5ba5bcb1892
|
4
|
+
data.tar.gz: 90abebb42e77c1a49e61eb151459f5ea0b98539b0f0415b87e924b63e226aaa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8d5462bc0c4306c308dde03264adad8c820bd1fe3d559e970210cdd809806d11a4fc5bea1830e5582774776edb3758f5d78fd4e7fe4c636872afaa4c00a236
|
7
|
+
data.tar.gz: 654659368878f232e0cbc6fa036343a39ac99a141c260ee552e90316f1a8d4a6e18c4ebba43200e7315dd71452602375d76b28cc5da934db6224e0c5239bceda
|
data/.github/workflows/push.yml
CHANGED
@@ -10,13 +10,14 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
|
-
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
|
13
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
|
14
14
|
activesupport-version:
|
15
15
|
- activesupport_5.2
|
16
16
|
- activesupport_6.0
|
17
17
|
- activesupport_6.1
|
18
18
|
- activesupport_7.0
|
19
19
|
- activesupport_7.1
|
20
|
+
- activesupport_7.2
|
20
21
|
exclude:
|
21
22
|
- ruby-version: '2.5'
|
22
23
|
activesupport-version: activesupport_7.0
|
@@ -26,6 +27,14 @@ jobs:
|
|
26
27
|
activesupport-version: activesupport_7.1
|
27
28
|
- ruby-version: '2.6'
|
28
29
|
activesupport-version: activesupport_7.1
|
30
|
+
- ruby-version: '2.5'
|
31
|
+
activesupport-version: activesupport_7.2
|
32
|
+
- ruby-version: '2.6'
|
33
|
+
activesupport-version: activesupport_7.2
|
34
|
+
- ruby-version: '2.7'
|
35
|
+
activesupport-version: activesupport_7.2
|
36
|
+
- ruby-version: '3.0'
|
37
|
+
activesupport-version: activesupport_7.2
|
29
38
|
fail-fast: false
|
30
39
|
|
31
40
|
env:
|
@@ -49,7 +58,7 @@ jobs:
|
|
49
58
|
- uses: ruby/setup-ruby@v1
|
50
59
|
with:
|
51
60
|
bundler-cache: true
|
52
|
-
ruby-version: "3.
|
61
|
+
ruby-version: "3.4"
|
53
62
|
- name: Install dependencies
|
54
63
|
run: bundle install
|
55
64
|
- name: Run the tests
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.1
|
data/.standard_todo.yml
CHANGED
@@ -13,7 +13,6 @@ ignore:
|
|
13
13
|
- Style/IdenticalConditionalBranches
|
14
14
|
- lib/csvlint/csvw/property_checker.rb:
|
15
15
|
- Performance/InefficientHashSearch
|
16
|
-
- Lint/UselessAssignment
|
17
16
|
- Naming/VariableName
|
18
17
|
- Style/SlicingWithRange
|
19
18
|
- Security/Open
|
@@ -24,18 +23,16 @@ ignore:
|
|
24
23
|
- Naming/VariableName
|
25
24
|
- lib/csvlint/schema.rb:
|
26
25
|
- Security/Open
|
27
|
-
- Lint/UselessAssignment
|
28
26
|
- Style/SlicingWithRange
|
29
27
|
- lib/csvlint/validate.rb:
|
30
|
-
- Lint/UselessAssignment
|
31
28
|
- Performance/Count
|
32
29
|
- Lint/BooleanSymbol
|
33
30
|
- Naming/VariableName
|
34
31
|
- Security/Open
|
35
32
|
- Lint/NonLocalExitFromIterator
|
36
|
-
- spec/validator_spec.rb:
|
37
|
-
- Lint/UselessAssignment
|
38
33
|
- lib/csvlint/schema.rb:
|
39
34
|
- Lint/UselessRescue
|
40
35
|
- lib/csvlint/validate.rb:
|
41
36
|
- Lint/UselessRescue
|
37
|
+
- lib/csvlint/cli.rb:
|
38
|
+
- Style/SafeNavigation
|
data/Appraisals
CHANGED
data/README.md
CHANGED
data/csvlint.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.required_ruby_version = [">= 2.5", "< 3.
|
19
|
+
spec.required_ruby_version = [">= 2.5", "< 3.5"]
|
20
20
|
|
21
21
|
spec.add_dependency "csv"
|
22
22
|
spec.add_dependency "rainbow"
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_dependency "thor"
|
30
30
|
spec.add_dependency "rack"
|
31
31
|
spec.add_dependency "net-http-persistent"
|
32
|
+
spec.add_dependency "mutex_m" # For Ruby 3.4+
|
32
33
|
|
33
34
|
spec.add_development_dependency "bundler", ">= 1.3"
|
34
35
|
spec.add_development_dependency "rake"
|
@@ -40,13 +41,12 @@ Gem::Specification.new do |spec|
|
|
40
41
|
spec.add_development_dependency "rspec"
|
41
42
|
spec.add_development_dependency "rspec-pride"
|
42
43
|
spec.add_development_dependency "rspec-expectations"
|
43
|
-
spec.add_development_dependency "
|
44
|
+
spec.add_development_dependency "coveralls_reborn"
|
44
45
|
spec.add_development_dependency "byebug"
|
45
46
|
spec.add_development_dependency "github_changelog_generator"
|
46
47
|
spec.add_development_dependency "aruba"
|
47
48
|
spec.add_development_dependency "rdf", "< 4.0"
|
48
49
|
spec.add_development_dependency "rdf-turtle"
|
49
|
-
spec.add_development_dependency "henry"
|
50
50
|
spec.add_development_dependency "standardrb"
|
51
51
|
spec.add_development_dependency "appraisal"
|
52
52
|
end
|
data/lib/csvlint/cli.rb
CHANGED
@@ -104,7 +104,7 @@ module Csvlint
|
|
104
104
|
location = "#{error.row ? "Row" : "Column"}: #{location}"
|
105
105
|
end
|
106
106
|
output_string = "#{index + 1}. "
|
107
|
-
if error.column && @schema
|
107
|
+
if error.column && @schema&.instance_of?(Csvlint::Schema)
|
108
108
|
unless @schema.fields[error.column - 1].nil?
|
109
109
|
output_string += "#{@schema.fields[error.column - 1].name}: "
|
110
110
|
end
|
@@ -176,7 +176,7 @@ module Csvlint
|
|
176
176
|
col: error.column
|
177
177
|
}
|
178
178
|
|
179
|
-
if error.column && @schema
|
179
|
+
if error.column && @schema&.instance_of?(Csvlint::Schema) && !@schema.fields[error.column - 1].nil?
|
180
180
|
field = @schema.fields[error.column - 1]
|
181
181
|
h[:header] = field.name
|
182
182
|
h[:constraints] = field.constraints.map { |k, v| [k.underscore, v] }.to_h
|
@@ -285,8 +285,8 @@ module Csvlint
|
|
285
285
|
warnings = []
|
286
286
|
if value.instance_of? Hash
|
287
287
|
if value["@id"]
|
288
|
-
raise Csvlint::Csvw::MetadataError.new("datatype.@id"), "datatype @id must not be the id of a built-in datatype (#{value["@id"]})" if BUILT_IN_DATATYPES.
|
289
|
-
|
288
|
+
raise Csvlint::Csvw::MetadataError.new("datatype.@id"), "datatype @id must not be the id of a built-in datatype (#{value["@id"]})" if BUILT_IN_DATATYPES.value?(value["@id"])
|
289
|
+
_, w, _ = PROPERTIES["@id"].call(value["@id"], base_url, lang)
|
290
290
|
unless w.nil?
|
291
291
|
warnings << w
|
292
292
|
value.delete("@id")
|
@@ -422,7 +422,7 @@ module Csvlint
|
|
422
422
|
elsif p == "url"
|
423
423
|
elsif p == "titles"
|
424
424
|
else
|
425
|
-
|
425
|
+
_, warning, type = check_property(p, v, base_url, lang)
|
426
426
|
if type != :transformation && !(warning.nil? || warning.empty?)
|
427
427
|
value.delete(p)
|
428
428
|
warnings << :invalid_property unless type == :transformation
|
@@ -555,7 +555,7 @@ module Csvlint
|
|
555
555
|
warnings = []
|
556
556
|
value.each do |p, v|
|
557
557
|
if ["resource", "schemaReference", "columnReference"].include? p
|
558
|
-
v, warning,
|
558
|
+
v, warning, _ = check_property(p, v, base_url, lang)
|
559
559
|
if warning.nil? || warning.empty?
|
560
560
|
value[p] = v
|
561
561
|
else
|
data/lib/csvlint/field.rb
CHANGED
@@ -82,6 +82,12 @@ module Csvlint
|
|
82
82
|
@uniques << value
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
if constraints["enum"]
|
87
|
+
unless constraints["enum"].include?(value)
|
88
|
+
build_errors(:invalid_enum_value, :schema, row, column, value, {"enum" => constraints["enum"]})
|
89
|
+
end
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
def validate_type(value, row, column)
|
data/lib/csvlint/schema.rb
CHANGED
@@ -48,7 +48,7 @@ module Csvlint
|
|
48
48
|
else
|
49
49
|
Schema.from_json_table(uri, json)
|
50
50
|
end
|
51
|
-
rescue TypeError
|
51
|
+
rescue TypeError
|
52
52
|
# NO IDEA what this was even trying to do - SP 20160526
|
53
53
|
rescue Csvlint::Csvw::MetadataError => e
|
54
54
|
raise e
|
@@ -88,7 +88,7 @@ module Csvlint
|
|
88
88
|
|
89
89
|
fields.each_with_index do |field, i|
|
90
90
|
value = values[i] || ""
|
91
|
-
|
91
|
+
field.validate_column(value, row, i + 1, all_errors)
|
92
92
|
@errors += fields[i].errors
|
93
93
|
@warnings += fields[i].warnings
|
94
94
|
end
|
data/lib/csvlint/validate.rb
CHANGED
@@ -157,7 +157,7 @@ module Csvlint
|
|
157
157
|
# If it's not a full line, then prepare to add it to the beginning of the next chunk
|
158
158
|
@leading = line
|
159
159
|
end
|
160
|
-
rescue ArgumentError
|
160
|
+
rescue ArgumentError
|
161
161
|
build_errors(:invalid_encoding, :structure, @current_line, nil, @current_line) unless @reported_invalid_encoding
|
162
162
|
@current_line += 1
|
163
163
|
@reported_invalid_encoding = true
|
@@ -165,13 +165,12 @@ module Csvlint
|
|
165
165
|
|
166
166
|
def validate_line(input = nil, index = nil)
|
167
167
|
@input = input
|
168
|
-
single_col = false
|
169
168
|
line = index.present? ? index : 0
|
170
169
|
@encoding = input.encoding.to_s
|
171
170
|
report_line_breaks(line)
|
172
171
|
parse_contents(input, line)
|
173
172
|
@lambda&.call(self)
|
174
|
-
rescue ArgumentError
|
173
|
+
rescue ArgumentError
|
175
174
|
build_errors(:invalid_encoding, :structure, @current_line, nil, index) unless @reported_invalid_encoding
|
176
175
|
@reported_invalid_encoding = true
|
177
176
|
end
|
@@ -205,7 +204,7 @@ module Csvlint
|
|
205
204
|
if @schema
|
206
205
|
@schema.validate_row(row, current_line, all_errors, @source, @validate)
|
207
206
|
@errors += @schema.errors
|
208
|
-
|
207
|
+
@schema.errors
|
209
208
|
@warnings += @schema.warnings
|
210
209
|
elsif !row.empty? && row.size != @expected_columns
|
211
210
|
build_errors(:ragged_rows, :structure, current_line, nil, stream.to_s)
|
@@ -277,7 +276,6 @@ module Csvlint
|
|
277
276
|
if schema.tables[@source_url]
|
278
277
|
@schema = schema
|
279
278
|
else
|
280
|
-
warn_if_unsuccessful = true
|
281
279
|
build_warnings(:schema_mismatch, :context, nil, nil, @source_url, schema)
|
282
280
|
end
|
283
281
|
end
|
data/lib/csvlint/version.rb
CHANGED
data/lib/csvlint.rb
CHANGED
data/spec/validator_spec.rb
CHANGED
@@ -573,14 +573,14 @@ describe Csvlint::Validator do
|
|
573
573
|
it "should call a lambda for each line" do
|
574
574
|
@count = 0
|
575
575
|
mylambda = lambda { |row| @count += 1 }
|
576
|
-
|
576
|
+
Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
|
577
577
|
expect(@count).to eq(3)
|
578
578
|
end
|
579
579
|
|
580
580
|
it "reports back the status of each line" do
|
581
581
|
@results = []
|
582
582
|
mylambda = lambda { |row| @results << row.current_line }
|
583
|
-
|
583
|
+
Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
|
584
584
|
expect(@results.count).to eq(3)
|
585
585
|
expect(@results[0]).to eq(1)
|
586
586
|
expect(@results[1]).to eq(2)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csvlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pezholio
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: csv
|
@@ -164,6 +163,20 @@ dependencies:
|
|
164
163
|
- - ">="
|
165
164
|
- !ruby/object:Gem::Version
|
166
165
|
version: '0'
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: mutex_m
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
type: :runtime
|
174
|
+
prerelease: false
|
175
|
+
version_requirements: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
167
180
|
- !ruby/object:Gem::Dependency
|
168
181
|
name: bundler
|
169
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -305,7 +318,7 @@ dependencies:
|
|
305
318
|
- !ruby/object:Gem::Version
|
306
319
|
version: '0'
|
307
320
|
- !ruby/object:Gem::Dependency
|
308
|
-
name:
|
321
|
+
name: coveralls_reborn
|
309
322
|
requirement: !ruby/object:Gem::Requirement
|
310
323
|
requirements:
|
311
324
|
- - ">="
|
@@ -388,20 +401,6 @@ dependencies:
|
|
388
401
|
- - ">="
|
389
402
|
- !ruby/object:Gem::Version
|
390
403
|
version: '0'
|
391
|
-
- !ruby/object:Gem::Dependency
|
392
|
-
name: henry
|
393
|
-
requirement: !ruby/object:Gem::Requirement
|
394
|
-
requirements:
|
395
|
-
- - ">="
|
396
|
-
- !ruby/object:Gem::Version
|
397
|
-
version: '0'
|
398
|
-
type: :development
|
399
|
-
prerelease: false
|
400
|
-
version_requirements: !ruby/object:Gem::Requirement
|
401
|
-
requirements:
|
402
|
-
- - ">="
|
403
|
-
- !ruby/object:Gem::Version
|
404
|
-
version: '0'
|
405
404
|
- !ruby/object:Gem::Dependency
|
406
405
|
name: standardrb
|
407
406
|
requirement: !ruby/object:Gem::Requirement
|
@@ -508,6 +507,7 @@ files:
|
|
508
507
|
- gemfiles/activesupport_6.1.gemfile
|
509
508
|
- gemfiles/activesupport_7.0.gemfile
|
510
509
|
- gemfiles/activesupport_7.1.gemfile
|
510
|
+
- gemfiles/activesupport_7.2.gemfile
|
511
511
|
- lib/csvlint.rb
|
512
512
|
- lib/csvlint/cli.rb
|
513
513
|
- lib/csvlint/csvw/column.rb
|
@@ -536,7 +536,6 @@ homepage: https://github.com/theodi/csvlint.rb
|
|
536
536
|
licenses:
|
537
537
|
- MIT
|
538
538
|
metadata: {}
|
539
|
-
post_install_message:
|
540
539
|
rdoc_options: []
|
541
540
|
require_paths:
|
542
541
|
- lib
|
@@ -547,15 +546,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
547
546
|
version: '2.5'
|
548
547
|
- - "<"
|
549
548
|
- !ruby/object:Gem::Version
|
550
|
-
version: '3.
|
549
|
+
version: '3.5'
|
551
550
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
552
551
|
requirements:
|
553
552
|
- - ">="
|
554
553
|
- !ruby/object:Gem::Version
|
555
554
|
version: '0'
|
556
555
|
requirements: []
|
557
|
-
rubygems_version: 3.
|
558
|
-
signing_key:
|
556
|
+
rubygems_version: 3.6.2
|
559
557
|
specification_version: 4
|
560
558
|
summary: CSV Validator
|
561
559
|
test_files: []
|