In Files

  • test-unit-3.3.4/lib/test/unit/diff.rb

Class/Module Index [+]

Quicksearch

Test::Unit::Diff

Public Instance Methods

diff(differ_class, from, to, options={}) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 725
def diff(differ_class, from, to, options={})
  if from.respond_to?(:valid_encoding?) and not from.valid_encoding?
    from = from.dup.force_encoding("ASCII-8BIT")
  end
  if to.respond_to?(:valid_encoding?) and not to.valid_encoding?
    to = to.dup.force_encoding("ASCII-8BIT")
  end
  differ = differ_class.new(from.split(/\r?\n/), to.split(/\r?\n/))
  lines = differ.diff(options)
  if Object.const_defined?(:EncodingError)
    begin
      lines.join("\n")
    rescue EncodingError
      lines.collect {|line| line.force_encoding("ASCII-8BIT")}.join("\n")
    end
  else
    lines.join("\n")
  end
end
            
fold(string) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 707
def fold(string)
  string.split(/\r?\n/).collect do |line|
    line.gsub(/(.{78})/, "\\1\n")
  end.join("\n")
end
            
folded_readable(from, to, options={}) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 713
def folded_readable(from, to, options={})
  readable(fold(from), fold(to), options)
end
            
need_fold?(diff) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 703
def need_fold?(diff)
  /^[-+].{79}/ =~ diff
end
            
readable(from, to, options={}) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 717
def readable(from, to, options={})
  diff(ReadableDiffer, from, to, options)
end
            
unified(from, to, options={}) click to toggle source
 
               # File test-unit-3.3.4/lib/test/unit/diff.rb, line 721
def unified(from, to, options={})
  diff(UnifiedDiffer, from, to, options)
end