Class: VirtualFS::Backend
- Inherits:
-
Object
- Object
- VirtualFS::Backend
- Defined in:
- lib/virtualfs/backend.rb
Instance Method Summary collapse
- #cache(&proc) ⇒ Object
- #dotfolders_for(path) ⇒ Object
- #entries(path = nil) ⇒ Object
- #glob(pattern, path = nil) ⇒ Object (also: #[])
-
#initialize(opts = {}) ⇒ Backend
constructor
A new instance of Backend.
- #map_entries(paths, method = :to_s, &dir_criteria) ⇒ Object
- #stream_for(path) ⇒ Object
Constructor Details
Instance Method Details
#cache(&proc) ⇒ Object
16 17 18 19 20 |
# File 'lib/virtualfs/backend.rb', line 16 def cache(&proc) local_variable_values = eval('local_variables.map { |var| eval(var.to_s) }', proc.binding) key = caller[0] << local_variable_values.inspect @cache.cache(key, &proc) end |
#dotfolders_for(path) ⇒ Object
32 33 34 |
# File 'lib/virtualfs/backend.rb', line 32 def dotfolders_for(path) [VirtualFS::Dir.new(::File.join(path, '.'), self), VirtualFS::Dir.new(::File.join(path, '..'), self)] end |
#entries(path = nil) ⇒ Object
36 37 38 39 |
# File 'lib/virtualfs/backend.rb', line 36 def entries(path=nil) # override this raise NotImplementedError end |
#glob(pattern, path = nil) ⇒ Object Also known as: []
41 42 43 44 |
# File 'lib/virtualfs/backend.rb', line 41 def glob(pattern, path=nil) # override this raise NotImplementedError end |
#map_entries(paths, method = :to_s, &dir_criteria) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/virtualfs/backend.rb', line 22 def map_entries(paths, method=:to_s, &dir_criteria) paths.map do |path| if dir_criteria.call(path) VirtualFS::Dir.new(path.send(method), self) else VirtualFS::File.new(path.send(method), self) end end end |
#stream_for(path) ⇒ Object
46 47 48 49 |
# File 'lib/virtualfs/backend.rb', line 46 def stream_for(path) # override this raise NotImplementedError end |