Sha256: 64017cb0e924f5b2733317f3766fc76177eb0fea293d523f1b4f7405414f328a
Contents?: true
Size: 1015 Bytes
Versions: 4
Compression:
Stored size: 1015 Bytes
Contents
module ContentfulMiddleman class VersionHash class << self def source_root=(source_root) @source_root = source_root end def read_for_space(space_name) hashfilename_for_space = hashfilename(space_name) ::File.read(hashfilename_for_space) if File.exist? hashfilename_for_space end def write_for_space_with_entries(space_name, entries, use_camel_case = false) updated_at_key = use_camel_case ? :updatedAt : :updated_at sorted_entries = entries.sort {|a, b| a.id <=> b.id} ids_and_revisions_string = sorted_entries.map {|e| "#{e.id}#{e.public_send(updated_at_key)}"}.join entries_hash = Digest::SHA1.hexdigest( ids_and_revisions_string ) File.open(hashfilename(space_name), 'w') { |file| file.write(entries_hash) } entries_hash end private def hashfilename(space_name) ::File.join(@source_root, ".#{space_name}-space-hash") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems