Class: QB::Repo::Git::GitHub

Inherits:
QB::Repo::Git show all
Defined in:
lib/qb/repo/git/github.rb

Overview

Git repo where the origin remote points to GitHub, which is used to determine it's owner and name.

Constant Summary collapse

SSH_URL_RE =

Constants

/^git@github\.com\:(?<owner>.*)\/(?<name>.*)\.git$/
HTTPS_URL_RE =
/^https:\/\/github\.com\/(?<owner>.*)\/(?<name>.*)\.git$/

Instance Attribute Summary

Attributes inherited from QB::Repo

#name, #ref_path, #root_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QB::Repo::Git

#clean?, from_path, #from_path!, #full_name, #head_short, #lib, #status, #tags

Methods inherited from QB::Repo

from_path, from_path!, #tags

Methods inherited from Util::Resource

#initialize

Constructor Details

This class inherits a constructor from QB::Util::Resource

Class Method Details

.https_url?(string) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/qb/repo/git/github.rb', line 62

def self.https_url? string
  !!(HTTPS_URL_RE =~ string)
end

.parse_https_url(string) ⇒ Object



77
78
79
# File 'lib/qb/repo/git/github.rb', line 77

def self.parse_https_url string
  parse_url_with HTTPS_URL_RE, string
end

.parse_ssh_url(string) ⇒ Object



72
73
74
# File 'lib/qb/repo/git/github.rb', line 72

def self.parse_ssh_url string
  parse_url_with SSH_URL_RE, string
end

.parse_url(string) ⇒ nil, QB::GitHub::RepoID

Extract owner and name from Git remote URL string pointing to GitHub.

Returns:

  • (nil)

    If the URL is not recognized.

  • (QB::GitHub::RepoID)

    If the URL successfully parses.



90
91
92
# File 'lib/qb/repo/git/github.rb', line 90

def self.parse_url string
  parse_ssh_url( string ) || parse_https_url( string )
end

.ssh_url?(string) ⇒ Boolean

Helpers

Returns:

  • (Boolean)


57
58
59
# File 'lib/qb/repo/git/github.rb', line 57

def self.ssh_url? string
  !!(SSH_URL_RE =~ string)
end

.url?(string) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/qb/repo/git/github.rb', line 67

def self.url? string
  ssh_url?( string ) || https_url?( string )
end

Instance Method Details

#apiObject



134
135
136
# File 'lib/qb/repo/git/github.rb', line 134

def api
  QB::GitHub::API.client.repo repo_id.path
end

#github?true

Part of the QB::Repo::Git API, always true for GitHub instances.

Returns:

  • (true)


129
130
131
# File 'lib/qb/repo/git/github.rb', line 129

def github?
  true
end

#issue(number) ⇒ Object



139
140
141
142
# File 'lib/qb/repo/git/github.rb', line 139

def issue number
  # QB::GitHub::API.client.issue( repo_id.path, number ).to_h.stringify_keys
  QB::GitHub::Issue.find_by repo_id: repo_id, number: number
end