vendor/gems/diff-lcs-1.1.2/lib/diff/lcs/hunk.rb
def context_diff
    s = "***************\n"
    s << "*** #{context_range(:old)} ****\n"
    r = context_range(:new)

      # Print out file 1 part for each block in context diff format if there
      # are any blocks that remove items
    lo, hi = @start_old, @end_old
    removes = @blocks.select { |e| not e.remove.empty? }
    if removes
      outlist = @data_old[lo .. hi].collect { |e| e.gsub(/^/, '  ') }
      removes.each do |block|
        block.remove.each do |item|
          outlist[item.position - lo].gsub!(/^ /) { block.op } # - or !
        end
      end
      s << outlist.join("\n")
    end

    s << "\n--- #{r} ----\n"
    lo, hi = @start_new, @end_new
    inserts = @blocks.select { |e| not e.insert.empty? }
    if inserts
      outlist = @data_new[lo .. hi].collect { |e| e.gsub(/^/, '  ') }
      inserts.each do |block|
        block.insert.each do |item|
          outlist[item.position - lo].gsub!(/^ /) { block.op } # + or !
        end
      end
      s << outlist.join("\n")
    end
    s
  end
# Create a hunk using references to both the old and new data, as well as
# the piece of data
Create a hunk using references to both the old and new data, as well as
the piece of data
Create a hunk using references to both the old and new data as well as the piece of data
def context_diff
    s = "***************\n"
    s << "*** #{context_range(:old)} ****\n"
    r = context_range(:new)
    lo, hi = @start_old, @end_old
    removes = @blocks.select { |e| not e.remove.empty? }
    if removes
      outlist = @data_old[lo .. hi].collect { |e| e.gsub(/^/, '  ') }
      removes.each do |block|
        block.remove.each do |item|
          outlist[item.position - lo].gsub!(/^ /) { block.op } 
        end
      end
      s << outlist.join("\n")
    end
    s << "\n--- #{r} ----\n"
    lo, hi = @start_new, @end_new
    inserts = @blocks.select { |e| not e.insert.empty? }
    if inserts
      outlist = @data_new[lo .. hi].collect { |e| e.gsub(/^/, '  ') }
      inserts.each do |block|
        block.insert.each do |item|
          outlist[item.position - lo].gsub!(/^ /) { block.op } 
        end
      end
      s << outlist.join("\n")
    end
    s
  end
def context_diff s = "***************\n" s << "*** #{context_range(:old)} ****\n" r = context_range ( :new ) lo , hi = @start_old , @end_old removes = @blocks . select { | e | not e . remove . empty? } if removes outlist = @data_old [ lo .. hi ] . collect { | e | e . gsub ( / ^ / , '  ' ) } removes . each do | block | block . remove . each do | item | outlist [ item . position - lo ] . gsub! ( / ^  / ) { block . op } end end s << outlist . join ( "\n" ) end s << "\n--- #{r} ----\n" lo , hi = @start_new , @end_new inserts = @blocks . select { | e | not e . insert . empty? } if inserts outlist = @data_new [ lo .. hi ] . collect { | e | e . gsub ( / ^ / , '  ' ) } inserts . each do | block | block . insert . each do | item | outlist [ item . position - lo ] . gsub! ( / ^  / ) { block . op } end end s << outlist . join ( "\n" ) end s end
Create a hunk using references to both the old and new data, as well as
the piece of data
Create a hunk using references to both the old and new data as well as the piece of data
# Print out file 1 part for each block in context diff format if there # are any blocks that remove items # - or ! # + or !