summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Davis <ryand-ruby@zenspider.com>2021-12-28 15:20:23 -0800
committerRyan Davis <ryand-ruby@zenspider.com>2021-12-28 15:20:23 -0800
commitb61531a32688ef5e006a03be2ebef0919515bf81 (patch)
treeb250aad985e5e525f14fc6bcfae317bbd7879780
parent7d2c140d5989129531d3972266d105a33b079502 (diff)
downloadhoe-b61531a32688ef5e006a03be2ebef0919515bf81.tar.gz
- Fixed loading config files for ruby 3.1's now default YAML.safe_load_file.
[git-p4: depot-paths = "//src/hoe/dev/": change = 13295]
-rw-r--r--lib/hoe.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/hoe.rb b/lib/hoe.rb
index f0e6af1..26c187c 100644
--- a/lib/hoe.rb
+++ b/lib/hoe.rb
@@ -904,19 +904,29 @@ class Hoe
config = Hoe::DEFAULT_CONFIG
rc = File.expand_path("~/.hoerc")
- exists = File.exist? rc
- homeconfig = exists ? YAML.load_file(rc) : {}
+ homeconfig = maybe_load_yaml rc
config = config.merge homeconfig
localrc = File.join Dir.pwd, ".hoerc"
- exists = File.exist? localrc
- localconfig = exists ? YAML.load_file(localrc) : {}
+ localconfig = maybe_load_yaml(localrc)
config = config.merge localconfig
yield config, rc
end
+
+ def maybe_load_yaml path
+ if File.exist? path then
+ if YAML.respond_to? :safe_load_file then
+ YAML.safe_load_file path, permitted_classes: [Regexp, Symbol]
+ else
+ YAML.load_file path
+ end
+ else
+ {}
+ end
+ end
end
class File