johannes
johannes

Reputation: 7272

How do I get the ruby YAML implementation to not read beyond the YAML EOF(...)

In the YAML specification it says ... is the EOF If I do:

YAML.load_documents("--- abc\n--- 42\n...\nerror") { |d| puts d }

I should get

abc
42

But I get

abc
42
error

Unfortenely there is not much documentation about the YAML parses. Do I have to tell the parses to honor the EOF, or does the parser not comply to the specs?

Upvotes: 0

Views: 394

Answers (1)

tadman
tadman

Reputation: 211610

It would seem that according to the YAML spec (http://yaml.org/spec/current.html) that the ... only indicates the end of the current document, not the end of the file.

While the specification suggests that the only valid content beyond an end of document marker is either comments or another document, the Ruby YAML parser appears to take a rather relaxed approach and allow ... to simply split documents.

Upvotes: 2

Related Questions