Class: MockFS::DirAdapter
- Inherits:
-
Object
- Object
- MockFS::DirAdapter
show all
- Extended by:
- Adapter
- Includes:
- Adapter
- Defined in:
- lib/mockfs.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Adapter
method_missing, node, respond_to?
Constructor Details
#initialize(dirname) ⇒ DirAdapter
Returns a new instance of DirAdapter.
190
191
192
193
194
195
|
# File 'lib/mockfs.rb', line 190
def initialize( dirname )
unless node( dirname ).class == MockFileSystem::MockDir
raise Errno::ENOTDIR
end
@path = dirname
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MockFS::Adapter
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
188
189
190
|
# File 'lib/mockfs.rb', line 188
def path
@path
end
|
Class Method Details
.[](string) ⇒ Object
166
|
# File 'lib/mockfs.rb', line 166
def self.[]( string ); glob( string, 0 ); end
|
.foreach(dirname, &block) ⇒ Object
168
169
170
|
# File 'lib/mockfs.rb', line 168
def self.foreach( dirname, &block )
entries( dirname ).each( &block )
end
|
.glob(string, flags = 0) ⇒ Object
172
173
174
175
176
|
# File 'lib/mockfs.rb', line 172
def self.glob( string, flags = 0 )
DirAdapter.new( '.' ).send( :glob, string, flags ).map { |result|
Path.new( result )[1..-1]
}
end
|
.mkdir(dirname) ⇒ Object
178
179
180
181
|
# File 'lib/mockfs.rb', line 178
def self.mkdir( dirname )
path = Path.new( dirname ).absolute
node( path.parent ).mkdir( path.node )
end
|
.rmdir(dirname) ⇒ Object
183
184
185
186
|
# File 'lib/mockfs.rb', line 183
def self.rmdir( dirname )
path = Path.new( dirname ).absolute
node( path ).delete
end
|
Instance Method Details
#entries ⇒ Object
197
|
# File 'lib/mockfs.rb', line 197
def entries; self.class.entries( @path ); end
|