Class: Gglog::CommitMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/gglog/commit_message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first_line, body, repository, sha) ⇒ CommitMessage

Returns a new instance of CommitMessage.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gglog/commit_message.rb', line 19

def initialize(first_line, body, repository, sha)
  @first_line = first_line || ""
  @body = body || ""
  @repository = repository || ""
  @sha = sha || ""

  @first_line = @first_line.force_encoding('UTF-8')
  @body = @body.force_encoding('UTF-8')
  @repository = @repository.force_encoding('utf-8')
  @sha = @sha.force_encoding('utf-8')
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



15
16
17
# File 'lib/gglog/commit_message.rb', line 15

def body
  @body
end

#first_lineObject (readonly)

Returns the value of attribute first_line.



15
16
17
# File 'lib/gglog/commit_message.rb', line 15

def first_line
  @first_line
end

#first_line_included_snippetObject

Returns the value of attribute first_line_included_snippet.



17
18
19
# File 'lib/gglog/commit_message.rb', line 17

def first_line_included_snippet
  @first_line_included_snippet
end

#repositoryObject (readonly)

Returns the value of attribute repository.



16
17
18
# File 'lib/gglog/commit_message.rb', line 16

def repository
  @repository
end

#shaObject (readonly)

Returns the value of attribute sha.



16
17
18
# File 'lib/gglog/commit_message.rb', line 16

def sha
  @sha
end

Class Method Details

.new_from_commit_object(commit, repository_name) ⇒ Object



5
6
7
8
# File 'lib/gglog/commit_message.rb', line 5

def new_from_commit_object(commit, repository_name)
  first_line, _, body = commit.message.split("\n", 3)
  self.new(first_line, body, repository_name, commit.oid)
end

.new_from_record(commit_message) ⇒ Object



10
11
12
13
# File 'lib/gglog/commit_message.rb', line 10

def new_from_record(commit_message)
  self.new(commit_message.first_line, commit_message.body,
           commit_message.repository, commit_message.sha)
end