Module: Stacker::Differ

Defined in:
lib/stacker/differ.rb

Class Method Summary collapse

Class Method Details

.diff(one, two, *args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stacker/differ.rb', line 9

def diff one, two, *args
  down = args.include? :down

  diff = Diffy::Diff.new(
    (down ? one : two) + "\n",
    (down ? two : one) + "\n",
    context: 3,
    include_diff_info: true
  ).to_s(*args.select { |arg| arg == :color })

  diff.gsub(/^(\x1B.+)?(\-{3}|\+{3}).+\n/, '').strip
end

.json_diff(one, two, *args) ⇒ Object



22
23
24
# File 'lib/stacker/differ.rb', line 22

def json_diff one, two, *args
  diff JSON.pretty_generate(one), JSON.pretty_generate(two), *args
end

.yaml_diff(one, two, *args) ⇒ Object



26
27
28
# File 'lib/stacker/differ.rb', line 26

def yaml_diff one, two, *args
  diff YAML.dump(one), YAML.dump(two), *args
end