diff options
-rw-r--r-- | lib/psych.rb | 1 | ||||
-rw-r--r-- | lib/psych/handler.rb | 63 | ||||
-rw-r--r-- | lib/psych/parser.rb | 2 | ||||
-rw-r--r-- | lib/psych/parser/handler.rb | 65 | ||||
-rw-r--r-- | test/psych/test_parser.rb | 4 |
5 files changed, 66 insertions, 69 deletions
diff --git a/lib/psych.rb b/lib/psych.rb index 0151e9f..9d136d5 100644 --- a/lib/psych.rb +++ b/lib/psych.rb @@ -1,3 +1,4 @@ +require 'psych/handler' require 'psych/parser' require 'psych/psych' diff --git a/lib/psych/handler.rb b/lib/psych/handler.rb new file mode 100644 index 0000000..5324174 --- /dev/null +++ b/lib/psych/handler.rb @@ -0,0 +1,63 @@ +module Psych + ### + # Default event handlers used in conjunction with Psych::Parser + class Handler + ### + # Called with +encoding+ when the YAML stream starts. + def start_stream encoding + end + + ### + # 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 + + ### + # Called with the document ends. + def end_document implicit = true + end + + ### + # Called when an alias is found to +anchor+ + def alias anchor + end + + ### + # Called when a scalar +value+ is found. The scalar may have an + # +anchor+, a +tag+, be implicitly +plain+ or implicitly +quoted+ + def scalar value, anchor = nil, tag = nil, plain = true, quoted = true, style = ANY_SCALAR_STYLE + end + + ### + # Called when a sequence is started. + 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 a map starts + def start_mapping anchor = nil, tag = nil, implicit = true, style = BLOCK_MAPPING_STYLE + end + + ### + # Called when a map ends + def end_mapping + end + + ### + # Called when an empty event happens. (Which, as far as I can tell, is + # never). + def empty + end + + ### + # Called when the YAML stream ends + def end_stream + end + end +end diff --git a/lib/psych/parser.rb b/lib/psych/parser.rb index 736521f..a59c435 100644 --- a/lib/psych/parser.rb +++ b/lib/psych/parser.rb @@ -1,5 +1,3 @@ -require 'psych/parser/handler' - module Psych ### # YAML parser class. diff --git a/lib/psych/parser/handler.rb b/lib/psych/parser/handler.rb deleted file mode 100644 index 8bfdb1a..0000000 --- a/lib/psych/parser/handler.rb +++ /dev/null @@ -1,65 +0,0 @@ -module Psych - class Parser - ### - # Default event handlers used in conjunction with Psych::Parser - class Handler - ### - # Called with +encoding+ when the YAML stream starts. - def start_stream encoding - end - - ### - # 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 - - ### - # Called with the document ends. - def end_document implicit = true - end - - ### - # Called when an alias is found to +anchor+ - def alias anchor - end - - ### - # Called when a scalar +value+ is found. The scalar may have an - # +anchor+, a +tag+, be implicitly +plain+ or implicitly +quoted+ - def scalar value, anchor = nil, tag = nil, plain = true, quoted = true, style = ANY_SCALAR_STYLE - end - - ### - # Called when a sequence is started. - 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 a map starts - def start_mapping anchor = nil, tag = nil, implicit = true, style = BLOCK_MAPPING_STYLE - end - - ### - # Called when a map ends - def end_mapping - end - - ### - # Called when an empty event happens. (Which, as far as I can tell, is - # never). - def empty - end - - ### - # Called when the YAML stream ends - def end_stream - end - end - end -end diff --git a/test/psych/test_parser.rb b/test/psych/test_parser.rb index 48fa9f2..3bbd280 100644 --- a/test/psych/test_parser.rb +++ b/test/psych/test_parser.rb @@ -2,13 +2,13 @@ require 'helper' module Psych class TestParser < Test::Unit::TestCase - class EventCatcher < Parser::Handler + class EventCatcher < Handler attr_reader :calls def initialize @calls = [] end - (Parser::Handler.instance_methods(true) - + (Handler.instance_methods(true) - Object.instance_methods).each do |m| class_eval %{ def #{m} *args |