-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it a YAML Document? #49
Comments
I don't think there's a good way to do that without parsing the entire document. The problem is that documents can be implicitly started. That means the string irb(main):001:0> require 'psych'
=> true
irb(main):002:0> Psych.load 'foo'
=> "foo"
irb(main):003:0> You would essentially have to parse the entire string to make sure it was YAML. Say the We wouldn't want to test IO objects because it may not be possible to rewind the IO (possibly a socket or something). |
Good points. Technically I believe the YAML spec requires a document start with Anyhow, obviously not the most pressing feature. Just a convenience that I could have made use of a few times, so I thought I'd suggest it. |
Gotcha! :-) Unfortunately, the 1.1 spec says that YAML documents are not required to start with |
You're using 1.1, not 1.2? |
libyaml only supports 1.1 at this point, so ya, psych is only working with the 1.1 spec. Once libyaml gets an upgrade, we will too. |
Is there any way to detect if a file and/or string is YAML?
Maybe something like:
would be a good addition, if not.
The text was updated successfully, but these errors were encountered: