From 031026146bc4e1f7c7c174fa5ff3a1df300895de Mon Sep 17 00:00:00 2001 From: Hans de Graaff Date: Thu, 28 Jul 2022 10:25:35 +0200 Subject: dev-ruby/crack: add ruby31, fix compatibility with psych 4 Add upstream pull request to fix compatibility with psych 4, thus allowing ruby31 to be added. Signed-off-by: Hans de Graaff --- dev-ruby/crack/crack-0.4.4-r2.ebuild | 42 +++++++++++++++++++++++++++ dev-ruby/crack/files/crack-0.4.4-psych4.patch | 30 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 dev-ruby/crack/crack-0.4.4-r2.ebuild create mode 100644 dev-ruby/crack/files/crack-0.4.4-psych4.patch diff --git a/dev-ruby/crack/crack-0.4.4-r2.ebuild b/dev-ruby/crack/crack-0.4.4-r2.ebuild new file mode 100644 index 000000000000..2610de8a296f --- /dev/null +++ b/dev-ruby/crack/crack-0.4.4-r2.ebuild @@ -0,0 +1,42 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +USE_RUBY="ruby27 ruby30 ruby31" + +RUBY_FAKEGEM_EXTRADOC="README.md History" + +RUBY_FAKEGEM_GEMSPEC="crack.gemspec" + +inherit ruby-fakegem + +DESCRIPTION="Really simple JSON and XML parsing, ripped from Merb and Rails" +HOMEPAGE="https://github.com/jnunemaker/crack" +SRC_URI="https://github.com/jnunemaker/crack/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +IUSE="" + +PATCHES=( "${FILESDIR}/${P}-psych4.patch" ) + +ruby_add_rdepend "dev-ruby/rexml" + +ruby_add_bdepend "test? ( dev-ruby/minitest )" + +all_ruby_prepare() { + sed -i -e 's/git ls-files --/find/' ${RUBY_FAKEGEM_GEMSPEC} || die +} + +each_ruby_prepare() { + # Remove tests which fail when run by portage but pass when run by hand + sed -i -e '/{"regex": \/foo.*\/}/d' test/json_test.rb || die + sed -i -e '/{"regex": \/foo.*\/i}/d' test/json_test.rb || die + sed -i -e '/{"regex": \/foo.*\/mix}/d' test/json_test.rb || die +} + +each_ruby_test() { + ${RUBY} -Itest -Ilib -e 'Dir["test/*_test.rb"].each { |f| load f }' || die +} diff --git a/dev-ruby/crack/files/crack-0.4.4-psych4.patch b/dev-ruby/crack/files/crack-0.4.4-psych4.patch new file mode 100644 index 000000000000..4c4e96661ba9 --- /dev/null +++ b/dev-ruby/crack/files/crack-0.4.4-psych4.patch @@ -0,0 +1,30 @@ +From 7fa8d8aea4a041969e433debef7f4d5d59881ae2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?V=C3=ADt=20Ondruch?= +Date: Fri, 11 Mar 2022 18:29:43 +0100 +Subject: [PATCH] Use named parameters for `safe_load`. + +This is available since Psych 3.1 [[1], [2]], but mandatory since Psych +4.0 [[3]]. + +Fixes #72 + +[1]: https://github.com/ruby/psych/pull/358 +[2]: https://github.com/ruby/psych/pull/378 +[3]: https://github.com/ruby/psych/commit/0767227051dbddf1f949eef512c174deabf22891 +--- + lib/crack/json.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/crack/json.rb b/lib/crack/json.rb +index 1a27ac7..528aad6 100644 +--- a/lib/crack/json.rb ++++ b/lib/crack/json.rb +@@ -13,7 +13,7 @@ def self.parser_exceptions + + def self.parse(json) + yaml = unescape(convert_json_to_yaml(json)) +- YAML.safe_load(yaml, [Regexp, Date, Time]) ++ YAML.safe_load(yaml, permitted_classes: [Regexp, Date, Time]) + rescue *parser_exceptions + raise ParseError, "Invalid JSON string" + rescue Psych::DisallowedClass -- cgit v1.2.3-65-gdbad