Sha256: 4fd490896067ed23921d94e925d230a5a674686a67954e5793a9f78693e44e4c

Contents?: true

Size: 897 Bytes

Versions: 75

Compression:

Stored size: 897 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 determining whether to replace a file's contents.

    The default checksum type 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

75 entries across 75 versions & 3 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/type/file/checksum.rb
puppet-3.2.0.rc1 lib/puppet/type/file/checksum.rb
puppet-parse-0.1.0 lib/vendor/puppet/type/file/checksum.rb
puppet-parse-0.0.6 lib/vendor/puppet/type/file/checksum.rb
puppet-2.7.21 lib/puppet/type/file/checksum.rb
puppet-3.1.1 lib/puppet/type/file/checksum.rb
puppet-parse-0.0.5 lib/vendor/puppet/type/file/checksum.rb
puppet-parse-0.0.4 lib/vendor/puppet/type/file/checksum.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/type/file/checksum.rb
puppet-3.1.0 lib/puppet/type/file/checksum.rb
puppet-3.1.0.rc2 lib/puppet/type/file/checksum.rb
puppet-3.1.0.rc1 lib/puppet/type/file/checksum.rb
puppet-3.0.2 lib/puppet/type/file/checksum.rb
puppet-3.0.2.rc3 lib/puppet/type/file/checksum.rb
puppet-3.0.2.rc2 lib/puppet/type/file/checksum.rb
puppet-3.0.2.rc1 lib/puppet/type/file/checksum.rb
puppet-parse-0.0.2 lib/vendor/puppet/type/file/checksum.rb
puppet-2.7.20 lib/puppet/type/file/checksum.rb
puppet-2.7.20.rc1 lib/puppet/type/file/checksum.rb
puppet-3.0.1 lib/puppet/type/file/checksum.rb