class PairingMatrix::CommitReader

Public Class Methods

new(config) click to toggle source
# File lib/pairing_matrix/commit_readers/commit_reader.rb, line 5
def initialize(config)
    @config = config
end

Public Instance Methods

authors_with_commits(days) click to toggle source
# File lib/pairing_matrix/commit_readers/commit_reader.rb, line 9
def authors_with_commits(days)
    date = (Date.today - days).to_s
    authors = authors(date)
    author_groups = authors.group_by { |n| titleize(n)}
    author_groups.map do |k, v|
        pair = k.split(',')
        pair.unshift('') if pair.size == 1
        [pair, v.size].flatten
    end
end

Protected Instance Methods

read(since) click to toggle source
# File lib/pairing_matrix/commit_readers/commit_reader.rb, line 21
def read(since)
    #to be implemented by child commit reader
end

Private Instance Methods

authors(since) click to toggle source
# File lib/pairing_matrix/commit_readers/commit_reader.rb, line 26
def authors(since)
    commits = if @config.absent? then [] else read(since) end
    commits.map do |commit|
      commit.scan(/#{@config.authors_regex}/).flatten.compact.reject(&:empty?).map { |name| name.gsub(' ', '') }.sort.join(',')
    end.compact.reject(&:empty?)
end
titleize(name) click to toggle source
# File lib/pairing_matrix/commit_readers/commit_reader.rb, line 33
def titleize(name)
    name.gsub(/\w+/) do |word|
        word.capitalize
    end
end