class Puppet::ModuleTool::Checksums

Checksums

This class provides methods for generating checksums for data and adding them to Metadata.

Public Class Methods

new(path) click to toggle source

Instantiate object with string path to create checksums from.

   # File lib/puppet/module_tool/checksums.rb
15 def initialize(path)
16   @path = Pathname.new(path)
17 end

Public Instance Methods

checksum(pathname) click to toggle source

Return checksum for the Pathname.

   # File lib/puppet/module_tool/checksums.rb
20 def checksum(pathname)
21   return Digest::MD5.hexdigest(Puppet::FileSystem.binread(pathname))
22 end
data() click to toggle source

Return checksums for object's Pathname, generate if it's needed. Result is a hash of path strings to checksum strings.

   # File lib/puppet/module_tool/checksums.rb
26 def data
27   unless @data
28     @data = {}
29     @path.find do |descendant|
30       if Puppet::ModuleTool.artifact?(descendant)
31         Find.prune
32       elsif descendant.file?
33         path = descendant.relative_path_from(@path)
34         @data[path.to_s] = checksum(descendant)
35       end
36     end
37   end
38   return @data
39 end
Also aliased as: to_data_hash, to_hash
each(&block) click to toggle source

TODO: Why?

   # File lib/puppet/module_tool/checksums.rb
45 def each(&block)
46   data.each(&block)
47 end
to_data_hash()
Alias for: data
to_hash()
Alias for: data