class Puppet::ModuleTool::Checksums

Checksums

This class proides 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, line 15
def initialize(path)
  @path = Pathname.new(path)
end

Public Instance Methods

checksum(pathname) click to toggle source

Return checksum for the Pathname.

# File lib/puppet/module_tool/checksums.rb, line 20
def checksum(pathname)
  return Digest::MD5.hexdigest(Puppet::FileSystem.binread(pathname))
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, line 26
def data
  unless @data
    @data = {}
    @path.find do |descendant|
      if Puppet::ModuleTool.artifact?(descendant)
        Find.prune
      elsif descendant.file?
        path = descendant.relative_path_from(@path)
        @data[path.to_s] = checksum(descendant)
      end
    end
  end
  return @data
end
Also aliased as: to_data_hash, to_hash
each(&block) click to toggle source

TODO: Why?

# File lib/puppet/module_tool/checksums.rb, line 45
def each(&block)
  data.each(&block)
end
to_data_hash() click to toggle source
Alias for: data
to_hash() click to toggle source
Alias for: data