Sha256: 4b664a041a06b13f0a3da83574c41767a00b6c69699cc52b622d8a1b0e74eb17

Contents?: true

Size: 1.11 KB

Versions: 94

Compression:

Stored size: 1.11 KB

Contents

desc 'Show some stats about the code'
task :stats do
  line_count = proc do |path|
    Dir[path].collect { |f| File.open(f).readlines.reject { |l| l =~ /(^\s*(\#|\/\*))|^\s*$/ }.size }.inject(0){ |sum,n| sum += n }
  end
  comment_count = proc do |path|
    Dir[path].collect { |f| File.open(f).readlines.select { |l| l =~ /^\s*\#/ }.size }.inject(0) { |sum,n| sum += n }
  end
  lib     = line_count['lib/**/*.rb']
  comment = comment_count['lib/**/*.rb']
  ext     = line_count['ext/**/*.{c,h}'] 
  spec    = line_count['spec/**/*.rb']
  
  comment_ratio = '%1.2f' % (comment.to_f / lib.to_f)
  spec_ratio = '%1.2f' % (spec.to_f / lib.to_f)
  
  puts '/======================\\'
  puts '| Part            LOC  |'
  puts '|======================|'
  puts "| lib             #{lib.to_s.ljust(5)}|"
  puts "| lib comments    #{comment.to_s.ljust(5)}|"
  puts "| ext             #{ext.to_s.ljust(5)}|"
  puts "| spec            #{spec.to_s.ljust(5)}|"
  puts '| ratios:              |'
  puts "|   lib/comment   #{comment_ratio.to_s.ljust(5)}|"
  puts "|   lib/spec      #{spec_ratio.to_s.ljust(5)}|"
  puts '\======================/'
end

Version data entries

94 entries across 94 versions & 7 rubygems

Version Path
classiccms-0.5.17 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.16 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.15 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.14 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.13 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.12 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.11 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.10 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.9 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.8 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.7 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.6 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.5 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.2 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.1 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.5.0 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.4.2 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.4.1 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.4.0 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake
classiccms-0.3.9 vendor/bundle/gems/thin-1.3.1/tasks/stats.rake