Class: MockFS::MockFileSystem

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mockfs.rb

Overview

The MockFileSystem is the singleton class that pretends to be the file system in mock mode. When it’s first created, it fills in one path up to your real directory location; other paths will have to be filled by hand using fill_path.

Defined Under Namespace

Modules: Node Classes: MockDir, MockFile, MockRoot

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMockFileSystem

:nodoc:



393
394
395
# File 'lib/mockfs.rb', line 393

def initialize #:nodoc:
	flush
end

Class Method Details

.flushObject

Flushes all file information out of the MockFileSystem.



391
# File 'lib/mockfs.rb', line 391

def self.flush; instance.flush; end

Instance Method Details

#fill_path(dirname) ⇒ Object

Use this method to fill in directory paths. This is the same as calling mkdir a bunch of times.

MockFS.mock_file_system.fill_path '/usr/local/bin'
MockFS.mock_file_system.fill_path '/home/francis/Desktop/myproject/'


404
405
406
# File 'lib/mockfs.rb', line 404

def fill_path( dirname )
	@root.fill_path( Path.new( dirname ).absolute.strip )
end

#flushObject

Flushes all file information out of the MockFileSystem.



398
# File 'lib/mockfs.rb', line 398

def flush; @root = MockRoot.new( '' ); fill_path( '.' ); end

#node(dirname) ⇒ Object

:nodoc:



408
409
410
# File 'lib/mockfs.rb', line 408

def node( dirname ) #:nodoc:
	@root.node( dirname )
end