Sha256: 3130cb9e200ff8daeb214c6dc8bdce40595b04a412ffc92733dc14d4dd68fb6e

Contents?: true

Size: 664 Bytes

Versions: 3

Compression:

Stored size: 664 Bytes

Contents

module FixTSVConflict
  class Conflict
    attr_reader :left, :lbranch, :right, :rbranch

    def initialize(left, lbranch, right, rbranch)
      @left = left
      @lbranch = lbranch
      @right = right
      @rbranch = rbranch
    end

    ID_REGEXP = /\A[0-9]+\t/
    NL_REGEXP = /\A\n/

    def valid?
      left.all? { |line| ID_REGEXP =~ line || NL_REGEXP =~ line} &&
        right.all? { |line| ID_REGEXP =~ line || NL_REGEXP =~ line }
    end

    def to_a
      result = []
      result << "#{LEFT} #{lbranch}\n"
      result += left
      result << "#{SEP}\n"
      result += right
      result << "#{RIGHT} #{rbranch}\n"
      result
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fix_tsv_conflict-0.3.0 lib/fix_tsv_conflict/conflict.rb
fix_tsv_conflict-0.2.1 lib/fix_tsv_conflict/conflict.rb
fix_tsv_conflict-0.2.0 lib/fix_tsv_conflict/conflict.rb