Class: Puppet::FileBucket::File Private
- Extended by:
- Indirector
- Defined in:
- lib/puppet/file_bucket/file.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: FileContents, StringContents
Constant Summary
Constants included from Indirector
Instance Attribute Summary collapse
- #bucket_path ⇒ Object readonly private
Class Method Summary collapse
- .from_binary(contents) ⇒ Object private
- .supported_formats ⇒ Object private
Instance Method Summary collapse
- #checksum ⇒ Object private
- #checksum_data ⇒ Object private
- #checksum_type ⇒ Object private
- #contents ⇒ Object private
-
#initialize(contents, options = {}) ⇒ File
constructor
private
A new instance of File.
- #name ⇒ Object private
-
#size ⇒ Num
private
The size of the contents.
-
#stream(&block) ⇒ IO
private
A stream that reads the contents.
- #to_binary ⇒ Object private
- #to_s ⇒ Object private
Methods included from Indirector
Constructor Details
#initialize(contents, options = {}) ⇒ File
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of File.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/file_bucket/file.rb', line 22 def initialize(contents, = {}) case contents when String @contents = StringContents.new(contents) when Pathname @contents = FileContents.new(contents) else raise ArgumentError, _("contents must be a String or Pathname, got a %{contents_class}") % { contents_class: contents.class } end @bucket_path = .delete(:bucket_path) @checksum_type = Puppet[:digest_algorithm].to_sym raise ArgumentError, _("Unknown option(s): %{opts}") % { opts: .keys.join(', ') } unless .empty? end |
Instance Attribute Details
#bucket_path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/puppet/file_bucket/file.rb', line 16 def bucket_path @bucket_path end |
Class Method Details
.from_binary(contents) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 |
# File 'lib/puppet/file_bucket/file.rb', line 75 def self.from_binary(contents) new(contents) end |
.supported_formats ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/puppet/file_bucket/file.rb', line 18 def self.supported_formats [:binary] end |
Instance Method Details
#checksum ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/puppet/file_bucket/file.rb', line 51 def checksum "{#{checksum_type}}#{checksum_data}" end |
#checksum_data ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/puppet/file_bucket/file.rb', line 55 def checksum_data @checksum_data ||= @contents.checksum_data(@checksum_type) end |
#checksum_type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/puppet/file_bucket/file.rb', line 47 def checksum_type @checksum_type.to_s end |
#contents ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/puppet/file_bucket/file.rb', line 67 def contents to_binary end |
#name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 |
# File 'lib/puppet/file_bucket/file.rb', line 71 def name "#{checksum_type}/#{checksum_data}" end |
#size ⇒ Num
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The size of the contents.
38 39 40 |
# File 'lib/puppet/file_bucket/file.rb', line 38 def size @contents.size() end |
#stream(&block) ⇒ IO
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns A stream that reads the contents.
43 44 45 |
# File 'lib/puppet/file_bucket/file.rb', line 43 def stream(&block) @contents.stream(&block) end |
#to_binary ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/puppet/file_bucket/file.rb', line 63 def to_binary @contents.to_binary end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/puppet/file_bucket/file.rb', line 59 def to_s to_binary end |