From 35ba94fe6ba3fa9aa9dce364521417b7cbbb7b94 Mon Sep 17 00:00:00 2001 From: murphy Date: Mon, 29 Jun 2009 23:18:44 +0000 Subject: Added LinesOfCode encoder (issue #123) - simple version. --- lib/coderay/encoders/lines_of_code.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/coderay/encoders/lines_of_code.rb (limited to 'lib/coderay/encoders/lines_of_code.rb') 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 -- cgit v1.2.1