class HgCommitLogParser
this is not namespaced under Solano
because we want to eventually move this out into another gem
Attributes
commit_log[RW]
Public Class Methods
new(commit_log)
click to toggle source
beb3d918995bbe6370bb21fd76b4f433bfd64dc4 commit summary user user@host.domain 1399437808.00 user user@host.domain 1399437808.00
# File lib/solano/scm/hg_log_parser.rb, line 19 def initialize(commit_log) @commit_log = commit_log end
Public Instance Methods
commits()
click to toggle source
Returns a list of commits in the following format [{
"id" => "15e8cbd88d68d210953d51c28e26c6b9944a313b", "author" => {"name"=>"Bob Smith", "email"=>"bob@example.com"}, "committer" => {"name"=>"Fred Smith", "email"=>"fred@example.com"}, "summary" => "ignore .ruby-version for rvm", "date" => 1380603292
}]
# File lib/solano/scm/hg_log_parser.rb, line 32 def commits record = [] commits = [] commit_log.lines.each do |line| line.strip! line.sanitize! if line.empty? c = parse_commit(record) commits.push(c) record = [] else record.push(line) end end commits end
Private Instance Methods
build_commit(sha, author, committer, summary, date)
click to toggle source
# File lib/solano/scm/hg_log_parser.rb, line 63 def build_commit(sha, author, committer, summary, date) {"id" => sha, "author" => author, "committer" => committer, "summary" => summary, "date" => date} end
build_user(name, email)
click to toggle source
# File lib/solano/scm/hg_log_parser.rb, line 59 def build_user(name, email) {"name" => name, "email" => email} end
parse_commit(record)
click to toggle source
# File lib/solano/scm/hg_log_parser.rb, line 52 def parse_commit(record) time = record[4].to_i author = build_user(record[2], record[3]) committer = build_user(record[5], record[6]) build_commit(record[0], author, committer, record[1], time) end