Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moving handler

  • Loading branch information...
commit 1e1b03f061be4333e2d2a8a4b2b176bcab20a023 1 parent 46ffb85
@tenderlove authored
View
1  lib/psych.rb
@@ -1,3 +1,4 @@
+require 'psych/handler'
require 'psych/parser'
require 'psych/psych'
View
63 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
View
2  lib/psych/parser.rb
@@ -1,5 +1,3 @@
-require 'psych/parser/handler'
-
module Psych
###
# YAML parser class.
View
65 lib/psych/parser/handler.rb
@@ -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
View
4 test/psych/test_parser.rb
@@ -2,13 +2,13 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.