DEV: Fix YAML load in new Ruby (#19500)

This commit is contained in:
Rafael dos Santos Silva 2022-12-16 17:07:18 -03:00 committed by GitHub
parent b80765f1f4
commit b8c1289c7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -8,7 +8,7 @@ class SiteSettings::YamlLoader
end
def load
yaml = YAML.load_file(@file)
yaml = load_yaml(@file)
yaml.each_key do |category|
yaml[category].each do |setting_name, hash|
if hash.is_a?(Hash)
@ -31,4 +31,14 @@ class SiteSettings::YamlLoader
end
end
end
private
def load_yaml(path)
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0')
YAML.load_file(path, aliases: true)
else
YAML.load_file(path)
end
end
end