|
|
|
@ -29,11 +29,12 @@ |
|
|
|
|
|
|
|
|
|
namespace :copyright do |
|
|
|
|
namespace :authors do |
|
|
|
|
desc "Shows contributors to a project" |
|
|
|
|
desc "Shows contributors of a repository" |
|
|
|
|
task :show, :arg1 do |task, args| |
|
|
|
|
contribution_periods = contribution_periods_of_project(args[:arg1]) |
|
|
|
|
contribution_periods = contribution_periods_of_repository(args[:arg1]) |
|
|
|
|
formatted_periods = format_contribution_periods(contribution_periods) |
|
|
|
|
|
|
|
|
|
show_contribution_periods(contribution_periods) |
|
|
|
|
show_contribution_periods(formatted_periods) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
private |
|
|
|
@ -43,7 +44,7 @@ namespace :copyright do |
|
|
|
|
|
|
|
|
|
CONTRIBUTION_REGEX = /^(?<date>\d\d\d\d-\d\d-\d\d) (?<author>.*)$/ |
|
|
|
|
|
|
|
|
|
def contribution_periods_of_project(path) |
|
|
|
|
def contribution_periods_of_repository(path) |
|
|
|
|
contributions = [] |
|
|
|
|
contribution_periods = [] |
|
|
|
|
path = '.' if path.nil? |
|
|
|
@ -64,10 +65,17 @@ namespace :copyright do |
|
|
|
|
contribution_periods.sort_by{ |c| [c.end, c.begin] }.reverse |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def show_contribution_periods(contribution_periods) |
|
|
|
|
contribution_periods.each do |c| |
|
|
|
|
period = (c.begin == c.end) ? c.begin.to_s : "#{c.begin} - #{c.end}" |
|
|
|
|
puts "#{period} #{c.author}" |
|
|
|
|
def format_contribution_periods(contribution_periods) |
|
|
|
|
contribution_periods.each_with_object({}) do |c, h| |
|
|
|
|
date = (c.begin == c.end) ? c.begin.to_s : "#{c.begin} - #{c.end}" |
|
|
|
|
h[date] = [] unless h.has_key? date |
|
|
|
|
h[date] << c.author |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def show_contribution_periods(formatted_periods) |
|
|
|
|
formatted_periods.each_pair do |date, authors| |
|
|
|
|
puts "#{date} #{authors.join(", ")}" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|