class HoundListSync::Repositories::Gitlab
Constants
- URL_TEMPLATE
Public Class Methods
new( api_endpoint, token: nil, url_template: URL_TEMPLATE, http: HoundListSync::Http::Net.new )
click to toggle source
# File lib/hound_list_sync/repositories/gitlab.rb, line 58 def initialize( api_endpoint, token: nil, url_template: URL_TEMPLATE, http: HoundListSync::Http::Net.new ) @api_endpoint = api_endpoint @token = token @url_template = url_template @http = http end
Public Instance Methods
auth_headers()
click to toggle source
# File lib/hound_list_sync/repositories/gitlab.rb, line 97 def auth_headers @auth_headers ||= if @token.nil? {} else { "Authorization" => "Bearer #{@token}" } end end
each() { |repo| ... }
click to toggle source
# File lib/hound_list_sync/repositories/gitlab.rb, line 70 def each return to_enum unless block_given? page = "1" loop do response = @http.get(url(page), headers: auth_headers) repos = JSON.parse(response.body) break if repos.length.zero? repos.each do |repo| yield Repo.new(repo) end next_page = response.headers["x-next-page"] break if next_page.empty? page = next_page end end
url(page)
click to toggle source
# File lib/hound_list_sync/repositories/gitlab.rb, line 93 def url(page) format(@url_template, base: @api_endpoint, page: page) end