Sha256: dc7516370e7fac5bd0f95bf15a5c92b659aaa3c29da5790f720e700d4aee0828

Contents?: true

Size: 607 Bytes

Versions: 3

Compression:

Stored size: 607 Bytes

Contents

namespace :metrics do
  task :lines do
    lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
    for file_name in FileList["lib/**/*.rb"]
      f = File.open(file_name)
      while line = f.gets
        lines += 1
        next if line =~ /^\s*$/
        next if line =~ /^\s*#/
        codelines += 1
      end
      puts "L: #{sprintf("%4d", lines)}, " +
        "LOC #{sprintf("%4d", codelines)} | #{file_name}"
      total_lines     += lines
      total_codelines += codelines
    
      lines, codelines = 0, 0
    end

    puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
instrument-0.1.0 tasks/metrics.rake
instrument-0.1.1 tasks/metrics.rake
instrument-0.1.2 tasks/metrics.rake