Class: QB::GitHub::RepoID

Inherits:
Util::Resource show all
Defined in:
lib/qb/github/repo_id.rb

Overview

Unique identifier for a GitHub repo, which is a composite of an owner and a name string.

Instance Method Summary collapse

Instance Method Details

#git_https_urlString

HTTPS protocol URL string for use as a Git remote.

Examples:

repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
repo_id.git_https_url
# => "https://github.com/nrser/qb.git"

Returns:

  • (String)


106
107
108
# File 'lib/qb/github/repo_id.rb', line 106

def git_https_url
  "https://github.com/#{ path }.git"
end

#git_ssh_urlString

SSH protocol URL string for use as a Git remote.

Examples:

repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
repo_id.git_ssh_url
# => "[email protected]:nrser/qb.git"

Returns:

  • (String)


92
93
94
# File 'lib/qb/github/repo_id.rb', line 92

def git_ssh_url
  "[email protected]:#{ path }.git"
end

#git_url(protocol) ⇒ String

Return #git_ssh_url or #git_https_url depending on protocol parameter.

Parameters:

  • protocol (Symbol)

    :ssh or :https.

Returns:

  • (String)

    URL.



120
121
122
123
124
# File 'lib/qb/github/repo_id.rb', line 120

def git_url protocol
  t.match protocol,
    :ssh,   ->( _ ) { git_ssh_url },
    :https, ->( _ ) { git_https_url }
end

#pathString Also known as: full_name, to_s

"Path" on GitHub for the repo - the <owner>/<name> part that comes after the host in URLs.

Called full_name in GitHub API (we include a #full_name method alias as well).

This is also what we return for #to_s.

Examples:

repo_id = QB::GitHub::RepoID.new owner: 'nrser', name: 'qb'
repo_id.path
# => "nrser/qb"

Returns:

  • (String)


75
76
77
# File 'lib/qb/github/repo_id.rb', line 75

def path
  "#{ owner }/#{ name }"
end