class StatGen
Attributes
commitcache[RW]
date_stats[R]
debug[RW]
file_stats[R]
filetype_stats[R]
future[RW]
general_stats[R]
hour_stats[R]
include_mail[RW]
lastweeks_stats[R]
maxage[RW]
month_stats[R]
num_commits[R]
quiet[RW]
repos[R]
verbose[RW]
wday_stats[R]
year_stats[R]
yearmonth_stats[R]
Public Class Methods
new()
click to toggle source
# File lib/gitstats/statgen.rb, line 26 def initialize @repos = Array.new @repostate = Hash.new @verbose = false @debug = false @quiet = false @future = true @maxage = 0 @commitcache = nil @include_mail = false @num_commits = 0 @general_stats = CommitStats.new @author_stats = AuthorsCommitStats.new @year_stats = YearCommitStats.new @month_stats = MonthCommitStats.new @yearmonth_stats = YearMonthCommitStats.new @date_stats = DateCommitStats.new @hour_stats = HourCommitStats.new @wday_stats = DayOfWeekCommitStats.new @lastweeks_stats = LastWeeksCommitStats.new @file_stats = FileStats.new @filetype_stats = FileTypeFileStats.new end
Public Instance Methods
<<(value)
click to toggle source
# File lib/gitstats/statgen.rb, line 76 def <<(value) add(value[0], value[1], value[2]) end
add(name, directory, ref = 'HEAD')
click to toggle source
# File lib/gitstats/statgen.rb, line 68 def add(name, directory, ref = 'HEAD') cache = nil unless @commitcache.nil? cache = File.join(@commitcache, ".commitcache.#{name.tr('^a-zA-Z0-9_', '_')}") end @repos << Git.new(name, directory, ref, @debug, cache) end
calc()
click to toggle source
# File lib/gitstats/statgen.rb, line 80 def calc # reset because of caching for now @file_stats = FileStats.new @filetype_stats = FileTypeFileStats.new @repos.each do |repo| @repostate[repo.name] ||= { :last => nil } puts " repository '#{repo.name}' ..." unless @quiet repo.get_commits(@repostate[repo.name][:last]) do |commit| next if !@future && (commit[:time] > Time.now) next if (@maxage > 0) && ((Time.now - commit[:time]) > @maxage) puts " commit #{@num_commits} ..." if @verbose && ((@num_commits % 100) == 0) @num_commits += 1 @general_stats.update(commit) @author_stats.update(commit) @year_stats.update(commit) @month_stats.update(commit) @yearmonth_stats.update(commit) @date_stats.update(commit) @hour_stats.update(commit) @wday_stats.update(commit) @lastweeks_stats.update(commit) @repostate[repo.name][:last] = commit[:hash] end repo.get_files do |file| @file_stats.update(file) @filetype_stats.update(file) end end end
check_repostate()
click to toggle source
# File lib/gitstats/statgen.rb, line 61 def check_repostate @repostate.keys.each do |name| return false if @repos.find { |x| x.name == name }.nil? end true end
clear_repos()
click to toggle source
# File lib/gitstats/statgen.rb, line 57 def clear_repos @repos = Array.new end