A class that handles retrieving file contents. It only reads the file when its content is specifically asked for.
# File lib/puppet/file_serving/content.rb, line 18 def self.from_raw(content) instance = new("/this/is/a/fake/path") instance.content = content instance end
# File lib/puppet/file_serving/content.rb, line 14 def self.supported_formats [:raw] end
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
# File lib/puppet/file_serving/content.rb, line 26 def collect return if stat.ftype == "directory" self end
Read the content of our file in.
# 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 = IO.binread(full_path) end @content end
# File lib/puppet/file_serving/content.rb, line 42 def to_raw File.new(full_path, "rb") end