class OpenPull::PullRequestFetcher
Attributes
client[R]
organisation[R]
username[R]
Public Class Methods
new(client, organisation, username = '')
click to toggle source
# File lib/openpull/pull_request_fetcher.rb, line 7 def initialize(client, organisation, username = '') @client = client @organisation = organisation @username = username end
Public Instance Methods
fetch()
click to toggle source
# File lib/openpull/pull_request_fetcher.rb, line 13 def fetch repos = client.org_repos(organisation).map do |repository| Thread.new { fetch_pull_requests(repository) } end.map(&:value) repos.reject { |v| v.nil? || v.empty? } end
Private Instance Methods
fetch_pull_requests(repository)
click to toggle source
# File lib/openpull/pull_request_fetcher.rb, line 23 def fetch_pull_requests(repository) print '.'.green pull_requests = client.pull_requests(repository.id, state: 'open') return [] if pull_requests.empty? results = pull_requests.map do |pull_request| Thread.new { row(pull_request) } end.map(&:value) [headers(repository, results.size)] + results end
headers(repository, size)
click to toggle source
# File lib/openpull/pull_request_fetcher.rb, line 36 def headers(repository, size) head = [ "#{repository.name} (#{size})", repository.private ? 'private' : 'public' ] head += [''] * 5 head += [ repository.html_url, '' ] head.map { |h| h.blue.bold } end
row(pull_request)
click to toggle source
# File lib/openpull/pull_request_fetcher.rb, line 49 def row(pull_request) print '.'.yellow OpenPull::PullRequestDecorator.new( pull_request.rels[:self].get.data ).as_row(username) end