summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-09-10 15:12:11 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-25 13:11:33 +0900
commitb72f9200acf88e60c850a2d400554ff38f81194d (patch)
treea36d4a76d41c19dafeb06c89b16a72ac7db6db3e /ext
parent8ea1021f1979c04b3cee2a886fb52a914472dd16 (diff)
[ruby/psych] Forward keyword arguments in load_file and load_stream
https://github.com/ruby/psych/commit/4e1dd37f09
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/lib/psych.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 3fc98db6bb..b09866ad1e 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -549,7 +549,7 @@ module Psych
# end
# list # => ['foo', 'bar']
#
- def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: []
+ def self.load_stream yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: [], **kwargs
if legacy_filename != NOT_GIVEN
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load_stream is deprecated. Use keyword argument like Psych.load_stream(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
filename = legacy_filename
@@ -557,10 +557,10 @@ module Psych
result = if block_given?
parse_stream(yaml, filename: filename) do |node|
- yield node.to_ruby
+ yield node.to_ruby(**kwargs)
end
else
- parse_stream(yaml, filename: filename).children.map(&:to_ruby)
+ parse_stream(yaml, filename: filename).children.map { |node| node.to_ruby(**kwargs) }
end
return fallback if result.is_a?(Array) && result.empty?
@@ -571,9 +571,9 @@ module Psych
# Load 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+.
- def self.load_file filename, fallback: false
+ def self.load_file filename, **kwargs
File.open(filename, 'r:bom|utf-8') { |f|
- self.load f, filename: filename, fallback: fallback
+ self.load f, filename: filename, **kwargs
}
end