class Puppet::FileSystem::MemoryFile

An in-memory file abstraction. Commonly used with Puppet::FileSystem::File#overlay @api private

Attributes

children[R]
path[R]

Public Instance Methods

absolute?() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 51
def absolute?
  Pathname.new(path).absolute?
end
directory?() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 34
def directory?; @properties[:directory?]; end
duplicate_as(other_path) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 47
def duplicate_as(other_path)
  self.class.new(other_path, @properties)
end
each_line(&block) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 38
def each_line(&block)
  handle.each_line(&block)
end
executable?() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 36
def executable?; @properties[:executable?]; end
exist?() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 35
def exist?; @properties[:exist?]; end
handle() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 42
def handle
  raise Errno::ENOENT unless exist?
  StringIO.new(@properties[:content] || '')
end
inspect() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 68
def inspect
  "<Puppet::FileSystem::MemoryFile:#{to_s}>"
end
to_path() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 55
def to_path
  path
end
to_s() click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 59
def to_s
  to_path
end
to_str() click to toggle source

Used by Ruby 1.8.7 file system abstractions when operating on Pathname like things.

# File lib/puppet/file_system/memory_file.rb, line 64
def to_str
  to_path
end

Public Class Methods

a_directory(path, children = []) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 18
def self.a_directory(path, children = [])
  new(path,
      :exist? => true,
      :excutable? => true,
      :directory? => true,
      :children => children)
end
a_missing_file(path) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 6
def self.a_missing_file(path)
  new(path, :exist? => false, :executable? => false)
end
a_regular_file_containing(path, content) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 10
def self.a_regular_file_containing(path, content)
  new(path, :exist? => true, :executable? => false, :content => content)
end
an_executable(path) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 14
def self.an_executable(path)
  new(path, :exist? => true, :executable? => true)
end
new(path, properties) click to toggle source
# File lib/puppet/file_system/memory_file.rb, line 26
def initialize(path, properties)
  @path = path
  @properties = properties
  @children = (properties[:children] || []).collect do |child|
    child.duplicate_as(File.join(@path, child.path))
  end
end