From: Alberto Garcia Date: Fri, 8 Apr 2022 14:08:46 +0000 (+0100) Subject: Support building with ruby 2.5 X-Git-Tag: archive/raspbian/2.36.0-3_deb10u1+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=91dacd1abdd008e711e9a3178ab4effd96bfa501;p=webkit2gtk.git Support building with ruby 2.5 Origin: https://github.com/WebKit/WebKit/commit/ec527f042c3bc230a47b7c548bbbb1ac9bc1524f =================================================================== Gbp-Pq: Name support-ruby2.5.patch --- diff --git a/Source/WTF/Scripts/GeneratePreferences.rb b/Source/WTF/Scripts/GeneratePreferences.rb index de0f2268b1..ee603d9e56 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