Class: Puppet::FileSystem::MemoryImpl

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

Instance Method Summary collapse

Constructor Details

#initialize(*files) ⇒ MemoryImpl

Returns a new instance of MemoryImpl.



2
3
4
# File 'lib/puppet/file_system/memory_impl.rb', line 2

def initialize(*files)
  @files = files + all_children_of(files)
end

Instance Method Details

#assert_path(path) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/puppet/file_system/memory_impl.rb', line 64

def assert_path(path)
  if path.is_a?(Puppet::FileSystem::MemoryFile)
    path
  else
    find(path) or raise ArgumentError, _("Unable to find registered object for %{path}") % { path: path.inspect }
  end
end

#basename(path) ⇒ Object



38
39
40
# File 'lib/puppet/file_system/memory_impl.rb', line 38

def basename(path)
  path.duplicate_as(File.basename(path_string(path)))
end

#children(path) ⇒ Object



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

def children(path)
  path.children
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

def directory?(path)
  path.directory?
end

#each_line(path, &block) ⇒ Object



30
31
32
# File 'lib/puppet/file_system/memory_impl.rb', line 30

def each_line(path, &block)
  path.each_line(&block)
end

#executable?(path) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/puppet/file_system/memory_impl.rb', line 22

def executable?(path)
  path.executable?
end

#exist?(path) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/puppet/file_system/memory_impl.rb', line 10

def exist?(path)
  path.exist?
end

#expand_path(path, dir_string = nil) ⇒ Object



6
7
8
# File 'lib/puppet/file_system/memory_impl.rb', line 6

def expand_path(path, dir_string = nil)
  File.expand_path(path, dir_string)
end

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/puppet/file_system/memory_impl.rb', line 18

def file?(path)
  path.file?
end

#open(path, *args, &block) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/puppet/file_system/memory_impl.rb', line 55

def open(path, *args, &block)
  handle = assert_path(path).handle
  if block_given?
    yield handle
  else
    return handle
  end
end

#path_string(object) ⇒ Object



42
43
44
# File 'lib/puppet/file_system/memory_impl.rb', line 42

def path_string(object)
  object.path
end

#pathname(path) ⇒ Object



34
35
36
# File 'lib/puppet/file_system/memory_impl.rb', line 34

def pathname(path)
  find(path) || Puppet::FileSystem::MemoryFile.a_missing_file(path)
end

#read(path, opts = {}) ⇒ Object



46
47
48
49
# File 'lib/puppet/file_system/memory_impl.rb', line 46

def read(path, opts = {})
  handle = assert_path(path).handle
  handle.read
end

#read_preserve_line_endings(path) ⇒ Object



51
52
53
# File 'lib/puppet/file_system/memory_impl.rb', line 51

def read_preserve_line_endings(path)
  read(path)
end