Sha256: d6d8198cd110238ab71cf538efd1e27fcfc0b2fd9b0955b5deb0eb1e77b52a1f

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 KB

Contents

# Copyright (c) 2013-2015 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].files.find { |f| f.name == path }
    file2 = description2[scope].files.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

14 entries across 14 versions & 1 rubygems

Version Path
machinery-tool-1.16.4 lib/file_diff.rb
machinery-tool-1.16.3 lib/file_diff.rb
machinery-tool-1.16.2 lib/file_diff.rb
machinery-tool-1.16.1 lib/file_diff.rb
machinery-tool-1.16.0 lib/file_diff.rb
machinery-tool-1.15.0 lib/file_diff.rb
machinery-tool-1.14.2 lib/file_diff.rb
machinery-tool-1.14.1 lib/file_diff.rb
machinery-tool-1.14.0 lib/file_diff.rb
machinery-tool-1.13.0 lib/file_diff.rb
machinery-tool-1.12.0 lib/file_diff.rb
machinery-tool-1.11.2 lib/file_diff.rb
machinery-tool-1.11.1 lib/file_diff.rb
machinery-tool-1.11.0 lib/file_diff.rb