Skip to content

Commit

Permalink
Merge pull request #258 from koic/suppress_psych_safe_load_warnings
Browse files Browse the repository at this point in the history
Suppress deprecation warnings of `Psych.safe_load` args in Ruby 2.6
  • Loading branch information
winebarrel committed Oct 25, 2018
2 parents 9cdc806 + cb7d899 commit fb8a211
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bin/ridgepole
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ begin
else
File.open(diff_file)
end
elsif Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') # Ruby 2.6
YAML.safe_load(
diff_file,
whitelist_classes: [],
whitelist_symbols: [],
aliases: true
)
else
YAML.safe_load(diff_file, [], [], true)
end
Expand Down
19 changes: 18 additions & 1 deletion lib/ridgepole/cli/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ def load(config, env = 'development')
parse_config_file(config)
elsif (expanded = File.expand_path(config)) && File.exist?(expanded)
parse_config_file(expanded)
elsif Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') # Ruby 2.6
YAML.safe_load(
ERB.new(config).result,
whitelist_classes: [],
whitelist_symbols: [],
aliases: true
)
else
YAML.safe_load(ERB.new(config).result, [], [], true)
end
Expand All @@ -30,7 +37,17 @@ def load(config, env = 'development')

def parse_config_file(path)
yaml = ERB.new(File.read(path)).result
YAML.safe_load(yaml, [], [], true)

if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1') # Ruby 2.6
YAML.safe_load(
yaml,
whitelist_classes: [],
whitelist_symbols: [],
aliases: true
)
else
YAML.safe_load(yaml, [], [], true)
end
end

def parse_database_url(config)
Expand Down

0 comments on commit fb8a211

Please sign in to comment.