* ext/psych/lib/psych.rb (load, parse): stop parsing or loading after
the first document has been parsed. * test/psych/test_stream.rb: pertinent tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a2e3de1b3f
commit
240c9acb5c
@ -1,3 +1,10 @@
|
|||||||
|
Fri Mar 9 06:29:22 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* ext/psych/lib/psych.rb (load, parse): stop parsing or loading after
|
||||||
|
the first document has been parsed.
|
||||||
|
|
||||||
|
* test/psych/test_stream.rb: pertinent tests.
|
||||||
|
|
||||||
Fri Mar 9 06:17:05 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
Fri Mar 9 06:17:05 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* ext/psych/lib/psych.rb (parse_stream, load_stream): if a block is
|
* ext/psych/lib/psych.rb (parse_stream, load_stream): if a block is
|
||||||
|
@ -148,8 +148,10 @@ module Psych
|
|||||||
#
|
#
|
||||||
# See Psych::Nodes for more information about YAML AST.
|
# See Psych::Nodes for more information about YAML AST.
|
||||||
def self.parse yaml, filename = nil
|
def self.parse yaml, filename = nil
|
||||||
children = parse_stream(yaml, filename).children
|
parse_stream(yaml, filename) do |node|
|
||||||
children.empty? ? false : children.first.children.first
|
return node
|
||||||
|
end
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -2,6 +2,16 @@ require 'psych/helper'
|
|||||||
|
|
||||||
module Psych
|
module Psych
|
||||||
class TestStream < TestCase
|
class TestStream < TestCase
|
||||||
|
def test_parse_partial
|
||||||
|
rb = Psych.parse("--- foo\n...\n--- `").to_ruby
|
||||||
|
assert_equal 'foo', rb
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_load_partial
|
||||||
|
rb = Psych.load("--- foo\n...\n--- `")
|
||||||
|
assert_equal 'foo', rb
|
||||||
|
end
|
||||||
|
|
||||||
def test_parse_stream_yields_documents
|
def test_parse_stream_yields_documents
|
||||||
list = []
|
list = []
|
||||||
Psych.parse_stream("--- foo\n...\n--- bar") do |doc|
|
Psych.parse_stream("--- foo\n...\n--- bar") do |doc|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user