summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-05-21 11:37:26 -0700
committerGitHub <noreply@github.com>2021-05-21 11:37:26 -0700
commit38e4b5115f170ae7d79debfc9219331a6d52babe (patch)
treee36e381b93d39b240c35620696e1e52f8bd117fa
parent3fabcb953f04b4c4927b419d6d91026f65e984af (diff)
parentf8a5e512a1856231bf10c80e8a08714b06fb95c4 (diff)
downloadpsych-38e4b5115f170ae7d79debfc9219331a6d52babe.zip
Merge pull request #493 from mame/load_file-should-use-load-instead-of-safe_load
Make YAML.load_file use YAML.load instead of safe_load
-rw-r--r--lib/psych.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index 7c6b8d0..6205061 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -575,7 +575,6 @@ module Psych
self.unsafe_load f, filename: filename, **kwargs
}
end
- class << self; alias :load_file :unsafe_load_file; end
###
# Safely loads the document contained in +filename+. Returns the yaml contained in
@@ -587,7 +586,17 @@ module Psych
self.safe_load f, filename: filename, **kwargs
}
end
- class << self; alias load_file safe_load_file end
+
+ ###
+ # Loads the document contained in +filename+. Returns the yaml contained in
+ # +filename+ as a Ruby object, or if the file is empty, it returns
+ # the specified +fallback+ return value, which defaults to +false+.
+ # See load for options.
+ def self.load_file filename, **kwargs
+ File.open(filename, 'r:bom|utf-8') { |f|
+ self.load f, filename: filename, **kwargs
+ }
+ end
# :stopdoc:
def self.add_domain_type domain, type_tag, &block