Module: Filezor::Util

Extended by:
Util
Included in:
Server, Util
Defined in:
lib/filezor/util.rb

Constant Summary collapse

BUFFER_SIZE =
2**16

Instance Method Summary collapse

Instance Method Details

#files_from_map(map) ⇒ Object



16
17
18
19
20
# File 'lib/filezor/util.rb', line 16

def files_from_map(map)
  map.inject([]) do |memo, (path, value)|
    memo << Filezor::File.new(StringIO.new(value), path)
  end
end

#md5(io) ⇒ Object

Streaming MD5 on IO objects



7
8
9
10
11
12
13
14
# File 'lib/filezor/util.rb', line 7

def md5(io)
  md5 = Digest::MD5.new
  while chunk = io.read(BUFFER_SIZE)
    md5 << chunk
  end
  io.rewind
  md5.hexdigest
end