Sha256: 426c1277783402ca0e5ee6539b765c039de85e2d41c4c7ed074430ea56575b70
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require "giff/gem_file" module Giff class Diff def initialize(file_a, file_b) @gem_a = to_file(file_a) @gem_b = to_file(file_b) end def describe if files_changed? data_a = @gem_a.data.contents data_b = @gem_b.data.contents keys = (data_a.keys + data_b.keys).sort.uniq keys.each do |key| if !data_a.key?(key) STDERR.puts "#{key} was removed" elsif !data_b.key?(key) STDERR.puts "#{key} was added" elsif data_a[key] != data_b[key] STDERR.puts "#{key} was modified" end end elsif metadata_changed? STDERR.puts "files equal but metadata changed" else STDERR.puts "files and metadata equal" end end def files_changed? @gem_a.data.contents != @gem_b.data.contents end def metadata_changed? @gem_a.metadata.contents != @gem_b.metadata.contents end private def to_file(file) file = File.open(file) if file.is_a?(String) if file.respond_to?(:read) # probably a file or IO Giff::GemFile.new(file) else raise ArgumentError, "#{file.inspect} isn't a file" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
giff-0.1.2 | lib/giff/diff.rb |