mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
activity creation dryed out
This commit is contained in:
parent
72944cc5c5
commit
00e99ea4af
2 changed files with 10 additions and 29 deletions
|
@ -10,6 +10,6 @@ require "git_stats/cli"
|
||||||
begin
|
begin
|
||||||
cli = GitStats::CLI.new
|
cli = GitStats::CLI.new
|
||||||
cli.start(*ARGV)
|
cli.start(*ARGV)
|
||||||
rescue => e
|
rescue ArgumentError => e
|
||||||
puts e.message
|
puts e.message
|
||||||
end
|
end
|
|
@ -2,39 +2,20 @@ module GitStats
|
||||||
module GitData
|
module GitData
|
||||||
class Activity
|
class Activity
|
||||||
|
|
||||||
|
attr_reader :by_hour, :by_wday, :by_wday_hour, :by_month, :by_year, :by_year_week
|
||||||
|
|
||||||
def initialize(commits)
|
def initialize(commits)
|
||||||
commits.values.each do |commit|
|
@by_hour = @by_wday = @by_month = @by_year = Hash.new(0)
|
||||||
add_commit(commit)
|
@by_wday_hour = @by_year_week = Hash.new { |h, k| h[k] = Hash.new(0) }
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_hour
|
add_commits(commits)
|
||||||
@by_hour ||= Hash.new(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_wday
|
|
||||||
@by_wday ||= Hash.new(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_wday_hour
|
|
||||||
@by_wday_hour ||= Hash.new { |h, k| h[k] = Hash.new(0) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_month
|
|
||||||
@by_month ||= Hash.new(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_year
|
|
||||||
@by_year ||= Hash.new(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
def by_year_week
|
|
||||||
@by_year_week ||= Hash.new { |h, k| h[k] = Hash.new(0) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def add_commit(commit)
|
def add_commits(commits)
|
||||||
add_commit_at(commit.date)
|
commits.values.each do |commit|
|
||||||
|
add_commit_at(commit.date)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_commit_at(date)
|
def add_commit_at(date)
|
||||||
|
|
Loading…
Reference in a new issue