diff --git a/lib/timecost/cli.rb b/lib/timecost/cli.rb index de2183b..fad7298 100644 --- a/lib/timecost/cli.rb +++ b/lib/timecost/cli.rb @@ -16,7 +16,7 @@ module TimeCost :verbose => false } - @rangelist = nil + @rangelist = {} @authorlist = nil end @@ -81,7 +81,7 @@ module TimeCost "--","."] - @rangelist = RangeList.new + @rangelist = {} commit = nil loop do line = process.gets @@ -96,7 +96,11 @@ module TimeCost # merge ranges & push unless commit.nil? then range = Range.new @config, commit - @rangelist.add range + + if not @rangelist.include? commit.author then + @rangelist[commit.author] = RangeList.new + end + @rangelist[commit.author].add range end commit = Commit.new id # puts "commit #{id}" @@ -110,6 +114,7 @@ module TimeCost commit = nil # reject end + end when /^Date:\s*(.*?)\s*$/ then @@ -170,10 +175,17 @@ module TimeCost def report return if not @config[:output_dump].nil? - @rangelist.each do |r| - puts r.to_s + "\n" + @rangelist.each do |author,rangelist| + rangelist.each do |range| + puts range.to_s + "\n" + end end - puts "TOTAL: %.2f hours" % @rangelist.sum + total = 0 + @rangelist.each do |author,rangelist| + puts "SUB-TOTAL for %s: %.2f hours\n" % [author, rangelist.sum] + total += rangelist.sum + end + puts "TOTAL: %.2f hours" % total end end end diff --git a/lib/timecost/range.rb b/lib/timecost/range.rb index b3b3a8b..627d69f 100644 --- a/lib/timecost/range.rb +++ b/lib/timecost/range.rb @@ -97,12 +97,12 @@ module TimeCost end def to_s - val = "(%s) %s - %s\n" % [diff, fixed_start, @time_stop] + val = "(%s)\t%s - %s\n" % [diff, fixed_start, @time_stop] + unless @config[:author_filter_enable] then + val += "\tby %s\n" % @commits.first.author + end @commits.each do |commit| lines = [] - unless @config[:author_filter_enable] then - lines.push commit.author - end lines.concat commit.note.split(/\n/) r = lines.map{ |s| "\t %s" % s }.join "\n" r[1] = '*' diff --git a/timecost.gemspec b/timecost.gemspec index a0803f0..b244ab5 100644 --- a/timecost.gemspec +++ b/timecost.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| spec.email = ["glenux@glenux.net"] spec.summary = %q{Use GIT logs to give an estimation of spent time & costs of your projects.} spec.description = %q{Use GIT logs to give an estimation of spent time & costs of your projects.} - spec.homepage = "https//github.com/glenux/git-timecost" + spec.homepage = "https://github.com/glenux/git-timecost" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0")