class Puppet::FileBucket::File

Attributes

bucket_path[R]

Public Class Methods

from_binary(contents) click to toggle source
   # File lib/puppet/file_bucket/file.rb
74 def self.from_binary(contents)
75   self.new(contents)
76 end
new(contents, options = {}) click to toggle source
   # File lib/puppet/file_bucket/file.rb
21 def initialize(contents, options = {})
22   case contents
23   when String
24     @contents = StringContents.new(contents)
25   when Pathname
26     @contents = FileContents.new(contents)
27   else
28     raise ArgumentError.new(_("contents must be a String or Pathname, got a %{contents_class}") % { contents_class: contents.class })
29   end
30 
31   @bucket_path = options.delete(:bucket_path)
32   @checksum_type = Puppet[:digest_algorithm].to_sym
33   raise ArgumentError.new(_("Unknown option(s): %{opts}") % { opts: options.keys.join(', ') }) unless options.empty?
34 end
supported_formats() click to toggle source
   # File lib/puppet/file_bucket/file.rb
17 def self.supported_formats
18   [:binary]
19 end

Public Instance Methods

checksum() click to toggle source
   # File lib/puppet/file_bucket/file.rb
50 def checksum
51   "{#{checksum_type}}#{checksum_data}"
52 end
checksum_data() click to toggle source
   # File lib/puppet/file_bucket/file.rb
54 def checksum_data
55   @checksum_data ||= @contents.checksum_data(@checksum_type)
56 end
checksum_type() click to toggle source
   # File lib/puppet/file_bucket/file.rb
46 def checksum_type
47   @checksum_type.to_s
48 end
contents() click to toggle source
   # File lib/puppet/file_bucket/file.rb
66 def contents
67   to_binary
68 end
name() click to toggle source
   # File lib/puppet/file_bucket/file.rb
70 def name
71   "#{checksum_type}/#{checksum_data}"
72 end
size() click to toggle source

@return [Num] The size of the contents

   # File lib/puppet/file_bucket/file.rb
37 def size
38   @contents.size()
39 end
stream(&block) click to toggle source

@return [IO] A stream that reads the contents

   # File lib/puppet/file_bucket/file.rb
42 def stream(&block)
43   @contents.stream(&block)
44 end
to_binary() click to toggle source
   # File lib/puppet/file_bucket/file.rb
62 def to_binary
63   @contents.to_binary
64 end
to_s() click to toggle source
   # File lib/puppet/file_bucket/file.rb
58 def to_s
59   to_binary
60 end