class Puppet::FileSystem::MemoryImpl
Public Class Methods
new(*files)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 2 def initialize(*files) 3 @files = files + all_children_of(files) 4 end
Public Instance Methods
assert_path(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 77 def assert_path(path) 78 if path.is_a?(Puppet::FileSystem::MemoryFile) 79 path 80 else 81 find(path) or raise ArgumentError, _("Unable to find registered object for %{path}") % { path: path.inspect } 82 end 83 end
basename(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 51 def basename(path) 52 path.duplicate_as(File.basename(path_string(path))) 53 end
children(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 39 def children(path) 40 path.children 41 end
directory?(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 14 def directory?(path) 15 path.directory? 16 end
each_line(path, &block)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 43 def each_line(path, &block) 44 path.each_line(&block) 45 end
executable?(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 22 def executable?(path) 23 path.executable? 24 end
exist?(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 10 def exist?(path) 11 path.exist? 12 end
expand_path(path, dir_string = nil)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 6 def expand_path(path, dir_string = nil) 7 File.expand_path(path, dir_string) 8 end
file?(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 18 def file?(path) 19 path.file? 20 end
open(path, *args) { |handle| ... }
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 68 def open(path, *args, &block) 69 handle = assert_path(path).handle 70 if block_given? 71 yield handle 72 else 73 return handle 74 end 75 end
path_string(object)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 55 def path_string(object) 56 object.path 57 end
pathname(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 47 def pathname(path) 48 find(path) || Puppet::FileSystem::MemoryFile.a_missing_file(path) 49 end
read(path, opts = {})
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 59 def read(path, opts = {}) 60 handle = assert_path(path).handle 61 handle.read 62 end
read_preserve_line_endings(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 64 def read_preserve_line_endings(path) 65 read(path) 66 end
readlink(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 30 def readlink(path) 31 path = path.path 32 link = find(path) 33 return Puppet::FileSystem::MemoryFile.a_missing_file(path) unless link 34 source = link.source_path 35 return Puppet::FileSystem::MemoryFile.a_missing_file(link) unless source 36 find(source) || Puppet::FileSystem::MemoryFile.a_missing_file(source) 37 end
symlink?(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 26 def symlink?(path) 27 path.symlink? 28 end
Private Instance Methods
all_children_of(files)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 91 def all_children_of(files) 92 children = files.collect(&:children).flatten 93 if children.empty? 94 [] 95 else 96 children + all_children_of(children) 97 end 98 end
find(path)
click to toggle source
# File lib/puppet/file_system/memory_impl.rb 87 def find(path) 88 @files.find { |file| file.path == path } 89 end