!2 fix build error for ruby3
From: @wk333 Reviewed-by: @small_leek Signed-off-by: @small_leek
This commit is contained in:
commit
8fee4a165d
71
fix-build-error-for-ruby3.patch
Normal file
71
fix-build-error-for-ruby3.patch
Normal file
@ -0,0 +1,71 @@
|
||||
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
|
||||
|
||||
@ -3,14 +3,16 @@
|
||||
Summary: Really simple JSON and XML parsing, ripped from Merb and Rails
|
||||
Name: rubygem-%{gem_name}
|
||||
Version: 0.4.2
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: MIT
|
||||
URL: http://github.com/jnunemaker/crack
|
||||
Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem
|
||||
Patch0: fix-build-error-for-ruby3.patch
|
||||
# ruby package has just soft dependency on rubygem(bigdecimal), while
|
||||
# crack always requires it.
|
||||
Requires: rubygem(bigdecimal)
|
||||
BuildRequires: rubygems-devel rubygem(bigdecimal) rubygem(minitest) rubygem(safe_yaml)
|
||||
BuildRequires: rubygem-rexml
|
||||
BuildArch: noarch
|
||||
#BZ 781829
|
||||
Epoch: 1
|
||||
@ -29,6 +31,9 @@ This package contains documentation for %{name}.
|
||||
%prep
|
||||
%setup -q -c -T
|
||||
%gem_install -n %{SOURCE0}
|
||||
pushd .%{gem_instdir}
|
||||
%patch0 -p1
|
||||
popd
|
||||
|
||||
%build
|
||||
|
||||
@ -64,5 +69,8 @@ popd
|
||||
%{gem_instdir}/test
|
||||
|
||||
%changelog
|
||||
* Tue Feb 22 2022 wangkai <wangkai385@huawei.com> - 0.4.2-2
|
||||
- fix build error for ruby3
|
||||
|
||||
* Mon Jul 27 2020 wangxiao <wangxiao65@huawei.com> - 0.4.2-1
|
||||
- package init
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user