Sha256: fce46b527df38c0cfd8c21f93fce00eb72c84b77206d2caabed1390102772275
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require "fix_tsv_conflict/logging" module FixTSVConflict class DiffPrinter include Logging attr_reader :stderr def initialize(stderr: $stderr) @stderr = stderr @left, @right = {}, {} end def print(cols, left, lbranch, right, rbranch) @lbranch, @rbranch = lbranch, rbranch left = left.chomp.split(TAB) right = right.chomp.split(TAB) cols.each do |col, i| l, r = left[i], right[i] if l == r flush_conflicts if in_conflict? dump [col, l].join(TAB) else @left[col] = l @right[col] = r end end flush_conflicts end def flush_conflicts dump "#{LEFT} #{@lbranch}" dump @left.map { |c, v| [c, v].join(TAB) } dump SEP dump @right.map { |c, v| [c, v].join(TAB) } dump "#{RIGHT} #{@rbranch}" @left.clear @right.clear end def print_col_and_value(col, value) @stderr.puts [col, value].join(TAB) end def in_conflict? @left.length > 0 || @right.length > 0 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fix_tsv_conflict-0.1.2 | lib/fix_tsv_conflict/diff_printer.rb |
fix_tsv_conflict-0.1.1 | lib/fix_tsv_conflict/diff_printer.rb |