class Chandler::GitHub::Remote

Assuming a git remote points to a public GitHub or a GitHub Enterprise repository, this class parses the remote to obtain the host and repository path. Supports SSH and HTTPS style git remotes.

This class also handles parsing values passed into the `–github` command line option, which may be a public GitHub repository name, like “mattbrictson/chandler”.

Attributes

host[R]
path[R]

Public Class Methods

new(host, path) click to toggle source
# File lib/chandler/github/remote.rb, line 27
def initialize(host, path)
  @host = host.downcase
  @path = path
end
parse(url) click to toggle source
# File lib/chandler/github/remote.rb, line 14
def self.parse(url)
  if (match = url.match(/@([^:]+):(.+)$/))
    new(match[1], match[2])
  else
    parsed_uri = URI(url)
    host = parsed_uri.host || "github.com"
    path = parsed_uri.path.sub(%r{^/+}, "")
    new(host, path)
  end
end

Public Instance Methods

repository() click to toggle source
# File lib/chandler/github/remote.rb, line 32
def repository
  path.sub(/\.git$/, "")
end