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
    def initialize(str)
      status = STATUS_BOTH
      
      section = 1
      @conflicts = 0
      @text = {}
      
      lines = str.split("\n")
      lines.each do |line|
        if /^<<<<<<< (.*?)/.match(line)
          status = STATUS_OURS
          @conflicts += 1
          section += 1
        elsif line == '======='
          status = STATUS_THEIRS
        elsif /^>>>>>>> (.*?)/.match(line)
          status = STATUS_BOTH          
          section += 1
        else
          @text[section] ||= {}
          @text[section][status] ||= []
          @text[section][status] << line
        end
      end
      @text = @text.values
      @sections = @text.size
    end

Public Instance methods

Pretty object inspection

[Source]

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

[Validate]