module Psych
def self.parse_stream yaml, filename = nil, &block
end
ex.message # => "(file.txt): found character that cannot start any token"
ex.file # => 'file.txt'
rescue Psych::SyntaxError => ex
Psych.parse_stream("--- `", "file.txt")
begin
end
node # => #
Psych.parse_stream("--- a\n--- b") do |node|
Psych.parse_stream("---\n - a\n - b") # => #
Example:
Raises a Psych::SyntaxError when a YAML syntax error is detected.
block as it's being parsed.
If a block is given, a Psych::Nodes::Document node will be yielded to the
raised.
+filename+ is used in the exception message if a Psych::SyntaxError is
This method can handle multiple YAML documents contained in +yaml+.
Parse a YAML string in +yaml+. Returns the Psych::Nodes::Stream.
##
def self.parse_stream yaml, filename = nil, &block if block_given? parser = Psych::Parser.new(Handlers::DocumentStream.new(&block)) parser.parse yaml, filename else parser = self.parser parser.parse yaml, filename parser.handler.root end end