class PairingMatrix::GitlabCommitReader

Public Class Methods

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

Protected Instance Methods

read(since) click to toggle source
# File lib/pairing_matrix/commit_readers/gitlab_commit_reader.rb, line 14
def read(since)
    cache = @cache.get(since)
    return cache unless cache.nil?
  
    commits = []
    together do
        client = gitlab_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/gitlab_commit_reader.rb, line 34
def fetch_commits(client, repo, since)
    client.commits(repo, since: since).map { |commit| commit.title }
end
gitlab_client() click to toggle source
# File lib/pairing_matrix/commit_readers/gitlab_commit_reader.rb, line 38
def gitlab_client
    Gitlab.client(endpoint: @config.url, private_token: @config.access_token)
end