summaryrefslogtreecommitdiffstats
path: root/tasks/stats.rake
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2009-02-28 21:19:37 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2009-02-28 21:19:37 +0100
commit0a8b6ea5dc6a9d56638b985dd67b0c45f167e381 (patch)
tree1932cb877c3e623f9a300c37971bb4e073670aea /tasks/stats.rake
parent50bb456cf469f73d3a32474dc07bd58c0c64dba1 (diff)
downloadmmap-ruby-0a8b6ea5dc6a9d56638b985dd67b0c45f167e381.zip
mmap-ruby-0a8b6ea5dc6a9d56638b985dd67b0c45f167e381.tar.gz
mmap goes rakeified, build and test OKHEADmaster
Diffstat (limited to 'tasks/stats.rake')
-rw-r--r--tasks/stats.rake25
1 files changed, 25 insertions, 0 deletions
diff --git a/tasks/stats.rake b/tasks/stats.rake
new file mode 100644
index 0000000..19ffd8e
--- /dev/null
+++ b/tasks/stats.rake
@@ -0,0 +1,25 @@
+
+desc 'lines and words count of real ruby code ( no empty lines or comments )'
+task :stats do
+ pattern = Regexp.new("^\s*(?:#.*)?$")
+# count_proc = Proc.new do |path|
+# Dir[path].collect { |f| File.open(f).readlines.reject { |l| l =~ pattern }.size }.inject(0) { |sum,n| sum+=n }
+# end
+ stat_proc = Proc.new do |files,name|
+ lines=0
+ words=0
+ files.each { |fn| open(fn){ |f| f.each{ |line|
+ begin
+ lines += 1
+ words += line.split(' ').size
+ end if not pattern.match(line)
+ } } }
+ puts "#{ format('%10s',name)} => #{format('%7d',lines)} code lines, #{format('%7d',words)} words."
+ end
+ stat_proc.call BIN_FILES, 'bin'
+ stat_proc.call LIB_FILES, 'lib'
+ stat_proc.call TEST_FILES, 'test'
+ stat_proc.call EXT_FILES, 'ext'
+
+end
+