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 73 def self.from_binary(contents) 74 self.new(contents) 75 end
new(contents, options = {})
click to toggle source
# File lib/puppet/file_bucket/file.rb 20 def initialize(contents, options = {}) 21 case contents 22 when String 23 @contents = StringContents.new(contents) 24 when Pathname 25 @contents = FileContents.new(contents) 26 else 27 raise ArgumentError.new(_("contents must be a String or Pathname, got a %{contents_class}") % { contents_class: contents.class }) 28 end 29 30 @bucket_path = options.delete(:bucket_path) 31 @checksum_type = Puppet[:digest_algorithm].to_sym 32 raise ArgumentError.new(_("Unknown option(s): %{opts}") % { opts: options.keys.join(', ') }) unless options.empty? 33 end
supported_formats()
click to toggle source
# File lib/puppet/file_bucket/file.rb 16 def self.supported_formats 17 [:binary] 18 end
Public Instance Methods
checksum()
click to toggle source
# File lib/puppet/file_bucket/file.rb 49 def checksum 50 "{#{checksum_type}}#{checksum_data}" 51 end
checksum_data()
click to toggle source
# File lib/puppet/file_bucket/file.rb 53 def checksum_data 54 @checksum_data ||= @contents.checksum_data(@checksum_type) 55 end
checksum_type()
click to toggle source
# File lib/puppet/file_bucket/file.rb 45 def checksum_type 46 @checksum_type.to_s 47 end
contents()
click to toggle source
# File lib/puppet/file_bucket/file.rb 65 def contents 66 to_binary 67 end
name()
click to toggle source
# File lib/puppet/file_bucket/file.rb 69 def name 70 "#{checksum_type}/#{checksum_data}" 71 end
size()
click to toggle source
@return [Num] The size of the contents
# File lib/puppet/file_bucket/file.rb 36 def size 37 @contents.size() 38 end
stream(&block)
click to toggle source
@return [IO] A stream that reads the contents
# File lib/puppet/file_bucket/file.rb 41 def stream(&block) 42 @contents.stream(&block) 43 end
to_binary()
click to toggle source
# File lib/puppet/file_bucket/file.rb 61 def to_binary 62 @contents.to_binary 63 end
to_s()
click to toggle source
# File lib/puppet/file_bucket/file.rb 57 def to_s 58 to_binary 59 end