!9 [sync] PR-8: fix build error with ruby3.2

From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
This commit is contained in:
openeuler-ci-bot 2023-08-14 03:04:30 +00:00 committed by Gitee
commit 4950049996
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From 693641fee8d1970abeded5dc59e22b745cfaf269 Mon Sep 17 00:00:00 2001
From: Yusuke Nakamura <yusuke1994525@gmail.com>
Date: Fri, 10 Jan 2020 01:06:06 +0900
Subject: [PATCH] Suppress deprecated warning by Object#=~ since ruby 2.6
In `Temple::Mixins::GrammerDSL::Value#Rule`, call `=~` method to
`Class` class then that causes a warning message.
This behavior introduced from ruby 2.6 with `-W` option.
(And ruby 2.7 always show a warning message)
- https://bugs.ruby-lang.org/issues/15231
- https://github.com/ruby/ruby/commit/ebff9dc10
Therefore use case-when-else clause to avoid warning.
---
lib/temple/mixins/grammar_dsl.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/temple/mixins/grammar_dsl.rb b/lib/temple/mixins/grammar_dsl.rb
index 0f154f5..d02aa9c 100644
--- a/lib/temple/mixins/grammar_dsl.rb
+++ b/lib/temple/mixins/grammar_dsl.rb
@@ -143,7 +143,8 @@ def Rule(rule)
start = Or.new(self)
curr = [start]
rule.each do |elem|
- if elem =~ /^(.*)(\*|\?|\+)$/
+ case elem
+ when /^(.*)(\*|\?|\+)$/
elem = Element.new(self, const_get($1))
curr.each {|c| c << elem }
elem << elem if $2 != '?'

View File

@ -1,12 +1,13 @@
%global gem_name temple %global gem_name temple
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 0.8.0 Version: 0.8.0
Release: 2 Release: 3
Summary: Template compilation framework in Ruby Summary: Template compilation framework in Ruby
License: MIT License: MIT
URL: https://github.com/judofyr/temple URL: https://github.com/judofyr/temple
Source0: https://rubygems.org/gems/temple-%{version}.gem Source0: https://rubygems.org/gems/temple-%{version}.gem
Patch0: rubygem-temple-0.8.2-Use-Erubi-instead-of-Erubis.patch Patch0: rubygem-temple-0.8.2-Use-Erubi-instead-of-Erubis.patch
Patch1: rubygem-temple-0.8.0-object-regexp-removal-ruby32.patch
BuildRequires: ruby(release) rubygems-devel ruby rubygem-bacon rubygem(erubi) rubygem(tilt) BuildRequires: ruby(release) rubygems-devel ruby rubygem-bacon rubygem(erubi) rubygem(tilt)
BuildArch: noarch BuildArch: noarch
%description %description
@ -29,6 +30,7 @@ Documentation for %{name}.
%setup -q -n %{gem_name}-%{version} %setup -q -n %{gem_name}-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1
%build %build
gem build ../%{gem_name}-%{version}.gemspec gem build ../%{gem_name}-%{version}.gemspec
@ -64,6 +66,9 @@ popd
%{gem_instdir}/test %{gem_instdir}/test
%changelog %changelog
* Mon Aug 14 2023 liyanan <thistleslyn@163.com> - 0.8.0-3
- fix build error with ruby3.2
* Tue Jan 10 liyanan <liyanan32@h-partners.com> - 0.8.0-2 * Tue Jan 10 liyanan <liyanan32@h-partners.com> - 0.8.0-2
- Use Erubi instead of Erubis - Use Erubi instead of Erubis