File webkit2gtk3-old-ruby.patch of Package webkit2gtk3.23795

From 2604facca3b721514c99b3af0f71dbb404a1339d Mon Sep 17 00:00:00 2001
From: "angelos@igalia.com"
 <angelos@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue, 22 Feb 2022 20:59:23 +0000
Subject: [PATCH] Ruby ERB.new compatibility fix
 https://bugs.webkit.org/show_bug.cgi?id=237035

Reviewed by Fujii Hironori.

ERB.new has changed its calling convention in newer ruby versions.
This was exposed by https://commits.webkit.org/247450@main, which
tried to silence the warning emitted by newer ruby versions.
Unfortunately, this resulted in failures with older ruby versions
(e.g.
https://build.webkit.org/#/builders/46/builds/11387/steps/8/logs/stdio).

Use the compatibility hack suggested by RuboCop to get this working
across ruby versions (without any warnings).

* Scripts/GeneratePreferences.rb:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@290331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
---
 Source/WTF/ChangeLog                      | 19 +++++++++++++++++++
 Source/WTF/Scripts/GeneratePreferences.rb | 13 ++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/Source/WTF/Scripts/GeneratePreferences.rb b/Source/WTF/Scripts/GeneratePreferences.rb
index de0f2268b178..ee603d9e5670 100644
--- a/Source/WTF/Scripts/GeneratePreferences.rb
+++ b/Source/WTF/Scripts/GeneratePreferences.rb
@@ -228,11 +228,22 @@ class Preferences
     result
   end
 
+  def createTemplate(templateString)
+    # Newer versions of ruby deprecate and/or drop passing non-keyword
+    # arguments for trim_mode and friends, so we need to call the constructor
+    # differently depending on what it expects. This solution is suggested by
+    # rubocop's Lint/ErbNewArguments.
+    if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
+      ERB.new(templateString, trim_mode:"-")
+    else
+      ERB.new(templateString, nil, "-")
+    end
+  end
   def renderTemplate(templateFile, outputDirectory)
     resultFile = File.join(outputDirectory, File.basename(templateFile, ".erb"))
     tempResultFile = resultFile + ".tmp"
 
-    output = ERB.new(File.read(templateFile), trim_mode:"-").result(binding)
+    output = createTemplate(File.read(templateFile)).result(binding)
     File.open(tempResultFile, "w+") do |f|
       f.write(output)
     end
-- 
2.35.1

openSUSE Build Service is sponsored by