Date: Friday, August 6, 2021 @ 08:47:42 Author: bastelfreak Revision: 994104
add ruby-json-schema Added: ruby-json-schema/ ruby-json-schema/repos/ ruby-json-schema/trunk/ ruby-json-schema/trunk/PKGBUILD ruby-json-schema/trunk/disable_tests_with_external_fixtures.patch ruby-json-schema/trunk/fix-broken-ruby26-and-newer-tests.patch --------------------------------------------+ PKGBUILD | 68 ++++++++++++++++ disable_tests_with_external_fixtures.patch | 112 +++++++++++++++++++++++++++ fix-broken-ruby26-and-newer-tests.patch | 15 +++ 3 files changed, 195 insertions(+) Added: ruby-json-schema/trunk/PKGBUILD =================================================================== --- ruby-json-schema/trunk/PKGBUILD (rev 0) +++ ruby-json-schema/trunk/PKGBUILD 2021-08-06 08:47:42 UTC (rev 994104) @@ -0,0 +1,68 @@ +# Maintainer: Tim Meusel <[email protected]> +# Contributor: Christian Rebischke <[email protected]> +# Contributor: Roberto Valentini <valantin89 [at] gmail [dot] com> + +_gemname='json-schema' +pkgname="ruby-${_gemname}" +pkgver=2.8.1 +pkgrel=4 +pkgdesc='Interface for validating JSON objects against a JSON schema conforming to JSON Schema Draft 4.' +arch=('any') +url='https://github.com/ruby-json-schema/json-schema' +license=('MIT') +makedepends=('ruby-rdoc' 'ruby-bundler') +checkdepends=('ruby-rake' 'ruby-minitest' 'ruby-test-unit' 'ruby-webmock') +depends=('ruby' 'ruby-addressable') +options=(!emptydirs) +source=("${url}/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz" + 'fix-broken-ruby26-and-newer-tests.patch' + 'disable_tests_with_external_fixtures.patch') +sha512sums=('4634fb46e0cf7cbe74def73bcdd1f8bbdf50430477cd5a2bba47c79a17f63b582d68c9064b5aec70c17b0e73db5032ddffb0a036d2f6e34ff571880b325f297b' + 'cd2e2fc621edb7e49855eebeaddb098b0c3fbea817201e36b9f2d43df38306f790c2ebc2cc19092bc3084b8a3b1a69e2271f6497845f6defc410082a91971dcc' + '3fd3d48fcc3e5a8356ac6b5839ec5db3495468071a19902550280ebecbb0e3bdd205fe2aa5ba41841dd08999a9bac5364b153c15f60e12a6af422a802816de4f') + +prepare() { + cd "${srcdir}/${_gemname}-${pkgver}" + + # remove simplecov. It's listed as a dependency, but not actually used/required + # sed --in-place '/simplecov/d' Gemfile + + # replace upper version boundaries for ruby gems + sed --in-place 's|~>|>=|g' "${_gemname}.gemspec" + + # the output of the ipaddr lib changed. + # This patch adjusts the expected output to match ruby2.6 and newer + # this is based on https://github.com/ruby-json-schema/json-schema/pull/437 + patch --forward --verbose --strip=1 --input=../fix-broken-ruby26-and-newer-tests.patch + + # disable tests that try to download fixtures from dead upstream websites + patch --forward --verbose --strip=1 --input=../disable_tests_with_external_fixtures.patch + + # tests from this file fail because they try to download fixtures from http://json-schema.org/address + # but that source is dead + #rm test/schema_reader_test.rb + #rm test/validator_schema_reader_test.rb +} + +build() { + cd "${srcdir}/${_gemname}-${pkgver}" + gem build "${_gemname}.gemspec" +} + +check() { + cd "${srcdir}/${_gemname}-${pkgver}" + rake test +} + +package() { + cd "${srcdir}/${_gemname}-${pkgver}" + local _gemdir="$(gem env gemdir)" + gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem" + + install -Dm 644 LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}/" + install -Dm 644 CHANGELOG.md CONTRIBUTING.md CONTRIBUTORS.md README.md -t "${pkgdir}/usr/share/doc/${pkgname}" + + rm -rf "${pkgdir}/${_gemdir}/cache" +} + +# vim: ts=2 sw=2 et: Added: ruby-json-schema/trunk/disable_tests_with_external_fixtures.patch =================================================================== --- ruby-json-schema/trunk/disable_tests_with_external_fixtures.patch (rev 0) +++ ruby-json-schema/trunk/disable_tests_with_external_fixtures.patch 2021-08-06 08:47:42 UTC (rev 994104) @@ -0,0 +1,112 @@ +diff --git a/test/bad_schema_ref_test.rb b/test/bad_schema_ref_test.rb +index 2c44555..24babe2 100644 +--- a/test/bad_schema_ref_test.rb ++++ b/test/bad_schema_ref_test.rb +@@ -29,21 +29,4 @@ class BadSchemaRefTest < Minitest::Test + assert_equal(expanded_path, error.location) + assert_equal("Read of file at #{expanded_path} failed", error.message) + end +- +- def test_bad_host_ref +- schema = { +- "$schema" => "http://json-schema.org/draft-04/schema#", +- "type" => "array", +- "items" => { "$ref" => "http://ppcheesecheseunicornnuuuurrrrr.example.invalid/json.schema"} +- } +- +- data = [1,2,3] +- error = assert_raises(JSON::Schema::ReadFailed) do +- JSON::Validator.validate(schema,data) +- end +- +- assert_equal(:uri, error.type) +- assert_equal("http://ppcheesecheseunicornnuuuurrrrr.example.invalid/json.schema", error.location) +- assert_equal("Read of URI at http://ppcheesecheseunicornnuuuurrrrr.example.invalid/json.schema failed", error.message) +- end + end +diff --git a/test/initialize_data_test.rb b/test/initialize_data_test.rb +index cf08cbe..4dcb65b 100644 +--- a/test/initialize_data_test.rb ++++ b/test/initialize_data_test.rb +@@ -71,46 +71,6 @@ class InitializeDataTest < Minitest::Test + assert_raises(JSON::Schema::JsonLoadError) { JSON::Validator.validate(schema, data, :uri => true) } + end + +- def test_parse_valid_uri_string +- schema = {'type' => 'string'} +- data = 'http://foo.bar/' +- +- stub_request(:get, "foo.bar").to_return(:body => '"hello world"', :status => 200) +- +- assert(JSON::Validator.validate(schema, data)) +- +- assert(JSON::Validator.validate(schema, data, :parse_data => false)) +- +- assert_raises(JSON::Schema::JsonParseError) do +- JSON::Validator.validate(schema, data, :json => true) +- end +- +- assert(JSON::Validator.validate(schema, data, :uri => true)) +- end +- +- def test_parse_invalid_uri_string +- schema = {'type' => 'string'} +- data = 'http://foo.bar/' +- +- stub_request(:get, "foo.bar").to_timeout +- +- assert(JSON::Validator.validate(schema, data)) +- +- assert(JSON::Validator.validate(schema, data, :parse_data => false)) +- +- stub_request(:get, "foo.bar").to_return(:status => [500, "Internal Server Error"]) +- +- assert(JSON::Validator.validate(schema, data)) +- +- assert(JSON::Validator.validate(schema, data, :parse_data => false)) +- +- assert_raises(JSON::Schema::JsonParseError) do +- JSON::Validator.validate(schema, data, :json => true) +- end +- +- assert_raises(JSON::Schema::JsonLoadError) { JSON::Validator.validate(schema, data, :uri => true) } +- end +- + def test_parse_invalid_scheme_string + schema = {'type' => 'string'} + data = 'pick one: [1, 2, 3]' +diff --git a/test/schema_reader_test.rb b/test/schema_reader_test.rb +index 746df75..2c9e867 100644 +--- a/test/schema_reader_test.rb ++++ b/test/schema_reader_test.rb +@@ -9,15 +9,6 @@ class SchemaReaderTest < Minitest::Test + to_return(:body => body, :status => 200) + end + +- def test_accept_all_uris +- stub_address_request +- +- reader = JSON::Schema::Reader.new +- schema = reader.read(ADDRESS_SCHEMA_URI) +- +- assert_equal schema.uri, Addressable::URI.parse("#{ADDRESS_SCHEMA_URI}#") +- end +- + def test_accept_all_files + reader = JSON::Schema::Reader.new + schema = reader.read(ADDRESS_SCHEMA_PATH) +@@ -65,14 +56,4 @@ class SchemaReaderTest < Minitest::Test + assert_equal(ADDRESS_SCHEMA_PATH, error.location) + assert_equal("Read of file at #{ADDRESS_SCHEMA_PATH} refused", error.message) + end +- +- def test_parse_error +- stub_address_request('this is totally not valid JSON!') +- +- reader = JSON::Schema::Reader.new +- +- assert_raises(JSON::Schema::JsonParseError) do +- reader.read(ADDRESS_SCHEMA_URI) +- end +- end + end Added: ruby-json-schema/trunk/fix-broken-ruby26-and-newer-tests.patch =================================================================== --- ruby-json-schema/trunk/fix-broken-ruby26-and-newer-tests.patch (rev 0) +++ ruby-json-schema/trunk/fix-broken-ruby26-and-newer-tests.patch 2021-08-06 08:47:42 UTC (rev 994104) @@ -0,0 +1,15 @@ +diff --git a/lib/json-schema/attributes/formats/ip.rb b/lib/json-schema/attributes/formats/ip.rb +index 04b2e3a..172132d 100644 +--- a/lib/json-schema/attributes/formats/ip.rb ++++ b/lib/json-schema/attributes/formats/ip.rb +@@ -10,8 +10,8 @@ module JSON + + begin + ip = IPAddr.new(data) +- rescue ArgumentError => e +- raise e unless e.message == 'invalid address' ++ rescue => e ++ raise e unless e.message.start_with?("invalid address") + end + + family = ip_version == 6 ? Socket::AF_INET6 : Socket::AF_INET
