lib/hoe.rb in hoe-3.23.0 vs lib/hoe.rb in hoe-3.23.1

- old
+ new

@@ -85,11 +85,11 @@ class Hoe include Rake::DSL if defined?(Rake::DSL) # duh - VERSION = "3.23.0" + VERSION = "3.23.1" @@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package, :publish, :gemcutter, :signing, :test] @bad_plugins = [] @@ -902,21 +902,31 @@ def with_config 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 # Like File::read, but strips out a BOM marker if it exists.