Sha256: eaa94df72351c60ad36a4b78ba1dd8f04ddaa07f1209b86769c1b45108165304
Contents?: true
Size: 1.34 KB
Versions: 16
Compression:
Stored size: 1.34 KB
Contents
# # Created by Luke Kanies on 2007-9-22. # 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 attr_reader :algorithm, :content def algorithm=(value) unless respond_to?(value) raise ArgumentError, "Checksum algorithm %s is not supported" % value end value = value.intern if value.is_a?(String) @algorithm = value # Reset the checksum so it's forced to be recalculated. @checksum = nil end # Calculate (if necessary) and return the checksum def checksum unless @checksum @checksum = send(algorithm, content) end @checksum end def initialize(content, algorithm = "md5") raise ArgumentError.new("You must specify the content") unless content @content = content # Init to avoid warnings. @checksum = nil self.algorithm = algorithm end # This is here so the Indirector::File terminus works correctly. def name checksum end def to_s "Checksum<{%s}%s>" % [algorithm, checksum] end end
Version data entries
16 entries across 16 versions & 1 rubygems