Method: PrettyDiff.strings

Defined in:
lib/pretty-diff.rb

.strings(one, two, options = {}) ⇒ Object

makes temporary files from the strings so that the diff command can do its work, passes off to PrettyFileDiff::Diff, and then deletes the temproary files



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pretty-diff.rb', line 26

def self.strings one, two, options = {}
  require 'tempfile'

  file_one = Tempfile.new('fileone')
  file_two = Tempfile.new('filetwo')
  file_one.write(one)
  file_two.write(two)
  file_one.close
  file_two.close

  diff = Diff.new file_one.path, file_two.path, options

  file_one.unlink
  file_two.unlink

  return diff
end