diff options
author | murphy <murphy@rubychan.de> | 2011-04-20 19:49:53 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-04-20 19:49:53 +0000 |
commit | aa17b9942d6ca3d01e3f74513e0903a195c23b22 (patch) | |
tree | eeee0ac8f13199d726f9eeb8f4ad7194773f0d36 /lib/coderay/encoder.rb | |
parent | 763948b33279a418b17f09f110e8cab0035a0734 (diff) | |
download | coderay-aa17b9942d6ca3d01e3f74513e0903a195c23b22.tar.gz |
Encoder refactoring to fix LOC and Statistic encoders
Diffstat (limited to 'lib/coderay/encoder.rb')
-rw-r--r-- | lib/coderay/encoder.rb | 8 |
1 files changed, 4 insertions, 4 deletions
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 |