From d86ecaeaf9f6707927b7d7e9ba1d23b5f9996e68 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 28 Dec 2022 14:47:56 +0000 Subject: [PATCH 1/4] Add support for Ruby 3.2 --- .github/workflows/push.yml | 4 ++-- .ruby-version | 2 +- README.md | 12 ++++++------ csvlint.gemspec | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 343316e..deda384 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1'] + ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2'] fail-fast: false steps: - uses: actions/checkout@v3 @@ -28,7 +28,7 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: "3.1" + ruby-version: "3.2" - name: Install dependencies run: bundle install - name: Run the tests diff --git a/.ruby-version b/.ruby-version index ef538c2..944880f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.2.0 diff --git a/README.md b/README.md index b15a690..152b064 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,14 @@ A ruby gem to support validating CSV files to check their syntax and contents. Y ## Summary of features -* Validation that checks the structural formatting of a CSV file +* Validation that checks the structural formatting of a CSV file * Validation of a delimiter-separated values (dsv) file accesible via URL, File, or an IO-style object (e.g. StringIO) -* Validation against [CSV dialects](http://dataprotocols.org/csv-dialect/) -* Validation against multiple schema standards; [JSON Table Schema](https://github.com/theodi/csvlint.rb/blob/master/README.md#json-table-schema-support) and [CSV on the Web](https://github.com/theodi/csvlint.rb/blob/master/README.md#csv-on-the-web-validation-support) +* Validation against [CSV dialects](http://dataprotocols.org/csv-dialect/) +* Validation against multiple schema standards; [JSON Table Schema](https://github.com/theodi/csvlint.rb/blob/master/README.md#json-table-schema-support) and [CSV on the Web](https://github.com/theodi/csvlint.rb/blob/master/README.md#csv-on-the-web-validation-support) ## Development -`ruby version 3.1.2` +`ruby version 3.2` ### Tests @@ -71,7 +71,7 @@ After installing the gem, you can validate a CSV on the command line like so: csvlint myfile.csv -You may need to add the gem exectuable directory to your path, by adding '/usr/local/lib/ruby/gems/2.6.0/bin' +You may need to add the gem exectuable directory to your path, by adding '/usr/local/lib/ruby/gems/2.6.0/bin' or whatever your version is, to your .bash_profile PATH entry. [like so](https://stackoverflow.com/questions/2392293/ruby-gems-returns-command-not-found) You will then see the validation result, together with any warnings or errors e.g. @@ -213,7 +213,7 @@ An example JSON Table Schema schema file is: "name": "price", "constraints": { "required": true, - "minLength": 1 + "minLength": 1 } }, { diff --git a/csvlint.gemspec b/csvlint.gemspec index 518936d..da7ad2d 100644 --- a/csvlint.gemspec +++ b/csvlint.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = [">= 2.5", "< 3.2"] + spec.required_ruby_version = [">= 2.5", "< 4.0"] spec.add_dependency "rainbow" spec.add_dependency "open_uri_redirections" From b992fd29ecc23737a0edb39bd48c3e5652896f8e Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 28 Dec 2022 16:00:01 +0000 Subject: [PATCH 2/4] Don't try to use regexes unless values are strings --- lib/csvlint/csvw/property_checker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/csvlint/csvw/property_checker.rb b/lib/csvlint/csvw/property_checker.rb index d84c3c0..4fb95fc 100644 --- a/lib/csvlint/csvw/property_checker.rb +++ b/lib/csvlint/csvw/property_checker.rb @@ -38,7 +38,7 @@ def check_common_property_value(value, base_url, lang) when "@type" if value["@value"] && BUILT_IN_DATATYPES.include?(v) elsif !value["@value"] && BUILT_IN_TYPES.include?(v) - elsif v =~ /^([a-z]+):/ && NAMESPACES.include?(v.split(":")[0]) + elsif ((v.is_a? String) && (v =~ /^([a-z]+):/)) && NAMESPACES.include?(v.split(":")[0]) else # must be an absolute URI begin @@ -60,7 +60,7 @@ def check_common_property_value(value, base_url, lang) raise Csvlint::Csvw::MetadataError.new, "common property with @value has properties other than @language or @type" unless value.except("@type").except("@language").except("@value").empty? when "@language" raise Csvlint::Csvw::MetadataError.new, "common property with @language lacks a @value" unless value["@value"] - raise Csvlint::Csvw::MetadataError.new, "common property has invalid @language (#{v})" unless v =~ BCP47_LANGUAGE_REGEXP || v.nil? + raise Csvlint::Csvw::MetadataError.new, "common property has invalid @language (#{v})" unless ((v.is_a? String) && (v =~ BCP47_LANGUAGE_REGEXP)) || v.nil? else if p[0] == "@" raise Csvlint::Csvw::MetadataError.new, "common property has property other than @id, @type, @value or @language beginning with @ (#{p})" From 021b35514f0bde6bfe29af9ff73beade5674dab8 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 28 Dec 2022 16:03:33 +0000 Subject: [PATCH 3/4] Only support up to Ruby 3.3 We still get errors commonly on minor version releases, so it's a good idea to go one at a time. --- csvlint.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csvlint.gemspec b/csvlint.gemspec index da7ad2d..12ef898 100644 --- a/csvlint.gemspec +++ b/csvlint.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = [">= 2.5", "< 4.0"] + spec.required_ruby_version = [">= 2.5", "< 3.3"] spec.add_dependency "rainbow" spec.add_dependency "open_uri_redirections" From 62360aa3a471d09020e763c7c41273d676b3c148 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 28 Dec 2022 16:05:21 +0000 Subject: [PATCH 4/4] lint: remove redundant require for 'set' --- lib/csvlint.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/csvlint.rb b/lib/csvlint.rb index 0bb7932..a6df8f4 100644 --- a/lib/csvlint.rb +++ b/lib/csvlint.rb @@ -1,7 +1,6 @@ require "csv" require "date" require "open-uri" -require "set" require "tempfile" require "typhoeus"