Sha256: 5ce026e425c9cdad1289cb601a76d55378ce3c6b1e9e84f1235cebbd5ed8e26c
Contents?: true
Size: 784 Bytes
Versions: 5
Compression:
Stored size: 784 Bytes
Contents
# encoding: utf-8 require 'digest/md5' # this class handles file checksums class EasyHtmlGenerator::Checksum @file_checksums = {} def self.checksum(input) Digest::MD5.hexdigest(input) end def self.file_checksum(file) checksum(File.read(file)) end def self.file_changed?(file, context = '') key = build_key(file, context) return true unless @file_checksums.key? key @file_checksums[key] != file_checksum(file) end def self.store_file(file, context = '') key = build_key(file, context) @file_checksums[key] = file_checksum(file) end def self.invalidate_file(file, context = '') key = build_key(file, context) @file_checksums.delete(key) end def self.build_key(file, context = '') "#{context}.#{file}" end end
Version data entries
5 entries across 5 versions & 1 rubygems