Class: PairingMatrix::CommitReader
- Inherits:
-
Object
- Object
- PairingMatrix::CommitReader
- Defined in:
- lib/pairing_matrix/commit_reader.rb
Direct Known Subclasses
Instance Method Summary collapse
- #authors(since) ⇒ Object
- #authors_with_commits(days) ⇒ Object
-
#initialize(config) ⇒ CommitReader
constructor
A new instance of CommitReader.
- #read(since) ⇒ Object
Constructor Details
#initialize(config) ⇒ CommitReader
Returns a new instance of CommitReader.
5 6 7 |
# File 'lib/pairing_matrix/commit_reader.rb', line 5 def initialize(config) @config = config end |
Instance Method Details
#authors(since) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/pairing_matrix/commit_reader.rb', line 19 def (since) commits = read(since) commits.map do |commit| commit.scan(/#{@config.authors_regex}/).flatten.compact.reject(&:empty?).map { |name| name.gsub(' ', '') }.sort.join(',') end.compact.reject(&:empty?) end |
#authors_with_commits(days) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pairing_matrix/commit_reader.rb', line 26 def (days) date = (Date.today - days).to_s = (date) = .group_by { |n| n } .map do |k, v| pair = k.split(',') pair.unshift('') if pair.size == 1 [pair, v.size].flatten end end |
#read(since) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/pairing_matrix/commit_reader.rb', line 9 def read(since) commits = [] @config.repos.each do |repo| Dir.chdir repo do commits << read_commits(since) end end commits.flatten end |