Class: FileSystem::MockFileSystem
- Inherits:
-
Object
- Object
- FileSystem::MockFileSystem
- 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
-
.flush ⇒ Object
Flushes all file information out of the MockFileSystem.
Instance Method Summary collapse
-
#fill_path(dirname) ⇒ Object
Use this method to fill in directory paths.
-
#flush ⇒ Object
Flushes all file information out of the MockFileSystem.
-
#get_node(dirname) ⇒ Object
:nodoc:.
-
#initialize ⇒ MockFileSystem
constructor
:nodoc:.
Constructor Details
#initialize ⇒ MockFileSystem
:nodoc:
197 198 199 |
# File 'lib/filesystem.rb', line 197 def initialize #:nodoc: flush end |
Class Method Details
.flush ⇒ Object
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 |
#flush ⇒ Object
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 |