module URI::Ssh
Public Instance Methods
generic_url?(url)
click to toggle source
@param url [String] git repository-ish url @return [Boolean] true if url is https, ssh protocol
# File lib/dr/base/uri.rb, line 50 def generic_url?(url) match = %r{\A(\w*)://}.match(url) !match.nil? end
parse(url, force: false)
click to toggle source
@param url [String] git repository-ish url @return [URI::Generic] if url starts ssh @return [URI::HTTPS] if url starts https @return [URI::SshGit] if url is ssh+git e.g git@example.com:schacon/ticgit.git
# 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)
click to toggle source
From: https://github.com/packsaddle/ruby-git_clone_url
@param url [String] git repository-ish url @return [Boolean] true if url is git via ssh protocol
# File lib/dr/base/uri.rb, line 44 def ssh_git_url?(url) !generic_url?(url) end
Protected Instance Methods
internal_parse(uri_string)
click to toggle source
@example
url = URI::Ssh.parse('git@github.com:packsaddle/ruby-uri-ssh_git.git') #=> #<URI::Ssh::Generic git@github.com:packsaddle/ruby-uri-ssh_git.git> url.scheme #=> nil url.userinfo #=> 'git' url.user #=> 'git' url.password #=> nil url.host #=> 'github.com' url.port #=> nil url.registry #=> nil url.path #=> 'packsaddle/ruby-uri-ssh_git.git' url.opaque #=> nil url.query #=> nil url.fragment #=> nil
@see docs.ruby-lang.org/en/2.2.0/URI/Generic.html @param url [String] git repository url via ssh protocol @return [Generic] parsed object
# File lib/dr/base/uri.rb, line 25 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