class Capillary::Commit

Constants

LOG_SEPARATOR

Attributes

committed_at[RW]
committer_email[RW]
id[RW]
message[W]
parent_ids[RW]
refs[R]
seq_id[RW]

Public Class Methods

new() click to toggle source
# File lib/capillary/commit.rb, line 29
def initialize
  @refs = RefCollection.new
end
parse(git_line) click to toggle source

Creates an instance from Git output

# File lib/capillary/commit.rb, line 34
def self.parse(git_line)
  git_line = git_line.gsub(/^[^a-f0-9]+/, "")
  return nil if git_line == ""

  parts = git_line.force_encoding('utf-8').split(LOG_SEPARATOR)
  result = new
  result.id = parts[0]
  result.parent_ids = parts[1].split(" ")
  result.committed_at = Time.parse(parts[2])
  result.committer_email = parts[3]
  result.refs.parse(parts[4])
  result.message = parts[5]
  result
end

Public Instance Methods

message() click to toggle source
# File lib/capillary/commit.rb, line 68
def message
  HTMLEntities.new.encode(@message)
end
to_hash() click to toggle source
# File lib/capillary/commit.rb, line 49
def to_hash
  { "id" => id,
    "parent_ids" => parent_ids,
    "committed_at" => committed_at,
    "committer_email" => committer_email,
    "refs" => refs.to_hash,
    "message" => message }
end
to_json() click to toggle source
# File lib/capillary/commit.rb, line 58
def to_json
  JSON.unparse({ "id" => id,
                 "parentIds" => parent_ids,
                 "committedAt" => committed_at,
                 "committerEmail" => committer_email,
                 "refs" => refs.to_hash,
                 "message" => message,
                 "seqId" => seq_id})
end