!5 [sync] PR-3: update to 2.9.0

From: @openeuler-sync-bot 
Reviewed-by: @shinwell_hu 
Signed-off-by: @shinwell_hu
This commit is contained in:
openeuler-ci-bot 2022-03-30 08:37:38 +00:00 committed by Gitee
commit a7f3c3540d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,85 @@
From 454d69729ffbde221117992a805f70d3a39b5ba4 Mon Sep 17 00:00:00 2001
From: r7kamura <r7kamura@gmail.com>
Date: Tue, 29 Oct 2019 13:26:47 +0900
Subject: [PATCH] Fix warnings on Ruby 2.7
> warning: Capturing the given block using Proc.new is deprecated; use `&block` instead
This patch converts `Proc.new` calls into `&block`.
---
lib/jbuilder.rb | 16 ++++++++--------
lib/jbuilder/jbuilder_template.rb | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/jbuilder.rb b/lib/jbuilder.rb
index f062a00..086d5ac 100644
--- a/lib/jbuilder.rb
+++ b/lib/jbuilder.rb
@@ -26,12 +26,12 @@ def self.encode(*args, &block)
BLANK = Blank.new
NON_ENUMERABLES = [ ::Struct, ::OpenStruct ].to_set
- def set!(key, value = BLANK, *args)
+ def set!(key, value = BLANK, *args, &block)
result = if ::Kernel.block_given?
if !_blank?(value)
# json.comments @post.comments { |comment| ... }
# { "comments": [ { ... }, { ... } ] }
- _scope{ array! value, &::Proc.new }
+ _scope{ array! value, &block }
else
# json.comments { ... }
# { "comments": ... }
@@ -61,9 +61,9 @@ def set!(key, value = BLANK, *args)
_set_value key, result
end
- def method_missing(*args)
+ def method_missing(*args, &block)
if ::Kernel.block_given?
- set!(*args, &::Proc.new)
+ set!(*args, &block)
else
set!(*args)
end
@@ -181,11 +181,11 @@ def child!
# json.array! [1, 2, 3]
#
# [1,2,3]
- def array!(collection = [], *attributes)
+ def array!(collection = [], *attributes, &block)
array = if collection.nil?
[]
elsif ::Kernel.block_given?
- _map_collection(collection, &::Proc.new)
+ _map_collection(collection, &block)
elsif attributes.any?
_map_collection(collection) { |element| extract! element, *attributes }
else
@@ -220,9 +220,9 @@ def extract!(object, *attributes)
end
end
- def call(object, *attributes)
+ def call(object, *attributes, &block)
if ::Kernel.block_given?
- array! object, &::Proc.new
+ array! object, &block
else
extract! object, *attributes
end
diff --git a/lib/jbuilder/jbuilder_template.rb b/lib/jbuilder/jbuilder_template.rb
index 685922e..4162310 100644
--- a/lib/jbuilder/jbuilder_template.rb
+++ b/lib/jbuilder/jbuilder_template.rb
@@ -73,8 +73,8 @@ def cache_root!(key=nil, options={})
# json.cache_if! !admin?, @person, expires_in: 10.minutes do
# json.extract! @person, :name, :age
# end
- def cache_if!(condition, *args)
- condition ? cache!(*args, &::Proc.new) : yield
+ def cache_if!(condition, *args, &block)
+ condition ? cache!(*args, &block) : yield
end
def target!

Binary file not shown.

BIN
jbuilder-2.9.0.gem Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
diff -Nur a/test/jbuilder_template_test.rb b/test/jbuilder_template_test.rb
--- a/test/jbuilder_template_test.rb 2022-03-01 17:35:46.095179949 +0800
+++ b/test/jbuilder_template_test.rb 2022-03-01 17:35:24.366810725 +0800
@@ -290,7 +290,7 @@
def render_without_parsing(source, assigns = {})
view = build_view(fixtures: PARTIALS.merge("source.json.jbuilder" => source), assigns: assigns)
- view.render(template: "source.json.jbuilder")
+ view.render(template: "source")
end
def build_view(options = {})

View File

@ -1,11 +1,13 @@
%global gem_name jbuilder
Name: rubygem-%{gem_name}
Version: 2.7.0
Version: 2.9.0
Release: 1
Summary: Create JSON structures via a Builder-style DSL
License: MIT
URL: https://github.com/rails/jbuilder
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
Patch1: rubygem-jbuilder-2.9.0-Fixes-the-test-suite-in-Rails-6-1.patch
Patch2: Fix-warnings-on-Ruby-2.7.patch
BuildRequires: ruby(release) rubygems-devel ruby rubygem(activemodel) rubygem(multi_json)
BuildRequires: rubygem(mocha) rubygem(railties)
BuildArch: noarch
@ -25,6 +27,10 @@ Documentation for %{name}.
%prep
%setup -q -c -T
%gem_install -n %{SOURCE0}
pushd .%{gem_instdir}
%patch1 -p1
%patch2 -p1
popd
%build
@ -60,5 +66,8 @@ popd
%{gem_instdir}/Appraisals
%changelog
* Thur Mar 3 2022 liqiuyu <liqiuyu@kylinos.cn> - 2.9.0-1
- update to 2.9.0
* Wed Aug 19 2020 tuShenmei <tushenmei@huawei.com> - 2.7.0-1
- package init