Sha256: 52bbbaad9ef84dca9e6e5a544ce8e30a7281239eb8c7c6a0df696595722dc05a

Contents?: true

Size: 669 Bytes

Versions: 14

Compression:

Stored size: 669 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
        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
      URI::File.build(path: str_path)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
steep-1.5.3 lib/steep/path_helper.rb
steep-1.5.2 lib/steep/path_helper.rb
steep-1.5.1 lib/steep/path_helper.rb
steep-1.5.0 lib/steep/path_helper.rb
steep-1.5.0.pre.6 lib/steep/path_helper.rb
steep-1.5.0.pre.5 lib/steep/path_helper.rb
steep-1.5.0.pre.4 lib/steep/path_helper.rb
steep-1.5.0.pre.3 lib/steep/path_helper.rb
steep-1.5.0.pre.2 lib/steep/path_helper.rb
steep-1.5.0.pre.1 lib/steep/path_helper.rb
steep-1.4.0 lib/steep/path_helper.rb
steep-1.4.0.dev.5 lib/steep/path_helper.rb
steep-1.4.0.dev.4 lib/steep/path_helper.rb
steep-1.4.0.dev.3 lib/steep/path_helper.rb