Method: Puppet::FileBucket::Dipper#diff
- Defined in:
- lib/puppet/file_bucket/dipper.rb
#diff(checksum_a, checksum_b, file_a, file_b) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Diffs two filebucket files identified by their sums
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/puppet/file_bucket/dipper.rb', line 61 def diff(checksum_a, checksum_b, file_a, file_b) raise RuntimeError, _("Diff is not supported on this platform") if Puppet[:diff] == "" if checksum_a source_path = "#{@rest_path}#{@checksum_type}/#{checksum_a}" if checksum_b file_diff = Puppet::FileBucket::File.indirection.find( source_path, :bucket_path => @local_path, :diff_with => checksum_b) elsif file_b tmp_file = ::Tempfile.new('diff') begin restore(tmp_file.path, checksum_a) file_diff = Puppet::Util::Diff.diff(tmp_file.path, file_b) ensure tmp_file.close tmp_file.unlink end else raise Puppet::Error, _("Please provide a file or checksum to diff with") end elsif file_a if checksum_b tmp_file = ::Tempfile.new('diff') begin restore(tmp_file.path, checksum_b) file_diff = Puppet::Util::Diff.diff(file_a, tmp_file.path) ensure tmp_file.close tmp_file.unlink end elsif file_b file_diff = Puppet::Util::Diff.diff(file_a, file_b) end end raise Puppet::Error, _("Failed to diff files") unless file_diff file_diff.to_s end |