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
16 def initialize(path)
17   @path = Pathname.new(path)
18 end

Public Instance Methods

checksum(pathname) click to toggle source

Return checksum for the Pathname.

   # File lib/puppet/module_tool/checksums.rb
21 def checksum(pathname)
22   return Digest::MD5.hexdigest(Puppet::FileSystem.binread(pathname))
23 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
27 def data
28   unless @data
29     @data = {}
30     @path.find do |descendant|
31       if Puppet::ModuleTool.artifact?(descendant)
32         Find.prune
33       elsif descendant.file?
34         path = descendant.relative_path_from(@path)
35         @data[path.to_s] = checksum(descendant)
36       end
37     end
38   end
39   return @data
40 end
Also aliased as: to_data_hash, to_hash
each(&block) click to toggle source

TODO: Why?

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