Sha256: 06b2a0b6dea27b12eae368c64cc31a37f798c39e8067384b3761c76c3cf67608
Contents?: true
Size: 1.59 KB
Versions: 12
Compression:
Stored size: 1.59 KB
Contents
# URI extention for PIONE system. # @api private module URI # Installs a new scheme. def self.install_scheme(name, klass) @@schemes[name] = klass end class Generic # Returns true if the scheme is supportted by PIONE system. # @return [Boolean] # true if the scheme is supportted by PIONE system def pione? false end # Returns true if the path represents a directory. # @return [Boolean] # true if the path represents a directory def directory? path[-1] == '/' end # Returns true if the path represents a file. # @return [Boolean] # true if the path represents a file def file? not(directory?) end # Converts the uri into directory form. # @return [Generic] # directory path form def as_directory if directory? self else self.clone.tap{|s| s.path = s.path + "/"} end end end class Parser alias :orig_split :split # Handles to split special schemes's URI. def split(uri) scheme = uri.split(":").first # special schemes case scheme when "local" path = uri[6..-1] return [scheme, nil, nil, nil, nil, path, nil, nil, nil] when "broadcast" rest = uri[10..-1] if rest == "//" return [scheme, nil, nil, nil, nil, nil, nil, nil, nil] end when "myftp" if uri[6] == "." or uri[6] == "~" path = uri[6..-1] return [scheme, nil, nil, nil, nil, path, nil, nil, nil] end end # other case return orig_split(uri) end end end
Version data entries
12 entries across 12 versions & 1 rubygems