Module: URI::SshGit

Defined in:
lib/uri/ssh_git.rb,
lib/uri/ssh_git/generic.rb,
lib/uri/ssh_git/version.rb

Overview

Parse and build git repository url via ssh protocol.

Defined Under Namespace

Classes: Generic

Constant Summary collapse

VERSION =
'2.0.0'

Class Method Summary collapse

Class Method Details

.parse(uri_string) ⇒ Generic

Returns parsed object.

Examples:

url = URI::SshGit.parse('[email protected]:packsaddle/ruby-uri-ssh_git.git')
#=> #<URI::SshGit::Generic [email protected]: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

Parameters:

  • url (String)

    git repository url via ssh protocol

Returns:

See Also:



30
31
32
33
34
35
36
# File 'lib/uri/ssh_git.rb', line 30

def self.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, path: path_part)
end