summaryrefslogtreecommitdiff
path: root/lib/psych.rb
diff options
context:
space:
mode:
authorPeter McLain <peter.mclain@gemstone.com>2010-03-29 15:52:31 -0700
committerPeter McLain <peter.mclain@gemstone.com>2010-03-29 15:52:31 -0700
commitc5f84428d51d85cee7fffef90b21da162c5d2258 (patch)
treee8f3b308d6b2666780c1d1c73e5ea62666a73ab9 /lib/psych.rb
parente67d46d87b5911d8e1a5cebbd9cbf37cca7b0a0f (diff)
downloadpsych-c5f84428d51d85cee7fffef90b21da162c5d2258.zip
Fix problem with empty and white-space only strings. Add test.
Diffstat (limited to 'lib/psych.rb')
-rw-r--r--lib/psych.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index 574bc7e..c142593 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -101,7 +101,8 @@ module Psych
# Psych.load("--- a") # => 'a'
# Psych.load("---\n - a\n - b") # => ['a', 'b']
def self.load yaml
- parse(yaml).to_ruby
+ result = parse(yaml)
+ result ? result.to_ruby : result
end
###
@@ -113,7 +114,8 @@ module Psych
#
# See Psych::Nodes for more information about YAML AST.
def self.parse yaml
- parse_stream(yaml).children.first.children.first
+ children = parse_stream(yaml).children
+ children.empty? ? false : children.first.children.first
end
###