Skip to content

Commit

Permalink
Merge pull request #342 from stomar/fallback-keyword
Browse files Browse the repository at this point in the history
Convert fallback option to a keyword argument
  • Loading branch information
hsbt authored Dec 19, 2017
2 parents 6333cf8 + 5db58be commit e90ccea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/psych.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ module Psych
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
#
def self.load yaml, filename = nil, fallback = false, symbolize_names: false
result = parse(yaml, filename, fallback)
def self.load yaml, filename = nil, fallback: false, symbolize_names: false
result = parse(yaml, filename, fallback: fallback)
result = result.to_ruby if result
symbolize_names!(result) if symbolize_names
result
Expand Down Expand Up @@ -346,7 +346,7 @@ def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases
# end
#
# See Psych::Nodes for more information about YAML AST.
def self.parse yaml, filename = nil, fallback = false
def self.parse yaml, filename = nil, fallback: false
parse_stream(yaml, filename) do |node|
return node
end
Expand Down Expand Up @@ -493,9 +493,9 @@ def self.load_stream yaml, filename = nil
# 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 default return value, which defaults to an empty Hash
def self.load_file filename, fallback = false
def self.load_file filename, fallback: false
File.open(filename, 'r:bom|utf-8') { |f|
self.load f, filename, FALLBACK.new(fallback)
self.load f, filename, fallback: FALLBACK.new(fallback)
}
end

Expand Down
2 changes: 1 addition & 1 deletion test/psych/test_psych.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def test_load_file

def test_load_file_with_fallback
Tempfile.create(['empty', 'yml']) {|t|
assert_equal Hash.new, Psych.load_file(t.path, Hash.new)
assert_equal Hash.new, Psych.load_file(t.path, fallback: Hash.new)
}
end

Expand Down

0 comments on commit e90ccea

Please sign in to comment.