Sha256: 02e0089b509cf07e9e7062c10413049c8bd74d38f281d5e9837eeafad80ac36e
Contents?: true
Size: 773 Bytes
Versions: 18
Compression:
Stored size: 773 Bytes
Contents
module Steep module PathHelper module_function def to_pathname(uri, dosish: Gem.win_platform?) uri = URI.parse(uri) if uri.scheme == "file" path = uri.path or raise path.sub!(%r{^/([a-zA-Z])(:|%3A)//?}i, '\1:/') if dosish path = URI::DEFAULT_PARSER.unescape(path) Pathname(path) end end def to_pathname!(uri, dosish: Gem.win_platform?) to_pathname(uri, dosish: dosish) or raise "Cannot translate a URI to pathname: #{uri}" end def to_uri(path, dosish: Gem.win_platform?) str_path = path.to_s if dosish str_path.insert(0, "/") if str_path[0] != "/" end str_path = URI::DEFAULT_PARSER.escape(str_path) URI::File.build(path: str_path) end end end
Version data entries
18 entries across 18 versions & 1 rubygems