Class: Puppet::FileSystem::MemoryFile Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/file_system/memory_file.rb

Overview

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.

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, properties) ⇒ MemoryFile

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 MemoryFile.


30
31
32
33
34
35
36
# File 'lib/puppet/file_system/memory_file.rb', line 30

def initialize(path, properties)
  @path = path
  @properties = properties
  @children = (properties[:children] || []).collect do |child|
    child.duplicate_as(File.join(@path, child.path))
  end
end

Instance Attribute Details

#childrenObject (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.


4
5
6
# File 'lib/puppet/file_system/memory_file.rb', line 4

def children
  @children
end

#pathObject (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.


4
5
6
# File 'lib/puppet/file_system/memory_file.rb', line 4

def path
  @path
end

Class Method Details

.a_directory(path, children = []) ⇒ 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
21
22
23
24
# 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) ⇒ 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.


6
7
8
# 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) ⇒ 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.


10
11
12
# 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

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.


26
27
28
# File 'lib/puppet/file_system/memory_file.rb', line 26

def self.a_symlink(target_path, source_path)
  new(target_path, :exist? => true, :symlink? => true, :source_path => source_path)
end

.an_executable(path) ⇒ 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.


14
15
16
# File 'lib/puppet/file_system/memory_file.rb', line 14

def self.an_executable(path)
  new(path, :exist? => true, :executable? => true)
end

Instance Method Details

#absolute?Boolean

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.


57
58
59
# File 'lib/puppet/file_system/memory_file.rb', line 57

def absolute?
  Pathname.new(path).absolute?
end

#directory?Boolean

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.


38
# File 'lib/puppet/file_system/memory_file.rb', line 38

def directory?; @properties[:directory?]; end

#duplicate_as(other_path) ⇒ 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.


53
54
55
# File 'lib/puppet/file_system/memory_file.rb', line 53

def duplicate_as(other_path)
  self.class.new(other_path, @properties)
end

#each_line(&block) ⇒ 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.


44
45
46
# File 'lib/puppet/file_system/memory_file.rb', line 44

def each_line(&block)
  handle.each_line(&block)
end

#executable?Boolean

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.


40
# File 'lib/puppet/file_system/memory_file.rb', line 40

def executable?; @properties[:executable?]; end

#exist?Boolean

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.


39
# File 'lib/puppet/file_system/memory_file.rb', line 39

def exist?; @properties[:exist?]; end

#handleObject

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.

Raises:

  • (Errno::ENOENT)

48
49
50
51
# File 'lib/puppet/file_system/memory_file.rb', line 48

def handle
  raise Errno::ENOENT unless exist?
  StringIO.new(@properties[:content] || '')
end

#inspectObject

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.


69
70
71
# File 'lib/puppet/file_system/memory_file.rb', line 69

def inspect
  "<Puppet::FileSystem::MemoryFile:#{self}>"
end

#source_pathObject

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.


42
# File 'lib/puppet/file_system/memory_file.rb', line 42

def source_path; @properties[:source_path]; end

#symlink?Boolean

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.


41
# File 'lib/puppet/file_system/memory_file.rb', line 41

def symlink?; @properties[:symlink?]; end

#to_pathObject

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.


61
62
63
# File 'lib/puppet/file_system/memory_file.rb', line 61

def to_path
  path
end

#to_sObject

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.


65
66
67
# File 'lib/puppet/file_system/memory_file.rb', line 65

def to_s
  to_path
end