Method: Crackup::Driver::FileDriver#get_path
- Defined in:
- lib/crackup/drivers/file.rb
#get_path(url) ⇒ Object
Gets the filesystem path represented by url. This method is capable of parsing URLs in any of the following formats:
-
file:///foo/bar
-
file://c:/foo/bar
-
c:/foo/bar
-
/foo/bar
-
//smbhost/foo/bar
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/crackup/drivers/file.rb', line 42 def get_path(url) uri = URI::parse(url) path = '' if uri.scheme =~ /^[a-z]$/i # Windows drive letter. path = uri.scheme + ':' elsif uri.host =~ /^[a-z]$/i # Windows drive letter. path = uri.host + ':' elsif uri.scheme.nil? && !uri.host.nil? # SMB share. path = '//' + uri.host end return path += uri.path rescue => e raise Crackup::StorageError, "Invalid URL: #{url}" end |