Module: Bundler::Alive::Client::GitlabApi
- Defined in:
- lib/bundler/alive/client/gitlab_api.rb
Overview
API Client for GitLab API
Defined Under Namespace
Classes: AccessTokenNotFoundError
Constant Summary collapse
- ACCESS_TOKEN_ENV_NAME =
Environment variable name of GitLab Access Token
"BUNDLER_ALIVE_GITLAB_TOKEN"
- ENDPOINT =
Endpoint of GitLab API
"https://gitlab.com/api/v4"
Class Method Summary collapse
Instance Method Summary collapse
-
#create_client ⇒ Gitlab::Client
Creates a GitLab client.
-
#query(urls:) ⇒ StatusResult
Query repository statuses.
Class Method Details
.extended(base) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/bundler/alive/client/gitlab_api.rb', line 38 def self.extended(base) base.instance_eval do @rate_limit_exceeded = false @retries_on_too_many_requests = 0 end end |
Instance Method Details
#create_client ⇒ Gitlab::Client
Creates a GitLab client
50 51 52 53 54 55 56 57 58 |
# File 'lib/bundler/alive/client/gitlab_api.rb', line 50 def create_client access_token = ENV.fetch(ACCESS_TOKEN_ENV_NAME, nil) raise AccessTokenNotFoundError if access_token.nil? Gitlab.client( endpoint: ENDPOINT, private_token: access_token ) end |
#query(urls:) ⇒ StatusResult
Query repository statuses
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bundler/alive/client/gitlab_api.rb', line 67 def query(urls:) collection = StatusCollection.new name_with_archived = get_name_with_statuses(urls) urls.each do |url| gem_name = url.gem_name alive = name_with_archived.key?(gem_name) && !name_with_archived[gem_name] status = Status.new(name: gem_name, repository_url: url, alive: alive, checked_at: Time.now) collection = collection.add(gem_name, status) end StatusResult.new(collection: collection, error_messages: @error_messages, rate_limit_exceeded: @rate_limit_exceeded) end |