Module: Gemvault::VaultPath
- Defined in:
- lib/gemvault/vault_path.rb
Overview
Translates vault locators into filesystem paths.
A locator is whatever a user hands the CLI or a package manager as "the vault": a plain filesystem path, a file:// URI, or a vault:// URI. Anything else passes through unchanged.
Constant Summary collapse
- SCHEMES =
["file", "vault"].freeze
Class Method Summary collapse
-
.resolve(locator) ⇒ Object
:call-seq: resolve(locator) -> Pathname.
Class Method Details
.resolve(locator) ⇒ Object
:call-seq:
resolve(locator) -> Pathname
Resolves locator to a Pathname. Two-slash relative forms such as
file://vault.gemv parse their first segment as a URI host, so
host and path are rejoined.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gemvault/vault_path.rb', line 22 def resolve(locator) begin uri = URI.parse(locator.to_s) return Pathname(locator.to_s) unless SCHEMES.include?(uri.scheme) Pathname([uri.host, uri.path].compact.join) rescue URI::InvalidURIError Pathname(locator.to_s) end end |