From 02010868fd9989bc626c3d6fcf6ee4a75b4b210d Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 24 Sep 2014 19:46:02 +0200 Subject: [PATCH] Prepare for authors & costs managements. --- lib/timecost/range.rb | 12 ++++++++++-- lib/timecost/user.rb | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 lib/timecost/user.rb diff --git a/lib/timecost/range.rb b/lib/timecost/range.rb index 212ba50..b3b3a8b 100644 --- a/lib/timecost/range.rb +++ b/lib/timecost/range.rb @@ -1,10 +1,15 @@ module TimeCost class Range - attr_accessor :time_start, :time_stop, :commits + attr_accessor :time_start, :time_stop, :commits, :author def initialize config, commit @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_start = @time_stop - (@config[:range_granularity] * 3 / 24.0) @commits = [commit] @@ -33,6 +38,9 @@ module TimeCost def overlap? range result = false + # return early result if ranges come from different authors + return false if (@author != range.author) + # Ref ----[----]----- # overlapping : # A -[----]-------- @@ -53,7 +61,6 @@ module TimeCost stop_before_start = (range.time_stop < @time_start) stop_after_start = (range.time_stop >= @time_start) - # A case if start_before_start and start_before_stop and stop_after_start and stop_before_stop then @@ -105,3 +112,4 @@ module TimeCost end end end + diff --git a/lib/timecost/user.rb b/lib/timecost/user.rb new file mode 100644 index 0000000..8335fde --- /dev/null +++ b/lib/timecost/user.rb @@ -0,0 +1,8 @@ + +module TimeCost + class Range + # Return local user id for git user + def self.parse gituser + end + end +end