Prepare for authors & costs managements.

This commit is contained in:
Glenn Y. Rolland 2014-09-24 19:46:02 +02:00
parent 91b37ffaa5
commit 02010868fd
2 changed files with 18 additions and 2 deletions

View file

@ -1,10 +1,15 @@
module TimeCost module TimeCost
class Range class Range
attr_accessor :time_start, :time_stop, :commits attr_accessor :time_start, :time_stop, :commits, :author
def initialize config, commit def initialize config, commit
@config = config @config = config
# FIXME: First approximation for users
# later, we'll replace with @user = User.parse(commit.author)
@author = commit.author
@time_stop = DateTime.parse(commit.date) @time_stop = DateTime.parse(commit.date)
@time_start = @time_stop - (@config[:range_granularity] * 3 / 24.0) @time_start = @time_stop - (@config[:range_granularity] * 3 / 24.0)
@commits = [commit] @commits = [commit]
@ -33,6 +38,9 @@ module TimeCost
def overlap? range def overlap? range
result = false result = false
# return early result if ranges come from different authors
return false if (@author != range.author)
# Ref ----[----]----- # Ref ----[----]-----
# overlapping : # overlapping :
# A -[----]-------- # A -[----]--------
@ -53,7 +61,6 @@ module TimeCost
stop_before_start = (range.time_stop < @time_start) stop_before_start = (range.time_stop < @time_start)
stop_after_start = (range.time_stop >= @time_start) stop_after_start = (range.time_stop >= @time_start)
# A case # A case
if start_before_start and start_before_stop and if start_before_start and start_before_stop and
stop_after_start and stop_before_stop then stop_after_start and stop_before_stop then
@ -105,3 +112,4 @@ module TimeCost
end end
end end
end end

8
lib/timecost/user.rb Normal file
View file

@ -0,0 +1,8 @@
module TimeCost
class Range
# Return local user id for git user
def self.parse gituser
end
end
end