Class: GitHack::CommitLineBuilder

Inherits:
LineBuilder show all
Defined in:
lib/git-hack/commit_line_builder.rb

Instance Attribute Summary

Attributes inherited from LineBuilder

#data, #index, #object

Instance Method Summary collapse

Methods inherited from LineBuilder

#in?, #out?, #parse

Constructor Details

#initialize(data, index) ⇒ CommitLineBuilder

Returns a new instance of CommitLineBuilder.



7
8
9
10
11
# File 'lib/git-hack/commit_line_builder.rb', line 7

def initialize(data,index)
	super(data,index)
	@is_message = false
	@commit = { 'masseg' => '', parent => []}
end

Instance Method Details

#process_lineObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/git-hack/commit_line_builder.rb', line 12

def process_line
	@is_message
	line = @data[@index]		
	line = line.chomp
	if line == ""
		@is_message = !@is_message
	elsif is_message
		@commit.message << line+"\n"
	else
		data = line.split
		key = data.shift
		value = data.join(" ")
		if key == 'commit'
			@commit['sha'] = value
		end
		if key == 'parent'
			@commit[key] << value
		else
		end
	end
end