class Puppet::FileSystem::MemoryImpl

Public Class Methods

new(*files) click to toggle source
  # File lib/puppet/file_system/memory_impl.rb
3 def initialize(*files)
4   @files = files + all_children_of(files)
5 end

Public Instance Methods

assert_path(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
78 def assert_path(path)
79   if path.is_a?(Puppet::FileSystem::MemoryFile)
80     path
81   else
82     find(path) or raise ArgumentError, _("Unable to find registered object for %{path}") % { path: path.inspect }
83   end
84 end
basename(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
52 def basename(path)
53   path.duplicate_as(File.basename(path_string(path)))
54 end
children(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
40 def children(path)
41   path.children
42 end
directory?(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
15 def directory?(path)
16   path.directory?
17 end
each_line(path, &block) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
44 def each_line(path, &block)
45   path.each_line(&block)
46 end
executable?(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
23 def executable?(path)
24   path.executable?
25 end
exist?(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
11 def exist?(path)
12   path.exist?
13 end
expand_path(path, dir_string = nil) click to toggle source
  # File lib/puppet/file_system/memory_impl.rb
7 def expand_path(path, dir_string = nil)
8   File.expand_path(path, dir_string)
9 end
file?(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
19 def file?(path)
20   path.file?
21 end
open(path, *args) { |handle| ... } click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
69 def open(path, *args, &block)
70   handle = assert_path(path).handle
71   if block_given?
72     yield handle
73   else
74     return handle
75   end
76 end
path_string(object) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
56 def path_string(object)
57   object.path
58 end
pathname(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
48 def pathname(path)
49   find(path) || Puppet::FileSystem::MemoryFile.a_missing_file(path)
50 end
read(path, opts = {}) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
60 def read(path, opts = {})
61   handle = assert_path(path).handle
62   handle.read
63 end
read_preserve_line_endings(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
65 def read_preserve_line_endings(path)
66   read(path)
67 end

Private Instance Methods

all_children_of(files) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
92 def all_children_of(files)
93   children = files.collect(&:children).flatten
94   if children.empty?
95     []
96   else
97     children + all_children_of(children)
98   end
99 end
find(path) click to toggle source
   # File lib/puppet/file_system/memory_impl.rb
88 def find(path)
89   @files.find { |file| file.path == path }
90 end