class RepoProvider::Github

API documentation: developer.github.com/v3/

Constants

URL_PATTERNS

Public Class Methods

get_repo(url) click to toggle source
# File lib/git-issues/providers/github.rb, line 13
def self.get_repo url
  # find the url pattern that matches the url
  URL_PATTERNS.map{|p| p.match url }.compact.first
end

Public Instance Methods

issue_close(id) click to toggle source
# File lib/git-issues/providers/github.rb, line 37
def issue_close id
  ret = github.close_issue gh_repo, id
  ret[:state] == 'closed'
end
issue_create(title, content) click to toggle source
# File lib/git-issues/providers/github.rb, line 27
def issue_create title, content
  ret = github.create_issue gh_repo, title, content
  ret.attrs && ret.attrs[:number] || -1
end
issue_delete(id) click to toggle source
# File lib/git-issues/providers/github.rb, line 42
def issue_delete id
  log.warn "You can't delete issues on GitHub. Please close/resolve them instead."
end
issue_reopen(id) click to toggle source
# File lib/git-issues/providers/github.rb, line 32
def issue_reopen id
  ret = github.reopen_issue gh_repo, id
  ret[:state] == 'open'
end
issues_list(opts = {}) click to toggle source
# File lib/git-issues/providers/github.rb, line 18
def issues_list opts = {}
  # get open issues for this repo
  issues = github.issues gh_repo
  # get all closed issues if required
  issues += github.issues( gh_repo, state: 'closed' ) if opts[:all]
  # return issues
  format_issues( issues )
end
provider() click to toggle source
# File lib/git-issues/providers/github.rb, line 46
def provider
  github
end

Private Instance Methods

format_issues(is) click to toggle source
# File lib/git-issues/providers/github.rb, line 56
def format_issues is
  Array(is).map do |i|
    i['description'] = i['body']
    i
  end
end
gh_repo() click to toggle source
# File lib/git-issues/providers/github.rb, line 52
def gh_repo
  "#{repo['user']}/#{repo['repo']}"
end
github() click to toggle source
# File lib/git-issues/providers/github.rb, line 63
def github
  init_github if @github.nil?
  @github
end
init_github() click to toggle source
# File lib/git-issues/providers/github.rb, line 68
def init_github
  ot = oauth_token
  # get configuration from oauth token and secret
  if( not ot.nil? )
    @github = Octokit::Client.new access_token: ot
  else
    # use login and password otherwise
    @github = Octokit::Client.new login: user, password: password
  end
end