# File lib/puppet/util/diff.rb, line 20
20:     def lcs_diff(data_old, data_new, format=:unified, context_lines=3)
21:         unless Puppet.features.diff?
22:             Puppet.warning "Cannot provide diff without the diff/lcs Ruby library"
23:             return ""
24:         end
25:         data_old = data_old.split(/\n/).map! { |e| e.chomp }
26:         data_new = data_new.split(/\n/).map! { |e| e.chomp }
27: 
28:         output = ""
29: 
30:         diffs = ::Diff::LCS.diff(data_old, data_new)
31:         return output if diffs.empty?
32: 
33:         oldhunk = hunk = nil
34:         file_length_difference = 0
35: 
36:         diffs.each do |piece|
37:             begin
38:                 hunk = ::Diff::LCS::Hunk.new(data_old, data_new, piece,
39:                                            context_lines,
40:                                            file_length_difference)
41:                 file_length_difference = hunk.file_length_difference
42:             next unless oldhunk
43:             # Hunks may overlap, which is why we need to be careful when our
44:             # diff includes lines of context. Otherwise, we might print
45:             # redundant lines.
46:             if (context_lines > 0) and hunk.overlaps?(oldhunk)
47:                 hunk.unshift(oldhunk)
48:             else
49:                 output << oldhunk.diff(format)
50:             end
51:             ensure
52:                 oldhunk = hunk
53:                 output << "\n"
54:             end
55:         end
56: 
57:         # Handle the last remaining hunk
58:         output << oldhunk.diff(format) << "\n"
59:     end