Class: Rake::Delphi::HashTask

Inherits:
BasicTask show all
Defined in:
lib/rake/common/hashtask.rb

Instance Method Summary collapse

Methods inherited from BasicTask

#trace?

Constructor Details

#initialize(file, alg) ⇒ HashTask

Returns a new instance of HashTask.



9
10
11
12
# File 'lib/rake/common/hashtask.rb', line 9

def initialize(file, alg)
    @file = file
    @alg = alg
end

Instance Method Details

#digestObject



14
15
16
17
18
19
20
21
# File 'lib/rake/common/hashtask.rb', line 14

def digest
    if ['md5', 'sha1'].include?(@alg)
        require 'digest/' + @alg
        return eval("Digest::#{@alg.upcase}.file(@file).hexdigest.upcase")
    else
        return "%02X" % Digest::CRC32.file(@file).digest.to_i
    end
end