lib/repository.rb in caelum-git-reports-0.1.1 vs lib/repository.rb in caelum-git-reports-0.2.0

- old
+ new

@@ -3,14 +3,15 @@ class Repository attr_accessor :name, :dir, :url attr_reader :commiters, :summary - def initialize(name, dir) + def initialize(name, dir, translations) @name = name @dir = dir @delimiter = "#{200.chr}@@@" + @translations = translations end def clone `cd #{dir} && git clone #{url} > /dev/null 2>&1` end @@ -39,10 +40,13 @@ for commit in log.split(@delimiter) temp = [] for info in commit.split("\n") temp.push info unless info == "" end + if (@translations[temp[0]]) + temp[0] = @translations[temp[0]] + end @summary[temp[1]] = {:commiter => temp[0], :time => Time.at(temp[1].to_i), :message => temp[2]} if temp[1] end end def calculate_stats(from = Date.new, to = Date.new) @@ -52,9 +56,12 @@ match = regexp.match(log) @commiters = Hash.new while !match.nil? email = match[1].gsub("\n", "") + if (@translations[email]) + email = @translations[email] + end if @commiters[email].nil? @commiters[email] = 0 end \ No newline at end of file