Sha256: dd2c7e92a00d7a08b1d6f9173620d7f98e0be90310906424bfcf1008ce945308

Contents?: true

Size: 1.43 KB

Versions: 21

Compression:

Stored size: 1.43 KB

Contents

require 'puppet/file_bucket'
require 'puppet/indirector'
require 'puppet/util/checksums'
require 'digest/md5'

class Puppet::FileBucket::File
  # This class handles the abstract notion of a file in a filebucket.
  # There are mechanisms to save and load this file locally and remotely in puppet/indirector/filebucketfile/*
  # There is a compatibility class that emulates pre-indirector filebuckets in Puppet::FileBucket::Dipper
  extend Puppet::Indirector
  require 'puppet/file_bucket/file/indirection_hooks'
  indirects :file_bucket_file, :terminus_class => :file, :extend => Puppet::FileBucket::File::IndirectionHooks

  attr :contents
  attr :bucket_path

  def initialize( contents, options = {} )
    raise ArgumentError.new("contents must be a String, got a #{contents.class}") unless contents.is_a?(String)
    @contents = contents

    @bucket_path = options.delete(:bucket_path)
    raise ArgumentError.new("Unknown option(s): #{options.keys.join(', ')}") unless options.empty?
  end

  def checksum_type
    'md5'
  end

  def checksum
    "{#{checksum_type}}#{checksum_data}"
  end

  def checksum_data
    @checksum_data ||= Digest::MD5.hexdigest(contents)
  end

  def to_s
    contents
  end

  def name
    "#{checksum_type}/#{checksum_data}"
  end

  def self.from_s( contents )
    self.new( contents )
  end

  def to_pson
    { "contents" => contents }.to_pson
  end

  def self.from_pson( pson )
    self.new( pson["contents"] )
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
puppet-2.7.17 lib/puppet/file_bucket/file.rb
puppet-2.7.16 lib/puppet/file_bucket/file.rb
puppet-2.7.14 lib/puppet/file_bucket/file.rb
puppet-2.7.13 lib/puppet/file_bucket/file.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
puppet-2.7.12 lib/puppet/file_bucket/file.rb
puppet-2.7.11 lib/puppet/file_bucket/file.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/file_bucket/file.rb
puppet-2.7.9 lib/puppet/file_bucket/file.rb
puppet-2.7.8 lib/puppet/file_bucket/file.rb
puppet-2.7.6 lib/puppet/file_bucket/file.rb
puppet-2.7.5 lib/puppet/file_bucket/file.rb