Skip to content

Commit

Permalink
Merge pull request #41 from arempe93/support-ruby-3.1
Browse files Browse the repository at this point in the history
Adds support for ruby 3.1.0 by fixing YAML
  • Loading branch information
le0pard authored Jan 7, 2022
2 parents d49083c + dee255b commit f506f59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/global/backend/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ def get_config_by_key(config, key)
end

def load_yml_file(file)
YAML.safe_load(
ERB.new(IO.read(file)).result,
[Date, Time, DateTime, Symbol].concat(@yaml_whitelist_classes),
[], true
)
file_contents = ERB.new(IO.read(file)).result
permitted_classes = [Date, Time, DateTime, Symbol].concat(@yaml_whitelist_classes)

if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4')
YAML.safe_load(file_contents, permitted_classes: permitted_classes, aliases: true)
else
YAML.safe_load(file_contents, permitted_classes, [], true)
end
end

def load_from_directory(path)
Expand Down

0 comments on commit f506f59

Please sign in to comment.