require "digest/md5" require "stringio" module Filezor::Util BUFFER_SIZE = 2**16 # Streaming MD5 on IO objects def md5(io) md5 = Digest::MD5.new while chunk = io.read(BUFFER_SIZE) md5 << chunk end io.rewind md5.hexdigest end def files_from_map(map) map.inject([]) do |memo, (path, value)| memo << Filezor::File.new(StringIO.new(value), path) end end extend self end