Sha256: a6a980ef2f0b33d8716697553928b17040bdbfe732b6728aaa75fa67c69bf6d0

Contents?: true

Size: 900 Bytes

Versions: 32

Compression:

Stored size: 900 Bytes

Contents

require 'puppet/util/checksums'

# Specify which checksum algorithm to use when checksumming
# files.
Puppet::Type.type(:file).newparam(:checksum) do
  include Puppet::Util::Checksums

  desc "The checksum type to use when checksumming a file.

    The default checksum parameter, if checksums are enabled, is md5."

  newvalues "md5", "md5lite", "mtime", "ctime", "none"

  defaultto :md5

  def sum(content)
    type = value || :md5 # because this might be called before defaults are set
    "{#{type}}" + send(type, content)
  end

  def sum_file(path)
    type = value || :md5 # because this might be called before defaults are set
    method = type.to_s + "_file"
    "{#{type}}" + send(method, path).to_s
  end

  def sum_stream(&block)
    type = value || :md5 # same comment as above
    method = type.to_s + "_stream"
    checksum = send(method, &block)
    "{#{type}}#{checksum}"
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
puppet-2.6.18 lib/puppet/type/file/checksum.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
puppet-2.6.17 lib/puppet/type/file/checksum.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
puppet-2.6.16 lib/puppet/type/file/checksum.rb
puppet-2.6.15 lib/puppet/type/file/checksum.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
puppet-2.7.11 lib/puppet/type/file/checksum.rb
puppet-2.6.14 lib/puppet/type/file/checksum.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/type/file/checksum.rb
puppet-2.6.13 lib/puppet/type/file/checksum.rb
puppet-2.7.9 lib/puppet/type/file/checksum.rb
puppet-2.7.8 lib/puppet/type/file/checksum.rb
puppet-2.7.6 lib/puppet/type/file/checksum.rb