update to 0.4.5

This commit is contained in:
liqiuyu 2022-03-03 15:27:07 +08:00
parent 8fee4a165d
commit dc42ded5b0
5 changed files with 18 additions and 94 deletions

Binary file not shown.

BIN
crack-0.4.5-tests.tar.gz Normal file

Binary file not shown.

BIN
crack-0.4.5.gem Normal file

Binary file not shown.

View File

@ -1,71 +0,0 @@
From 42709c7a30f1e09a32085e3b09820b88c8aa9963 Mon Sep 17 00:00:00 2001
From: wk333 <13474090681@163.com>
Date: Thu, 17 Feb 2022 17:54:57 +0800
Subject: fix build error for ruby3
Origin: https://github.com/jnunemaker/crack/commit/579acb39c5597b5a4353181a5cf967c148625275
Origin: https://github.com/jnunemaker/crack/commit/a7189fef728ce522cb03f62b18848cfc50058245
---
crack.gemspec | 2 +-
lib/crack/json.rb | 23 +++++------------------
2 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/crack.gemspec b/crack.gemspec
index 2225c16..5ab19dd 100644
--- a/crack.gemspec
+++ b/crack.gemspec
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
gem.version = Crack::VERSION
gem.license = "MIT"
- gem.add_dependency "safe_yaml", "~> 1.0.0"
+ gem.add_runtime_dependency("rexml")
end
diff --git a/lib/crack/json.rb b/lib/crack/json.rb
index 7bb890c..39bc620 100644
--- a/lib/crack/json.rb
+++ b/lib/crack/json.rb
@@ -3,34 +3,21 @@
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-require 'safe_yaml/load'
require 'strscan'
module Crack
class JSON
def self.parser_exceptions
- @parser_exceptions ||= begin
- exceptions = [ArgumentError]
-
- if const_defined?(:Psych)
- if Psych.const_defined?(:SyntaxError)
- exceptions << Psych::SyntaxError
- end
- end
-
- exceptions
- end
+ @parser_exceptions ||= [ArgumentError, Psych::SyntaxError]
end
def self.parse(json)
- args = [unescape(convert_json_to_yaml(json))]
- args << nil if SafeYAML::MULTI_ARGUMENT_YAML_LOAD
- args << { :whitelisted_tags => ['!ruby/regexp'] }
-
- SafeYAML.load(*args)
-
+ yaml = unescape(convert_json_to_yaml(json))
+ YAML.safe_load(yaml, [Regexp, Date, Time])
rescue *parser_exceptions
raise ParseError, "Invalid JSON string"
+ rescue Psych::DisallowedClass
+ yaml
end
protected
--
2.27.0

View File

@ -2,16 +2,16 @@
Summary: Really simple JSON and XML parsing, ripped from Merb and Rails Summary: Really simple JSON and XML parsing, ripped from Merb and Rails
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 0.4.2 Version: 0.4.5
Release: 2 Release: 1
License: MIT License: MIT
URL: http://github.com/jnunemaker/crack URL: https://github.com/jnunemaker/crack
Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
Patch0: fix-build-error-for-ruby3.patch Source1: crack-%{version}-tests.tar.gz
# ruby package has just soft dependency on rubygem(bigdecimal), while # ruby package has just soft dependency on rubygem(bigdecimal), while
# crack always requires it. # crack always requires it.
Requires: rubygem(bigdecimal) Requires: rubygem(bigdecimal)
BuildRequires: rubygems-devel rubygem(bigdecimal) rubygem(minitest) rubygem(safe_yaml) BuildRequires: rubygems-devel rubygem(bigdecimal) rubygem(minitest)
BuildRequires: rubygem-rexml BuildRequires: rubygem-rexml
BuildArch: noarch BuildArch: noarch
#BZ 781829 #BZ 781829
@ -24,51 +24,46 @@ Really simple JSON and XML parsing, ripped from Merb and Rails.
Summary: Documentation for %{name} Summary: Documentation for %{name}
Requires: %{name} = %{epoch}:%{version}-%{release} Requires: %{name} = %{epoch}:%{version}-%{release}
BuildArch: noarch
%description doc %description doc
This package contains documentation for %{name}. This package contains documentation for %{name}.
%prep %prep
%setup -q -c -T %setup -q -n %{gem_name}-%{version} -b 1
%gem_install -n %{SOURCE0}
pushd .%{gem_instdir}
%patch0 -p1
popd
%build %build
# Create the gem as gem install only works on a gem file
gem build ../%{gem_name}-%{version}.gemspec
# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
# by default, so that we can move it into the buildroot in %%install
%gem_install
%install %install
mkdir -p %{buildroot}%{gem_dir} mkdir -p %{buildroot}%{gem_dir}
cp -a .%{gem_dir}/* \ cp -a .%{gem_dir}/* \
%{buildroot}%{gem_dir}/ %{buildroot}%{gem_dir}/
# Fix non-standard-executable-perm rpmlint warning.
chmod a+x %{buildroot}%{gem_instdir}/script/*
%check %check
pushd .%{gem_instdir} pushd .%{gem_instdir}
ln -s %{_builddir}/test test
ruby -Ilib:test -e 'Dir.glob "./test/**/*_test.rb", &method(:require)' ruby -Ilib:test -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'
popd popd
%files %files
%dir %{gem_instdir} %dir %{gem_instdir}
%exclude %{gem_instdir}/.*
%doc %{gem_instdir}/LICENSE
%doc %{gem_instdir}/README.md
%doc %{gem_instdir}/History
%{gem_libdir} %{gem_libdir}
%exclude %{gem_cache} %exclude %{gem_cache}
%{gem_spec} %{gem_spec}
%files doc %files doc
%doc %{gem_docdir} %doc %{gem_docdir}
%{gem_instdir}/Gemfile
%{gem_instdir}/crack.gemspec
%{gem_instdir}/script
%{gem_instdir}/test
%changelog %changelog
* Thur Mar 3 2022 liqiuyu <liqiuyu@kylinos.cn> - 0.4.5-1
- update to 0.4.5
* Tue Feb 22 2022 wangkai <wangkai385@huawei.com> - 0.4.2-2 * Tue Feb 22 2022 wangkai <wangkai385@huawei.com> - 0.4.2-2
- fix build error for ruby3 - fix build error for ruby3