提交 d78a7026 编写于 作者: S Sergey Parizhskiy

improved code stats calculation, check on multiline comments and rewrite...

improved code stats calculation, check on multiline comments and rewrite regexps according to a class naming convention
上级 a93ee92d
......@@ -38,11 +38,22 @@ def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
next unless file_name =~ pattern
f = File.open(directory + "/" + file_name)
comment_started = false
while line = f.gets
stats["lines"] += 1
stats["classes"] += 1 if line =~ /class [A-Z]/
stats["methods"] += 1 if line =~ /def [a-z]/
if(comment_started)
if line =~ /^=end/
comment_started = false
end
next
else
if line =~ /^=begin/
comment_started = true
next
end
end
stats["classes"] += 1 if line =~ /^\s*class\s+[_A-Z]/
stats["methods"] += 1 if line =~ /^\s*def\s+[_a-z]/
stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册