Class: Puppet::FileSystem::MemoryImpl
- Defined in:
- lib/puppet/file_system/memory_impl.rb
Instance Method Summary collapse
- #assert_path(path) ⇒ Object
- #basename(path) ⇒ Object
- #children(path) ⇒ Object
- #directory?(path) ⇒ Boolean
- #each_line(path, &block) ⇒ Object
- #executable?(path) ⇒ Boolean
- #exist?(path) ⇒ Boolean
- #file?(path) ⇒ Boolean
-
#initialize(*files) ⇒ MemoryImpl
constructor
A new instance of MemoryImpl.
- #open(path, *args, &block) ⇒ Object
- #path_string(object) ⇒ Object
- #pathname(path) ⇒ Object
- #read(path) ⇒ Object
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
56 57 58 59 60 61 62 |
# File 'lib/puppet/file_system/memory_impl.rb', line 56 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.inspect}" end end |
#basename(path) ⇒ Object
34 35 36 |
# File 'lib/puppet/file_system/memory_impl.rb', line 34 def basename(path) path.duplicate_as(File.basename(path_string(path))) end |
#children(path) ⇒ Object
22 23 24 |
# File 'lib/puppet/file_system/memory_impl.rb', line 22 def children(path) path.children end |
#directory?(path) ⇒ Boolean
10 11 12 |
# File 'lib/puppet/file_system/memory_impl.rb', line 10 def directory?(path) path.directory? end |
#each_line(path, &block) ⇒ Object
26 27 28 |
# File 'lib/puppet/file_system/memory_impl.rb', line 26 def each_line(path, &block) path.each_line(&block) end |
#executable?(path) ⇒ Boolean
18 19 20 |
# File 'lib/puppet/file_system/memory_impl.rb', line 18 def executable?(path) path.executable? end |
#exist?(path) ⇒ Boolean
6 7 8 |
# File 'lib/puppet/file_system/memory_impl.rb', line 6 def exist?(path) path.exist? end |
#file?(path) ⇒ Boolean
14 15 16 |
# File 'lib/puppet/file_system/memory_impl.rb', line 14 def file?(path) path.file? end |
#open(path, *args, &block) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/puppet/file_system/memory_impl.rb', line 47 def open(path, *args, &block) handle = assert_path(path).handle if block_given? yield handle else return handle end end |
#path_string(object) ⇒ Object
38 39 40 |
# File 'lib/puppet/file_system/memory_impl.rb', line 38 def path_string(object) object.path end |
#pathname(path) ⇒ Object
30 31 32 |
# File 'lib/puppet/file_system/memory_impl.rb', line 30 def pathname(path) find(path) || Puppet::FileSystem::MemoryFile.a_missing_file(path) end |
#read(path) ⇒ Object
42 43 44 45 |
# File 'lib/puppet/file_system/memory_impl.rb', line 42 def read(path) handle = assert_path(path).handle handle.read end |