From e01fc9ede64a82bcd1fc60ba5aba6c02e892e2f6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 27 Sep 2009 15:20:14 -0700 Subject: end_sequence supported --- ext/psych/parser.c | 3 +++ lib/psych/parser/handler.rb | 5 +++++ test/psych/test_parser.rb | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/ext/psych/parser.c b/ext/psych/parser.c index 4c4ccbb..9ba5f16 100644 --- a/ext/psych/parser.c +++ b/ext/psych/parser.c @@ -118,6 +118,9 @@ static VALUE parse_string(VALUE self, VALUE string) anchor, tag, implicit, style); } break; + case YAML_SEQUENCE_END_EVENT: + rb_funcall(handler, rb_intern("end_sequence"), 0); + break; case YAML_STREAM_END_EVENT: rb_funcall(handler, rb_intern("end_stream"), 0); done = 1; diff --git a/lib/psych/parser/handler.rb b/lib/psych/parser/handler.rb index b2706c1..4c87fff 100644 --- a/lib/psych/parser/handler.rb +++ b/lib/psych/parser/handler.rb @@ -35,6 +35,11 @@ module Psych def start_sequence anchor = nil, tag = nil, implicit = true, style = BLOCK_SEQUENCE_STYLE end + ### + # Called when a sequence ends. + def end_sequence + end + ### # Called when the YAML stream ends def end_stream diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 4ad7b6a..61c2510 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -24,6 +24,11 @@ module Psych @parser = Psych::Parser.new EventCatcher.new end + def test_sequence_end + @parser.parse("---\n&A [1, 2]") + assert_called :end_sequence + end + def test_sequence_start_anchor @parser.parse("---\n&A [1, 2]") assert_called :start_sequence, ["A", true, FLOW_SEQUENCE_STYLE] -- cgit v1.2.3