Class: StatGen
- Inherits:
-
Object
- Object
- StatGen
- Defined in:
- lib/gitstats/statgen.rb
Instance Attribute Summary collapse
-
#author_stats ⇒ Object
readonly
Returns the value of attribute author_stats.
-
#commitcache ⇒ Object
Returns the value of attribute commitcache.
-
#date_stats ⇒ Object
readonly
Returns the value of attribute date_stats.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#file_stats ⇒ Object
readonly
Returns the value of attribute file_stats.
-
#filetype_stats ⇒ Object
readonly
Returns the value of attribute filetype_stats.
-
#future ⇒ Object
Returns the value of attribute future.
-
#general_stats ⇒ Object
readonly
Returns the value of attribute general_stats.
-
#hour_stats ⇒ Object
readonly
Returns the value of attribute hour_stats.
-
#include_mail ⇒ Object
Returns the value of attribute include_mail.
-
#lastweeks_stats ⇒ Object
readonly
Returns the value of attribute lastweeks_stats.
-
#maxage ⇒ Object
Returns the value of attribute maxage.
-
#month_stats ⇒ Object
readonly
Returns the value of attribute month_stats.
-
#num_commits ⇒ Object
readonly
Returns the value of attribute num_commits.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#repos ⇒ Object
readonly
Returns the value of attribute repos.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#wday_stats ⇒ Object
readonly
Returns the value of attribute wday_stats.
-
#year_stats ⇒ Object
readonly
Returns the value of attribute year_stats.
-
#yearmonth_stats ⇒ Object
readonly
Returns the value of attribute yearmonth_stats.
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #add(name, directory, ref = 'HEAD') ⇒ Object
- #calc ⇒ Object
- #check_repostate ⇒ Object
- #clear_repos ⇒ Object
-
#initialize ⇒ StatGen
constructor
A new instance of StatGen.
- #num_authors ⇒ Object
Constructor Details
#initialize ⇒ StatGen
Returns a new instance of StatGen.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Attribute Details
#author_stats ⇒ Object (readonly)
Returns the value of attribute author_stats.
14 15 16 |
# File 'lib/gitstats/statgen.rb', line 14 def @author_stats end |
#commitcache ⇒ Object
Returns the value of attribute commitcache.
7 8 9 |
# File 'lib/gitstats/statgen.rb', line 7 def commitcache @commitcache end |
#date_stats ⇒ Object (readonly)
Returns the value of attribute date_stats.
18 19 20 |
# File 'lib/gitstats/statgen.rb', line 18 def date_stats @date_stats end |
#debug ⇒ Object
Returns the value of attribute debug.
3 4 5 |
# File 'lib/gitstats/statgen.rb', line 3 def debug @debug end |
#file_stats ⇒ Object (readonly)
Returns the value of attribute file_stats.
23 24 25 |
# File 'lib/gitstats/statgen.rb', line 23 def file_stats @file_stats end |
#filetype_stats ⇒ Object (readonly)
Returns the value of attribute filetype_stats.
24 25 26 |
# File 'lib/gitstats/statgen.rb', line 24 def filetype_stats @filetype_stats end |
#future ⇒ Object
Returns the value of attribute future.
5 6 7 |
# File 'lib/gitstats/statgen.rb', line 5 def future @future end |
#general_stats ⇒ Object (readonly)
Returns the value of attribute general_stats.
13 14 15 |
# File 'lib/gitstats/statgen.rb', line 13 def general_stats @general_stats end |
#hour_stats ⇒ Object (readonly)
Returns the value of attribute hour_stats.
19 20 21 |
# File 'lib/gitstats/statgen.rb', line 19 def hour_stats @hour_stats end |
#include_mail ⇒ Object
Returns the value of attribute include_mail.
8 9 10 |
# File 'lib/gitstats/statgen.rb', line 8 def include_mail @include_mail end |
#lastweeks_stats ⇒ Object (readonly)
Returns the value of attribute lastweeks_stats.
21 22 23 |
# File 'lib/gitstats/statgen.rb', line 21 def lastweeks_stats @lastweeks_stats end |
#maxage ⇒ Object
Returns the value of attribute maxage.
6 7 8 |
# File 'lib/gitstats/statgen.rb', line 6 def maxage @maxage end |
#month_stats ⇒ Object (readonly)
Returns the value of attribute month_stats.
16 17 18 |
# File 'lib/gitstats/statgen.rb', line 16 def month_stats @month_stats end |
#num_commits ⇒ Object (readonly)
Returns the value of attribute num_commits.
11 12 13 |
# File 'lib/gitstats/statgen.rb', line 11 def num_commits @num_commits end |
#quiet ⇒ Object
Returns the value of attribute quiet.
4 5 6 |
# File 'lib/gitstats/statgen.rb', line 4 def quiet @quiet end |
#repos ⇒ Object (readonly)
Returns the value of attribute repos.
9 10 11 |
# File 'lib/gitstats/statgen.rb', line 9 def repos @repos end |
#verbose ⇒ Object
Returns the value of attribute verbose.
2 3 4 |
# File 'lib/gitstats/statgen.rb', line 2 def verbose @verbose end |
#wday_stats ⇒ Object (readonly)
Returns the value of attribute wday_stats.
20 21 22 |
# File 'lib/gitstats/statgen.rb', line 20 def wday_stats @wday_stats end |
#year_stats ⇒ Object (readonly)
Returns the value of attribute year_stats.
15 16 17 |
# File 'lib/gitstats/statgen.rb', line 15 def year_stats @year_stats end |
#yearmonth_stats ⇒ Object (readonly)
Returns the value of attribute yearmonth_stats.
17 18 19 |
# File 'lib/gitstats/statgen.rb', line 17 def yearmonth_stats @yearmonth_stats end |
Instance Method Details
#<<(value) ⇒ Object
76 77 78 |
# File 'lib/gitstats/statgen.rb', line 76 def <<(value) add(value[0], value[1], value[2]) end |
#add(name, directory, ref = 'HEAD') ⇒ Object
68 69 70 71 72 73 74 |
# 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 ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# 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 ⇒ Object
61 62 63 64 65 66 |
# 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 ⇒ Object
57 58 59 |
# File 'lib/gitstats/statgen.rb', line 57 def clear_repos @repos = Array.new end |
#num_authors ⇒ Object
53 54 55 |
# File 'lib/gitstats/statgen.rb', line 53 def @author_stats.size end |