class DevTools::PRlist::PullRequests

Attributes

pulls[R]

Public Class Methods

new(token = nil, repos = []) click to toggle source
# File lib/pr_list/pull_requests.rb, line 42
def initialize(token = nil, repos = [])
  @pulls  ||= []
  @github ||= __authenticate token

  repos.each { |repo| load!(repo) } if authorized?
end

Public Instance Methods

auth!(token) click to toggle source
# File lib/pr_list/pull_requests.rb, line 53
def auth!(token)
  @github = __authenticate token
end
authorized?() click to toggle source
# File lib/pr_list/pull_requests.rb, line 49
def authorized?
  return !@github.nil?
end
by_date() { |pr| ... } click to toggle source
# File lib/pr_list/pull_requests.rb, line 65
def by_date
  sorted_pulls = @pulls.sort_by { |pr| pr.date }

  block_given? ? sorted_pulls.each { |pr| yield pr } : sorted_pulls
end
load!(repo) click to toggle source
# File lib/pr_list/pull_requests.rb, line 57
def load!(repo)
  raise NoAuthError, "You must authorized with github using #auth first" unless authorized?

  @github.issues(repo).each do |issue|
    __load_issue issue if issue.pull_request?
  end
end
repos() click to toggle source
# File lib/pr_list/pull_requests.rb, line 71
def repos
  @pulls.collect { |pr| pr.repo }.uniq
end

Private Instance Methods

__authenticate(token) click to toggle source
# File lib/pr_list/pull_requests.rb, line 81
def __authenticate(token)
  token ? Octokit::Client.new(access_token: token) : nil
end
__load_issue(issue) click to toggle source
# File lib/pr_list/pull_requests.rb, line 77
def __load_issue(issue)
  @pulls.push PullRequest.new issue
end