Module: VirtualFS
- Defined in:
- lib/virtualfs.rb,
lib/virtualfs/dir.rb,
lib/virtualfs/file.rb,
lib/virtualfs/local.rb,
lib/virtualfs/github.rb,
lib/virtualfs/backend.rb,
lib/virtualfs/version.rb,
lib/virtualfs/file_cache.rb,
lib/virtualfs/dalli_cache.rb,
lib/virtualfs/runtime_cache.rb
Defined Under Namespace
Classes: Backend, DalliCache, Dir, File, FileCache, Github, Local, NullCache, RuntimeCache
Constant Summary collapse
- VERSION =
"0.1.5"
- @@SELF_RX =
/(\/|^)\.(\/|$)/
- @@PARENT_RX =
/([^\/.]+\/|^\/?)\.\.(\/|$)/
Class Method Summary collapse
Class Method Details
.realpath(path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/virtualfs.rb', line 7 def self.realpath(path) return nil if path.nil? # Remove . dirs p = path.gsub @@SELF_RX, '\2' # Remove .. dirs while p =~ @@PARENT_RX p.gsub! @@PARENT_RX, '' end # Keep a slash at the beginning, remove at the end '/' << p.sub(%r{^/+}, '').chomp('/') end |