mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 05:06:46 +10:00
Created tests and refactored some code along the way Added stat graph util spec, refactored code finsihed up tests and refactors finsihed up tests and refactors
32 lines
722 B
Ruby
32 lines
722 B
Ruby
class LogParser
|
|
#Parses the log file into a collection of commits
|
|
#Data model: {author, date, additions, deletions}
|
|
def self.parse_log log_from_git
|
|
log = log_from_git.split("\n")
|
|
|
|
i = 0
|
|
collection = []
|
|
entry = {}
|
|
|
|
while i <= log.size do
|
|
pos = i % 4
|
|
case pos
|
|
when 0
|
|
unless i == 0
|
|
collection.push(entry)
|
|
entry = {}
|
|
end
|
|
entry[:author] = log[i].to_s
|
|
when 1
|
|
entry[:date] = log[i].to_s
|
|
when 3
|
|
changes = log[i].split(",")
|
|
entry[:additions] = changes[1].to_i unless changes[1].nil?
|
|
entry[:deletions] = changes[2].to_i unless changes[2].nil?
|
|
end
|
|
i += 1
|
|
end
|
|
|
|
collection
|
|
end
|
|
end |