class GithubMembers::Client

Attributes

options[R]

Public Class Methods

new(options) click to toggle source
# File lib/github_members/client.rb, line 7
def initialize(options)
  @options = options

  Octokit.configure do |c|
    token = options.github_token
    c.access_token = token unless token.empty?
    c.auto_paginate = true
    c.per_page = 100
  end
end

Public Instance Methods

fetch_members(org) click to toggle source
# File lib/github_members/client.rb, line 18
def fetch_members(org)
  Octokit.organization_members(org).map do |gh_member|
    gh_user = Octokit.user(gh_member.login)
    fullname = gh_user.name.then { |name| name.to_s.empty? ? "" : name }

    {
      github: gh_member.login,
      fullname: fullname,
      avatar: gh_member.avatar_url
    }
  end
end
fetch_organization(org) click to toggle source
# File lib/github_members/client.rb, line 31
def fetch_organization(org)
  Octokit.organization(org).then do |gh_org|
    {
      name: gh_org.login,
      fullname: gh_org.name,
      url: gh_org.html_url
    }
  end
end