Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.cleanpath(orig_path)
- nodes = Pathname.new(orig_path).cleanpath.to_s.split('/')
- realnames = ['.']
- nodes.each do |node|
- path = realnames.join('/')
- entries = Dir.entries(path).select { |entry| entry.downcase == node.downcase }
- realnames << if entries.size == 1
- entries.first
- else
- node
- end
- end
- realnames.join('/')
- end
Add Comment
Please, Sign In to add comment