Sha256: a6f450e5c73099f6c14ec79fc3fd3158ec1b43ff6d97be9eead6dba5b9fb58b3

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'uri'

require 'uri/ssh_git/generic'
require 'uri/ssh_git/version'

module URI
  # Parse and build git repository url via ssh protocol.
  module SshGit
    # @example
    #   url = URI::SshGit.parse('git@github.com:packsaddle/ruby-uri-ssh_git.git')
    #   #=> #<URI::SshGit::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 http://docs.ruby-lang.org/en/2.2.0/URI/Generic.html
    #
    # @param url [String] git repository url via ssh protocol
    #
    # @return [Generic] parsed object
    def self.parse(uri_string)
      host_part, path_part = uri_string.split(':', 2)
      userinfo, host = host_part.split('@', 2)
      path_part = '/' + path_part unless path_part.start_with?('/')
      Generic.build(userinfo: userinfo, host: host, path: path_part)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
uri-ssh_git-1.0.0 lib/uri/ssh_git.rb
uri-ssh_git-0.1.2 lib/uri/ssh_git.rb