Class: MockFS::MockFileSystem
- Inherits:
-
Object
- Object
- MockFS::MockFileSystem
- 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
-
.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.
-
#initialize ⇒ MockFileSystem
constructor
:nodoc:.
-
#node(dirname) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ MockFileSystem
:nodoc:
393 394 395 |
# File 'lib/mockfs.rb', line 393 def initialize #:nodoc: flush end |
Class Method Details
.flush ⇒ Object
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 |
#flush ⇒ Object
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 |