blob: 571cc4557f11104311332e7886981c170e776070 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
require 'chef/mixin/shell_out'
class Chef
# Generates file diffs.
#--
# TODO/BUG:
# This is a quick hack. The final implementation should do the following:
# * Support a max file size above which diffs won't be attempted.
# * Support a max diff size above which results will be thrown out.
# * implement diffs in a way that will be performant and not depend on the diff(1) program.
# Xdiff looks pretty hot for this: http://XMailServer.Org/xdiff.html
class Diff
include Mixin::ShellOut
def initialize(old_file_path, new_file_path)
@old_file_path, @new_file_path = old_file_path, new_file_path
end
def diff
shell_out!("diff -N -U 3 #{@old_file_path} #{@new_file_path}", :returns => [0,1]).stdout
end
end
end
|