class HoundListSync::Repositories::GithubOrg
Constants
- API_GITHUB_COM
- HEADERS
- URL_TEMPLATE
Public Class Methods
new( orgname, api_endpoint: nil, credentials: {}, url_template: URL_TEMPLATE, http: HoundListSync::Http::Net.new )
click to toggle source
# File lib/hound_list_sync/repositories/github_org.rb, line 60 def initialize( orgname, api_endpoint: nil, credentials: {}, url_template: URL_TEMPLATE, http: HoundListSync::Http::Net.new ) @orgname = orgname @api_endpoint = api_endpoint || API_GITHUB_COM @credentials = credentials @url_template = url_template @http = http end
Public Instance Methods
basic_auth()
click to toggle source
# File lib/hound_list_sync/repositories/github_org.rb, line 101 def basic_auth @basic_auth ||= if @credentials.any? [@credentials.fetch(:login), @credentials.fetch(:pass)] else [] end end
each() { |repo| ... }
click to toggle source
# File lib/hound_list_sync/repositories/github_org.rb, line 74 def each return to_enum unless block_given? page = 1 loop do repos = JSON.parse( @http .get(url(page), headers: HEADERS, basic_auth: basic_auth) .body ) break if repos.length.zero? repos.each do |repo| yield Repo.new(repo) end page += 1 end end
url(page)
click to toggle source
# File lib/hound_list_sync/repositories/github_org.rb, line 97 def url(page) format(@url_template, base: @api_endpoint, org: @orgname, page: page) end