diff options
author | Peter McLain <peter.mclain@gemstone.com> | 2010-03-29 15:52:31 -0700 |
---|---|---|
committer | Peter McLain <peter.mclain@gemstone.com> | 2010-03-29 15:52:31 -0700 |
commit | c5f84428d51d85cee7fffef90b21da162c5d2258 (patch) | |
tree | e8f3b308d6b2666780c1d1c73e5ea62666a73ab9 /lib/psych.rb | |
parent | e67d46d87b5911d8e1a5cebbd9cbf37cca7b0a0f (diff) | |
download | psych-c5f84428d51d85cee7fffef90b21da162c5d2258.zip |
Fix problem with empty and white-space only strings. Add test.
Diffstat (limited to 'lib/psych.rb')
-rw-r--r-- | lib/psych.rb | 6 |
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 ### |