Module: Checkm
- Defined in:
- lib/checkm.rb,
lib/checkm/entry.rb,
lib/checkm/version.rb,
lib/checkm/manifest.rb
Defined Under Namespace
Constant Summary collapse
- CHUNK_SIZE =
Size (in bytes) to read (in chunks) to compute checksums
8*1024*1024
- VERSION =
self.version
Class Method Summary collapse
-
.checksum(file, alg) ⇒ Object
Compute the checksum ‘alg’ for a file.
- .version ⇒ Object
Class Method Details
.checksum(file, alg) ⇒ Object
Compute the checksum ‘alg’ for a file
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/checkm.rb', line 14 def self.checksum file, alg digest_alg = case alg when nil return true when /md5/ Digest::MD5.new when /sha1/ Digest::SHA1.new when /sha256/ Digest::SHA2.new(256) 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 |
.version ⇒ Object
3 4 5 |
# File 'lib/checkm/version.rb', line 3 def self.version @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp end |