class Grably::Digest::ProductDigest
Describes product state. If two digests for same file differs assume file changed
Attributes
md5[R]
mtime[R]
product[R]
size[R]
Public Class Methods
[](*products)
click to toggle source
# File lib/grably/core/digest.rb, line 37 def self.[](*products) products.map { |p| of_product(p) } end
new(product, mtime:, size:, md5:)
click to toggle source
# File lib/grably/core/digest.rb, line 13 def initialize(product, mtime:, size:, md5:) @product = product @mtime = mtime @size = size @md5 = md5 end
of_product(product)
click to toggle source
# File lib/grably/core/digest.rb, line 41 def self.of_product(product) product = Product.new(product) if product.is_a?(String) raise 'Expected string or Product got ' + product.inspect unless product.is_a? Product src = product.src raise 'File does not exist' unless File.exist? src ProductDigest.new( product, mtime: File.mtime(src), size: File.size(src), md5: ::Digest::MD5.hexdigest(IO.binread(src)) ) end
Public Instance Methods
==(other)
click to toggle source
# File lib/grably/core/digest.rb, line 24 def ==(other) [ product == other.product, mtime == other.mtime, size == other.size, md5 == other.md5 ].all? end
eql?(other)
click to toggle source
# File lib/grably/core/digest.rb, line 20 def eql?(other) self == other end
hash()
click to toggle source
# File lib/grably/core/digest.rb, line 33 def hash md5.to_i end