Class Grit::Merge
In: lib/grit/merge.rb
Parent: Object

Methods

inspect   new  

Constants

STATUS_BOTH = 'both'
STATUS_OURS = 'ours'
STATUS_THEIRS = 'theirs'

Attributes

conflicts  [R] 
sections  [R] 
text  [R] 

Public Class methods

[Source]

    # File lib/grit/merge.rb, line 11
11:     def initialize(str)
12:       status = STATUS_BOTH
13:       
14:       section = 1
15:       @conflicts = 0
16:       @text = {}
17:       
18:       lines = str.split("\n")
19:       lines.each do |line|
20:         if /^<<<<<<< (.*?)/.match(line)
21:           status = STATUS_OURS
22:           @conflicts += 1
23:           section += 1
24:         elsif line == '======='
25:           status = STATUS_THEIRS
26:         elsif /^>>>>>>> (.*?)/.match(line)
27:           status = STATUS_BOTH          
28:           section += 1
29:         else
30:           @text[section] ||= {}
31:           @text[section][status] ||= []
32:           @text[section][status] << line
33:         end
34:       end
35:       @text = @text.values
36:       @sections = @text.size
37:     end

Public Instance methods

Pretty object inspection

[Source]

    # File lib/grit/merge.rb, line 40
40:     def inspect
41:       %Q{#<Grit::Merge}
42:     end

[Validate]