Class: Puppet::FileServing::Content
- Extended by:
- Indirector
- Defined in:
- lib/vendor/puppet/file_serving/content.rb
Overview
A class that handles retrieving file contents. It only reads the file when its content is specifically asked for.
Constant Summary
Constants included from Indirector
Instance Attribute Summary collapse
-
#content ⇒ Object
Read the content of our file in.
Attributes inherited from Base
#links, #path, #relative_path, #source
Class Method Summary collapse
Instance Method Summary collapse
-
#collect ⇒ Object
BF: we used to fetch the file content here, but this is counter-productive for puppetmaster streaming of file content.
- #to_raw ⇒ Object
Methods included from Indirector
Methods inherited from Base
absolute?, #exist?, #full_path, #initialize, #stat, #to_pson_data_hash
Constructor Details
This class inherits a constructor from Puppet::FileServing::Base
Instance Attribute Details
#content ⇒ Object
Read the content of our file in.
32 33 34 35 36 37 38 39 40 |
# File 'lib/vendor/puppet/file_serving/content.rb', line 32 def content unless @content # This stat can raise an exception, too. raise(ArgumentError, "Cannot read the contents of links unless following links") if stat.ftype == "symlink" @content = IO.binread(full_path) end @content end |
Class Method Details
.from_raw(content) ⇒ Object
18 19 20 21 22 |
# File 'lib/vendor/puppet/file_serving/content.rb', line 18 def self.from_raw(content) instance = new("/this/is/a/fake/path") instance.content = content instance end |
.supported_formats ⇒ Object
14 15 16 |
# File 'lib/vendor/puppet/file_serving/content.rb', line 14 def self.supported_formats [:raw] end |
Instance Method Details
#collect ⇒ Object
BF: we used to fetch the file content here, but this is counter-productive for puppetmaster streaming of file content. So collect just returns itself
26 27 28 29 |
# File 'lib/vendor/puppet/file_serving/content.rb', line 26 def collect return if stat.ftype == "directory" self end |