Class: Puppet::FileSystem::MemoryFile Private
- 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
- #children ⇒ Object readonly private
- #path ⇒ Object readonly private
Class Method Summary collapse
- .a_directory(path, children = []) ⇒ Object private
- .a_missing_directory(path) ⇒ Object private
- .a_missing_file(path) ⇒ Object private
- .a_regular_file_containing(path, content) ⇒ Object private
- .a_symlink(target_path, source_path) ⇒ Object private
- .an_executable(path) ⇒ Object private
Instance Method Summary collapse
- #absolute? ⇒ Boolean private
- #directory? ⇒ Boolean private
- #duplicate_as(other_path) ⇒ Object private
- #each_line(&block) ⇒ Object private
- #executable? ⇒ Boolean private
- #exist? ⇒ Boolean private
- #handle ⇒ Object private
-
#initialize(path, properties) ⇒ MemoryFile
constructor
private
A new instance of MemoryFile.
- #inspect ⇒ Object private
- #source_path ⇒ Object private
- #symlink? ⇒ Boolean private
- #to_path ⇒ Object private
- #to_s ⇒ Object private
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.
39 40 41 42 43 44 45 |
# File 'lib/puppet/file_system/memory_file.rb', line 39 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
#children ⇒ Object (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.
6 7 8 |
# File 'lib/puppet/file_system/memory_file.rb', line 6 def children @children end |
#path ⇒ Object (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.
6 7 8 |
# File 'lib/puppet/file_system/memory_file.rb', line 6 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.
27 28 29 30 31 32 33 |
# File 'lib/puppet/file_system/memory_file.rb', line 27 def self.a_directory(path, children = []) new(path, :exist? => true, :executable? => true, :directory? => true, :children => children) end |
.a_missing_directory(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.
12 13 14 15 16 17 |
# File 'lib/puppet/file_system/memory_file.rb', line 12 def self.a_missing_directory(path) new(path, :exist? => false, :executable? => false, :directory? => true) 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.
8 9 10 |
# File 'lib/puppet/file_system/memory_file.rb', line 8 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.
19 20 21 |
# File 'lib/puppet/file_system/memory_file.rb', line 19 def self.a_regular_file_containing(path, content) new(path, :exist? => true, :executable? => false, :content => content) end |
.a_symlink(target_path, source_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.
35 36 37 |
# File 'lib/puppet/file_system/memory_file.rb', line 35 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.
23 24 25 |
# File 'lib/puppet/file_system/memory_file.rb', line 23 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.
67 68 69 |
# File 'lib/puppet/file_system/memory_file.rb', line 67 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.
47 |
# File 'lib/puppet/file_system/memory_file.rb', line 47 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.
63 64 65 |
# File 'lib/puppet/file_system/memory_file.rb', line 63 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.
53 54 55 |
# File 'lib/puppet/file_system/memory_file.rb', line 53 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.
49 |
# File 'lib/puppet/file_system/memory_file.rb', line 49 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.
48 |
# File 'lib/puppet/file_system/memory_file.rb', line 48 def exist?; @properties[:exist?]; end |
#handle ⇒ 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.
57 58 59 60 61 |
# File 'lib/puppet/file_system/memory_file.rb', line 57 def handle raise Errno::ENOENT unless exist? StringIO.new(@properties[:content] || '') end |
#inspect ⇒ 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.
79 80 81 |
# File 'lib/puppet/file_system/memory_file.rb', line 79 def inspect "<Puppet::FileSystem::MemoryFile:#{self}>" end |
#source_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.
51 |
# File 'lib/puppet/file_system/memory_file.rb', line 51 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.
50 |
# File 'lib/puppet/file_system/memory_file.rb', line 50 def symlink?; @properties[:symlink?]; end |
#to_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.
71 72 73 |
# File 'lib/puppet/file_system/memory_file.rb', line 71 def to_path path end |
#to_s ⇒ 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.
75 76 77 |
# File 'lib/puppet/file_system/memory_file.rb', line 75 def to_s to_path end |