Class Puppet::Checksum
In: lib/puppet/checksum.rb
Parent: Object

A checksum class to model translating checksums to file paths. This is the new filebucket.

Methods

algorithm=   checksum   name   new   to_s  

Included Modules

Puppet::Util::Checksums

Classes and Modules

Class Puppet::Checksum::File

Attributes

algorithm  [R] 
content  [R] 

Public Class methods

[Source]

    # File lib/puppet/checksum.rb, line 38
38:     def initialize(content, algorithm = "md5")
39:         raise ArgumentError.new("You must specify the content") unless content
40: 
41:         @content = content
42: 
43:         # Init to avoid warnings.
44:         @checksum = nil
45: 
46:         self.algorithm = algorithm
47:     end

Public Instance methods

[Source]

    # File lib/puppet/checksum.rb, line 20
20:     def algorithm=(value)
21:         unless respond_to?(value)
22:             raise ArgumentError, "Checksum algorithm %s is not supported" % value
23:         end
24:         value = value.intern if value.is_a?(String)
25:         @algorithm = value
26:         # Reset the checksum so it's forced to be recalculated.
27:         @checksum = nil
28:     end

Calculate (if necessary) and return the checksum

[Source]

    # File lib/puppet/checksum.rb, line 31
31:     def checksum
32:         unless @checksum
33:             @checksum = send(algorithm, content)
34:         end
35:         @checksum
36:     end

This is here so the Indirector::File terminus works correctly.

[Source]

    # File lib/puppet/checksum.rb, line 50
50:     def name
51:         checksum
52:     end

[Source]

    # File lib/puppet/checksum.rb, line 54
54:     def to_s
55:         "Checksum<{%s}%s>" % [algorithm, checksum]
56:     end

[Validate]