class PairingMatrix::GithubCommitReader

Public Class Methods

new(config) click to toggle source
Calls superclass method PairingMatrix::CommitReader::new
# File lib/pairing_matrix/commit_readers/github_commit_reader.rb, line 10
def initialize(config)
  super(config)
  @cache = CommitCache.new
end

Protected Instance Methods

read(since) click to toggle source
# File lib/pairing_matrix/commit_readers/github_commit_reader.rb, line 16
def read(since)
  cache = @cache.get(since)
  return cache unless cache.nil?

  commits = []
  together do
    client = github_client

    @config.repositories.map do |repo|
      async do
        commits << fetch_commits(client, repo, since)
      end
    end
  end

  result = commits.flatten
  @cache.put(since, result)
  result
end

Private Instance Methods

fetch_commits(client, repo, since) click to toggle source
# File lib/pairing_matrix/commit_readers/github_commit_reader.rb, line 37
def fetch_commits(client, repo, since)
  client.commits_since(repo, since).map { |commit| commit.commit.message }
end
github_client() click to toggle source
# File lib/pairing_matrix/commit_readers/github_commit_reader.rb, line 41
def github_client
  Octokit.configure {|c| c.api_endpoint = @config.url}

  if @config.has_access_token?
    Octokit::Client.new(:access_token => @config.access_token)
  else
    Octokit::Client.new
  end
end