ruby-changes:22905
From: tenderlove <ko1@a...>
Date: Fri, 9 Mar 2012 06:31:45 +0900 (JST)
Subject: [ruby-changes:22905] tenderlove:r34954 (trunk): * ext/psych/lib/psych.rb (load, parse): stop parsing or loading after
tenderlove 2012-03-09 06:31:05 +0900 (Fri, 09 Mar 2012) New Revision: 34954 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34954 Log: * 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. Modified files: trunk/ChangeLog trunk/ext/psych/lib/psych.rb trunk/test/psych/test_stream.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34953) +++ ChangeLog (revision 34954) @@ -1,3 +1,10 @@ +Fri Mar 9 06:29:22 2012 Aaron Patterson <aaron@t...> + + * 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@t...> * ext/psych/lib/psych.rb (parse_stream, load_stream): if a block is Index: ext/psych/lib/psych.rb =================================================================== --- ext/psych/lib/psych.rb (revision 34953) +++ ext/psych/lib/psych.rb (revision 34954) @@ -148,8 +148,10 @@ # # See Psych::Nodes for more information about YAML AST. def self.parse yaml, filename = nil - children = parse_stream(yaml, filename).children - children.empty? ? false : children.first.children.first + parse_stream(yaml, filename) do |node| + return node + end + false end ### Index: test/psych/test_stream.rb =================================================================== --- test/psych/test_stream.rb (revision 34953) +++ test/psych/test_stream.rb (revision 34954) @@ -2,6 +2,16 @@ module Psych 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 list = [] Psych.parse_stream("--- foo\n...\n--- bar") do |doc| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/