class Puppet::FileBucket::File

Attributes

bucket_path[R]
contents[R]

Public Class Methods

from_pson(pson) click to toggle source
# File lib/puppet/file_bucket/file.rb, line 52
def self.from_pson(pson)
  self.new(pson["contents"])
end
from_s(contents) click to toggle source
# File lib/puppet/file_bucket/file.rb, line 44
def self.from_s(contents)
  self.new(contents)
end
new(contents, options = {}) click to toggle source
# File lib/puppet/file_bucket/file.rb, line 16
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

Public Instance Methods

checksum() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 28
def checksum
  "{#{checksum_type}}#{checksum_data}"
end
checksum_data() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 32
def checksum_data
  @checksum_data ||= Digest::MD5.hexdigest(contents)
end
checksum_type() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 24
def checksum_type
  'md5'
end
name() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 40
def name
  "#{checksum_type}/#{checksum_data}"
end
to_pson() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 48
def to_pson
  { "contents" => contents }.to_pson
end
to_s() click to toggle source
# File lib/puppet/file_bucket/file.rb, line 36
def to_s
  contents
end