From 850df20bf83d182703d075951bfb95fb4531748a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sat, 26 Sep 2009 21:42:03 -0700 Subject: start docuemnt flushed out --- ext/psych/parser.c | 6 ++++-- lib/psych/parser/handler.rb | 6 +++--- test/psych/test_parser.rb | 9 +++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ext/psych/parser.c b/ext/psych/parser.c index ef95056..a9b0667 100644 --- a/ext/psych/parser.c +++ b/ext/psych/parser.c @@ -54,8 +54,10 @@ static VALUE parse_string(VALUE self, VALUE string) rb_ary_push(tag_directives, pair); } } - rb_funcall(handler, rb_intern("start_document"), 2, - version, tag_directives); + rb_funcall(handler, rb_intern("start_document"), 3, + version, tag_directives, + event.data.document_start.implicit == 1 ? Qtrue : Qfalse + ); } break; case YAML_STREAM_END_EVENT: diff --git a/lib/psych/parser/handler.rb b/lib/psych/parser/handler.rb index a140b09..211ebf1 100644 --- a/lib/psych/parser/handler.rb +++ b/lib/psych/parser/handler.rb @@ -9,9 +9,9 @@ module Psych end ### - # Called when the document starts with the declared +version+ and - # +tag_directives+ - def start_document version = [], tag_directives = [] + # Called when the document starts with the declared +version+, + # +tag_directives+, if the document is +implicit+ + def start_document version = [], tag_directives = [], implicit = true end ### diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 4a12015..187bace 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -33,14 +33,19 @@ module Psych assert_called :start_stream end + def test_start_document_implicit + @parser.parse("\"foo\"\n") + assert_called :start_document, [[], [], true] + end + def test_start_document_version @parser.parse("%YAML 1.1\n---\n\"foo\"\n") - assert_called :start_document, [[1,1], []] + assert_called :start_document, [[1,1], [], false] end def test_start_document_tag @parser.parse("%TAG !yaml! tag:yaml.org,2002\n---\n!yaml!str \"foo\"\n") - assert_called :start_document, [[], [['!yaml!', 'tag:yaml.org,2002']]] + assert_called :start_document, [[], [['!yaml!', 'tag:yaml.org,2002']], false] end def assert_called call, with = nil, parser = @parser -- cgit v1.2.3