Module: GitTeamStats
- Defined in:
- lib/git_team_stats.rb,
lib/git_team_stats/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
- .collect_commits ⇒ Object
- .count_commits ⇒ Object
- .get_cache_file_name ⇒ Object
- .get_cache_output ⇒ Object
- .inspect_commits ⇒ Object
- .load_from_cache(data) ⇒ Object
- .start(project) ⇒ Object
- .team_cumulative_stats ⇒ Object
- .user_cumulative_stats(user) ⇒ Object
Class Method Details
.collect_commits ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/git_team_stats.rb', line 35 def self.collect_commits unless @inspected @project[:parsers].each do |parser| parser.get_commits() end end end |
.count_commits ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/git_team_stats.rb', line 25 def self.count_commits count = 0 if !@inspected self.inspect_commits() end return @commits_in_detail.length end |
.get_cache_file_name ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/git_team_stats.rb', line 128 def self.get_cache_file_name hash_str = "" @project[:parsers].each{ |parser| hash_str += parser.get_head_short_hash().to_s + "-" } return $project[:name].to_s + "-" + hash_str + @project[:start_date].to_s + '-' + @project[:end_date].to_s end |
.get_cache_output ⇒ Object
119 120 121 |
# File 'lib/git_team_stats.rb', line 119 def self.get_cache_output return @commits_in_detail end |
.inspect_commits ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/git_team_stats.rb', line 44 def self.inspect_commits unless @inspected self.collect_commits() @project[:parsers].each do |parser| @commits_in_detail += parser.get_commit_details() end @inspected = true end end |
.load_from_cache(data) ⇒ Object
123 124 125 126 |
# File 'lib/git_team_stats.rb', line 123 def self.load_from_cache(data) @commits_in_detail = data @inspected = true end |
.start(project) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/git_team_stats.rb', line 10 def self.start(project) @project = project @commits_in_detail = [] @project[:parsers] = [] @project[:repos].each do |repo| @project[:parsers].push( GitParse.new(repo) ) end end |
.team_cumulative_stats ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/git_team_stats.rb', line 57 def self.team_cumulative_stats self.inspect_commits() team_cumulative = { :commits => 0, :lines => 0, :edits => 0, :file_types => {} } @commits_in_detail.each do |commit| team_cumulative[:commits] += 1 team_cumulative[:lines] += commit[:lines] team_cumulative[:edits] += commit[:edits] commit[:file_types].each do |language, details| if team_cumulative[:file_types].key? language team_cumulative[:file_types][language][:lines] += details[:lines] team_cumulative[:file_types][language][:edits] += details[:edits] else team_cumulative[:file_types][language] = { :lines => details[:lines], :edits => details[:edits] } end end end return team_cumulative end |
.user_cumulative_stats(user) ⇒ Object
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/git_team_stats.rb', line 87 def self.user_cumulative_stats(user) self.inspect_commits() user_cumulative = { :commits => 0, :lines => 0, :edits => 0, :file_types => {} } @commits_in_detail.each do |commit| if user[:aliases].any?{ |name| name == commit[:committer] } user_cumulative[:commits] += 1 user_cumulative[:lines] += commit[:lines] user_cumulative[:edits] += commit[:edits] commit[:file_types].each do |language, details| if user_cumulative[:file_types].key? language user_cumulative[:file_types][language][:lines] += details[:lines] user_cumulative[:file_types][language][:edits] += details[:edits] else user_cumulative[:file_types][language] = { :lines => details[:lines], :edits => details[:edits] } end end end end return user_cumulative end |