To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 96 / 963773853bda74793bf9bb1d78dc3aeab16e404f.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (712 Bytes)
| 1 |
autoload :YAML, 'yaml' |
|---|---|
| 2 |
|
| 3 |
module CodeRay |
| 4 |
module Encoders |
| 5 |
|
| 6 |
# = YAML Encoder |
| 7 |
# |
| 8 |
# Slow. |
| 9 |
class YAML < Encoder |
| 10 |
|
| 11 |
register_for :yaml |
| 12 |
|
| 13 |
FILE_EXTENSION = 'yaml' |
| 14 |
|
| 15 |
protected |
| 16 |
def setup options |
| 17 |
super |
| 18 |
|
| 19 |
@data = [] |
| 20 |
end |
| 21 |
|
| 22 |
def finish options |
| 23 |
output ::YAML.dump(@data) |
| 24 |
end |
| 25 |
|
| 26 |
public |
| 27 |
def text_token text, kind |
| 28 |
@data << [text, kind] |
| 29 |
end |
| 30 |
|
| 31 |
def begin_group kind |
| 32 |
@data << [:begin_group, kind] |
| 33 |
end |
| 34 |
|
| 35 |
def end_group kind |
| 36 |
@data << [:end_group, kind] |
| 37 |
end |
| 38 |
|
| 39 |
def begin_line kind |
| 40 |
@data << [:begin_line, kind] |
| 41 |
end |
| 42 |
|
| 43 |
def end_line kind |
| 44 |
@data << [:end_line, kind] |
| 45 |
end |
| 46 |
|
| 47 |
end |
| 48 |
|
| 49 |
end |
| 50 |
end |