diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2021-12-28 15:20:23 -0800 |
---|---|---|
committer | Ryan Davis <ryand-ruby@zenspider.com> | 2021-12-28 15:20:23 -0800 |
commit | b61531a32688ef5e006a03be2ebef0919515bf81 (patch) | |
tree | b250aad985e5e525f14fc6bcfae317bbd7879780 /lib | |
parent | 7d2c140d5989129531d3972266d105a33b079502 (diff) | |
download | hoe-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]
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hoe.rb | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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 |