diff options
author | murphy <murphy@rubychan.de> | 2009-06-29 23:18:44 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-06-29 23:18:44 +0000 |
commit | 35ba94fe6ba3fa9aa9dce364521417b7cbbb7b94 (patch) | |
tree | beee68c9bdf278ed907457b6f30d95ee1e31f099 /lib/coderay/encoders/lines_of_code.rb | |
parent | 00966d3cd17d5c9f07990d3e9628767ac5a867b6 (diff) | |
download | coderay-35ba94fe6ba3fa9aa9dce364521417b7cbbb7b94.tar.gz |
Added LinesOfCode encoder (issue #123) - simple version.
Diffstat (limited to 'lib/coderay/encoders/lines_of_code.rb')
-rw-r--r-- | lib/coderay/encoders/lines_of_code.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/coderay/encoders/lines_of_code.rb b/lib/coderay/encoders/lines_of_code.rb new file mode 100644 index 0000000..8ffe9dc --- /dev/null +++ b/lib/coderay/encoders/lines_of_code.rb @@ -0,0 +1,19 @@ +module CodeRay +module Encoders + + class LinesOfCode < Encoder + + register_for :lines_of_code + + def compile tokens, options + @loc = tokens.token_class_filter(:exclude => [:comment, :doctype]).text.scan(/^\s*\S.*$/).size + end + + def finish options + @loc + end + + end + +end +end |