# Yaml.rb and YAML "%" directives

**URL:** <https://www.ruby-forum.com/t/yaml-rb-and-yaml-directives/82627>\
**Category:** Ruby\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/yaml-rb-and-yaml-directives/82627 "2007-01-19T16:31:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Choi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@Joshua\_Choi](https://www.ruby-forum.com/u/Joshua_Choi)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/yaml-rb-and-yaml-directives/82627/1 "2007-01-19T16:31:49Z")

</div>

I’m new to Ruby, and it really is fun. Right now, I’m playing with  
YAML…

…but one part of yaml.rb doesn’t seem to work–it doesn’t seem to  
recognize any % directives  
([http://yaml.org/spec/current.html#id2523453](http://yaml.org/spec/current.html#id2523453)) like “%YAML 1.1” or  
“%TAG ! tag:blah.com,2007:”.

Why might it not be working?

I’m using Ubuntu Dapper, Ruby v1.8.4. The versions of yaml and syck  
I’m using are the ones that came with Ruby/Ubuntu.

Thanks in advance,  
Joshua Choi

(My test case is from the YAML 1.1 spec:

%TAG ! tag:clarkevans.com,2002:  
— !shape

# Use the ! handle for presenting

# tag:clarkevans.com,2002:circle

- !circle  
center: &ORIGIN {x: 73, y: 129}  
radius: 7
- !line  
start: \*ORIGIN  
finish: { x: 89, y: 102 }
- !label  
start: \*ORIGIN  
color: 0xFFEEBB  
text: Pretty vector drawing.

And if I do this:  
require ‘yaml’  
dump = YAML.load(…what’s above…)  
puts dump.to\_yaml

## …it prints:

“%TAG ! tag:clarkevans.com,2002”:

Apparently, it’s interpreting the top line as a string instead of a  
directive; the rest of the document was cut off by the top “—”.

It works if the top line isn’t there or is below the “—”, and it  
doesn’t work if there’s any line starting with “%” above “—” ; if  
it’s below “—”, it gets interpreted as a string.)

---

<div class="post-metadata">

**Author:** ![Joshua\_Choi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@Joshua\_Choi](https://www.ruby-forum.com/u/Joshua_Choi)\
**Post date:** [September 25, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/yaml-rb-and-yaml-directives/82627/2 "2007-09-25T22:47:59Z")

</div>

On Sun, Jan 14, 2007 at 11:29:20AM +0900, Joshua Choi wrote:

> I’m new to Ruby, and it really is fun. Right now, I’m playing with YAML…
> 
> …but one part of yaml.rb doesn’t seem to work–it doesn’t seem to  
> recognize any % directives  
> ([http://yaml.org/spec/current.html#id2523453](http://yaml.org/spec/current.html#id2523453)) like “%YAML 1.1” or  
> “%TAG ! tag:blah.com,2007:”.
> 
> Why might it not be working?

Okay, so, the reason is: Ruby’s builtin YAML library only does YAML  
1.0 documents. I’m afraid I haven’t worked on 1.1 support yet. So  
try the “Last Call” spec. If you’re having a hard time with  
anything else, please send me word!

\_why
