Module: URI::Ssh
Overview
Defined Under Namespace
Classes: Generic
Instance Method Summary collapse
-
#generic_url?(url) ⇒ Boolean
True if url is https, ssh protocol.
-
#internal_parse(uri_string) ⇒ Generic
protected
Parsed object.
- #parse(url, force: false) ⇒ URI::Generic, ...
- #ssh_git_url?(url) ⇒ Boolean
Instance Method Details
#generic_url?(url) ⇒ Boolean
Returns true if url is https, ssh protocol.
50 51 52 53 |
# File 'lib/dr/base/uri.rb', line 50 def generic_url?(url) match = %r{\A(\w*)://}.match(url) !match.nil? end |
#internal_parse(uri_string) ⇒ Generic (protected)
Returns parsed object.
25 26 27 28 29 30 31 |
# File 'lib/dr/base/uri.rb', line 25 protected def internal_parse(uri_string) host_part, path_part = uri_string&.split(':', 2) # There may be no user, so reverse the split to make sure host always # is !nil if host_part was !nil. host, userinfo = host_part&.split('@', 2)&.reverse Generic.build(userinfo: userinfo, host: host || uri_string, path: path_part) end |
#parse(url, force: false) ⇒ URI::Generic, ...
37 38 39 |
# File 'lib/dr/base/uri.rb', line 37 def parse(url, force: false) (ssh_git_url?(url) || force)? URI::Ssh.internal_parse(url) : URI.parse(url) end |
#ssh_git_url?(url) ⇒ Boolean
44 45 46 |
# File 'lib/dr/base/uri.rb', line 44 def ssh_git_url?(url) !generic_url?(url) end |