Class: Puppet::FileServing::Content

Inherits:
Base show all
Extended by:
Indirector
Defined in:
lib/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

Indirector::BadNameRegexp

Instance Attribute Summary collapse

Attributes inherited from Base

#links, #path, #relative_path, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Indirector

configure_routes, indirects

Methods inherited from Base

absolute?, #exist?, #full_path, #initialize, #stat, #to_data_hash

Constructor Details

This class inherits a constructor from Puppet::FileServing::Base

Instance Attribute Details

#contentObject

Read the content of our file in.



32
33
34
35
36
37
38
39
40
# File 'lib/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 = Puppet::FileSystem.binread(full_path)
  end
  @content
end

Class Method Details

.from_binary(content) ⇒ Object



20
21
22
23
24
# File 'lib/puppet/file_serving/content.rb', line 20

def self.from_binary(content)
  instance = new("/this/is/a/fake/path")
  instance.content = content
  instance
end

.supported_formatsObject



16
17
18
# File 'lib/puppet/file_serving/content.rb', line 16

def self.supported_formats
  [:binary]
end

Instance Method Details

#collect(source_permissions = nil) ⇒ Object

This is no longer used, but is still called by the file server implementations when interacting with their model abstraction.



28
29
# File 'lib/puppet/file_serving/content.rb', line 28

def collect(source_permissions = nil)
end

#to_binaryObject



42
43
44
# File 'lib/puppet/file_serving/content.rb', line 42

def to_binary
  File.new(full_path, "rb")
end