diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2011-08-19 03:09:35 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2011-08-19 03:09:35 +0200 |
commit | 75bc5455af8c3c3381066aac3d5fff42264cac6f (patch) | |
tree | 589d2c912ddd94c517eb794bcdf3257f8348f3c0 /lib/coderay/encoders/yaml.rb | |
parent | fdd17b6a09efb275238a3baef275465d31452f2a (diff) | |
download | coderay-75bc5455af8c3c3381066aac3d5fff42264cac6f.tar.gz |
Major rewrite of encoders to support IO output; fixed some minor scanner bugs; cleanups; dropped NitroXHTML scanner; improved tests
Diffstat (limited to 'lib/coderay/encoders/yaml.rb')
-rw-r--r-- | lib/coderay/encoders/yaml.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/coderay/encoders/yaml.rb b/lib/coderay/encoders/yaml.rb index c12f8d0..1eb2523 100644 --- a/lib/coderay/encoders/yaml.rb +++ b/lib/coderay/encoders/yaml.rb @@ -6,39 +6,44 @@ module Encoders # Slow. class YAML < Encoder + autoload :YAML, 'yaml' + register_for :yaml FILE_EXTENSION = 'yaml' protected def setup options - require 'yaml' - @out = [] + super + + @data = [] end def finish options - @out.to_a.to_yaml + YAML.dump @data, @out + + super end public def text_token text, kind - @out << [text, kind] + @data << [text, kind] end def begin_group kind - @out << [:begin_group, kind] + @data << [:begin_group, kind] end def end_group kind - @out << [:end_group, kind] + @data << [:end_group, kind] end def begin_line kind - @out << [:begin_line, kind] + @data << [:begin_line, kind] end def end_line kind - @out << [:end_line, kind] + @data << [:end_line, kind] end end |