2010-07-28 19:30:56 +00:00
|
|
|
namespace :metrics do
|
|
|
|
task :lines do
|
|
|
|
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
2010-08-17 01:21:17 +00:00
|
|
|
for file_name in FileList['lib/**/*.rb']
|
2010-07-28 19:30:56 +00:00
|
|
|
f = File.open(file_name)
|
|
|
|
while line = f.gets
|
|
|
|
lines += 1
|
|
|
|
next if line =~ /^\s*$/
|
|
|
|
next if line =~ /^\s*#/
|
|
|
|
codelines += 1
|
|
|
|
end
|
2010-08-17 01:21:17 +00:00
|
|
|
puts "L: #{sprintf('%4d', lines)}, " +
|
|
|
|
"LOC #{sprintf('%4d', codelines)} | #{file_name}"
|
2010-07-28 19:30:56 +00:00
|
|
|
total_lines += lines
|
|
|
|
total_codelines += codelines
|
|
|
|
|
|
|
|
lines, codelines = 0, 0
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
|
|
|
|
end
|
|
|
|
end
|