Class: Kelbim::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/kelbim/utils.rb

Defined Under Namespace

Modules: Helper

Class Method Summary collapse

Class Method Details

.diff(obj1, obj2, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kelbim/utils.rb', line 20

def diff(obj1, obj2, options = {})
  diffy = Diffy::Diff.new(
    obj1.pretty_inspect,
    obj2.pretty_inspect,
    :diff => '-u'
  )

  out = diffy.to_s(options[:color] ? :color : :text).gsub(/\s+\z/m, '')
  out.gsub!(/^/, options[:indent]) if options[:indent]
  out
end