Class: FileSystem::MockFileSystem

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/filesystem.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:



197
198
199
# File 'lib/filesystem.rb', line 197

def initialize #:nodoc:
	flush
end

Class Method Details

.flushObject

Flushes all file information out of the MockFileSystem.



195
# File 'lib/filesystem.rb', line 195

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.

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


212
213
214
# File 'lib/filesystem.rb', line 212

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

#flushObject

Flushes all file information out of the MockFileSystem.



202
# File 'lib/filesystem.rb', line 202

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

#get_node(dirname) ⇒ Object

:nodoc:



204
205
206
# File 'lib/filesystem.rb', line 204

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