joakimkarlsson / changefreq

Creates statistics on how often files are changed in a software development project

This URL has Read+Write access

changefreq / changefreq
100755 43 lines (30 sloc) 0.884 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env ruby -wKU
 
require 'rubygems'
require 'commandline'
require 'lib/svn_log_parser'
require 'lib/histogram'
 
class ChangeStats < CommandLine::Application
  def initialize
    synopsis "[--filter <filter>] logfile"
    options :help
    option :names => "--filter", :opt_found => get_args,
     :opt_description => "Filter for what files to include (e.g. *.cpp;*.h)",
     :arg_description => "filter", :opt_not_found => ""
    expected_args :logfile
  end
  
  def main
    log = SvnLogParser.new
    log.filter = opt.filter
    log.parse(File.open(@logfile))
    
    histogram = Histogram.new(log)
    
    f = histogram.frequencies
    f.each do |freq|
      print "#{freq.name}\t"
    end
    
    puts
     
    f = histogram.frequencies
    f.each do |freq|
      print "#{freq.count}\t"
    end
  end
end