From aa17b9942d6ca3d01e3f74513e0903a195c23b22 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 20 Apr 2011 19:49:53 +0000 Subject: Encoder refactoring to fix LOC and Statistic encoders --- lib/coderay/encoder.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/coderay/encoder.rb') diff --git a/lib/coderay/encoder.rb b/lib/coderay/encoder.rb index 3acb9c4..e495ca0 100644 --- a/lib/coderay/encoder.rb +++ b/lib/coderay/encoder.rb @@ -46,7 +46,7 @@ module CodeRay DEFAULT_OPTIONS = { } # The options you gave the Encoder at creating. - attr_accessor :options + attr_accessor :options, :scanner # Creates a new Encoder. # +options+ is saved and used for all encode operations, as long @@ -66,6 +66,7 @@ module CodeRay # Encode a Tokens object. def encode_tokens tokens, options = {} options = @options.merge options + @scanner = tokens.scanner if tokens.respond_to? :scanner setup options compile tokens, options finish options @@ -74,10 +75,9 @@ module CodeRay # Encode the given +code+ using the Scanner for +lang+. def encode code, lang, options = {} options = @options.merge options + @scanner = Scanners[lang].new code, CodeRay.get_scanner_options(options).update(:tokens => self) setup options - scanner_options = CodeRay.get_scanner_options options - scanner_options[:tokens] = self - CodeRay.scan code, lang, scanner_options + @scanner.tokenize finish options end -- cgit v1.2.1