Sha256: e469b3db90989963ce49d5b4759009008f56385b6efc3eb326a057fb45d67538

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

# Copyright (c) 2013-2016 SUSE LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact SUSE LLC.
#
# To contact SUSE about this file by physical or electronic mail,
# you may find current contact information at www.suse.com

class FileDiff
  def self.diff(description1, description2, scope, path)
    return nil if !description1.scope_extracted?(scope) || !description2.scope_extracted?(scope)

    file1 = description1[scope].find { |f| f.name == path }
    file2 = description2[scope].find { |f| f.name == path }
    return nil if !file1 || !file2

    if file1.binary? || file2.binary?
      raise Machinery::Errors::BinaryDiffError, "Can't diff binary files"
    end

    Diffy::Diff.new(file1.content, file2.content, include_plus_and_minus_in_html: true)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
machinery-tool-1.22.1 lib/file_diff.rb
machinery-tool-1.22.0 lib/file_diff.rb
machinery-tool-1.21.0 lib/file_diff.rb
machinery-tool-1.20.0 lib/file_diff.rb
machinery-tool-1.19.0 lib/file_diff.rb
machinery-tool-1.18.0 lib/file_diff.rb