From 75bc5455af8c3c3381066aac3d5fff42264cac6f Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Fri, 19 Aug 2011 03:09:35 +0200 Subject: Major rewrite of encoders to support IO output; fixed some minor scanner bugs; cleanups; dropped NitroXHTML scanner; improved tests --- lib/coderay/encoders/yaml.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/coderay/encoders/yaml.rb') 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 -- cgit v1.2.1