diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-17 11:44:37 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-17 11:44:37 -0500 |
commit | 8bf519681f3c464f87b853a1e9b07743fa26bace (patch) | |
tree | 8286a03df52f8d4b9e407d96320fa62397492efb /lib/puppet | |
parent | d0bd48cc50cf90440429569e748877ab6e23491f (diff) | |
download | puppet-8bf519681f3c464f87b853a1e9b07743fa26bace.tar.gz puppet-8bf519681f3c464f87b853a1e9b07743fa26bace.tar.xz puppet-8bf519681f3c464f87b853a1e9b07743fa26bace.zip |
Oops, forgot this file in my last commit.
I moved the checksum code to a separate module.
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/checksum.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/puppet/checksum.rb b/lib/puppet/checksum.rb index c607953c1..27f08aa99 100644 --- a/lib/puppet/checksum.rb +++ b/lib/puppet/checksum.rb @@ -3,11 +3,14 @@ # Copyright (c) 2007. All rights reserved. require 'puppet' +require 'puppet/util/checksums' require 'puppet/indirector' # A checksum class to model translating checksums to file paths. This # is the new filebucket. class Puppet::Checksum + include Puppet::Util::Checksums + extend Puppet::Indirector indirects :checksum @@ -27,25 +30,20 @@ class Puppet::Checksum # Calculate (if necessary) and return the checksum def checksum unless @checksum - @checksum = send(algorithm) + @checksum = send(algorithm, content) end @checksum end - def initialize(content, algorithm = nil) + def initialize(content, algorithm = "md5") raise ArgumentError.new("You must specify the content") unless content @content = content - self.algorithm = algorithm || "md5" # Init to avoid warnings. @checksum = nil - end - # This can't be private, else respond_to? returns false. - def md5 - require 'digest/md5' - Digest::MD5.hexdigest(content) + self.algorithm = algorithm end # This is here so the Indirector::File terminus works correctly. @@ -53,11 +51,6 @@ class Puppet::Checksum checksum end - def sha1 - require 'digest/sha1' - Digest::SHA1.hexdigest(content) - end - def to_s "Checksum<{%s}%s>" % [algorithm, checksum] end |