Module: Checkm
- Defined in:
- lib/checkm.rb
Defined Under Namespace
Constant Summary collapse
- CHUNK_SIZE =
8*1024*1024
Class Method Summary collapse
Class Method Details
.checksum(file, alg) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/checkm.rb', line 5 def self.checksum file, alg digest_alg = case alg when nil return true when /md5/ Digest::MD5.new if alg == 'md5' when /sha1/ when /sha256/ when /dir/ return File.directory? file else return false end while not file.eof? and chunk = file.readpartial(CHUNK_SIZE) digest_alg << chunk end digest_alg.hexdigest end |