module PrettyDiff

This module is a namespace that holds everything

Public Class Methods

files(one, two, options = {}) click to toggle source

verify that files exist and then pass them off to PrettyFileDiff::Diff

# File lib/pretty-diff.rb, line 15
def self.files one, two, options = {}
  if File.file?(one) && File.file?(two)
    return Diff.new one, two, options
  else
    raise ArgumentError
  end
end
strings(one, two, options = {}) click to toggle source

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

# 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