Class: GithubMembers::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/github_members/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
# 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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/github_members/client.rb', line 5

def options
  @options
end

Instance Method Details

#fetch_members(org) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# 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.)
    fullname = gh_user.name.then { |name| name.to_s.empty? ? "" : name }

    {
      github: gh_member.,
      fullname: fullname,
      avatar: gh_member.avatar_url
    }
  end
end

#fetch_organization(org) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/github_members/client.rb', line 31

def fetch_organization(org)
  Octokit.organization(org).then do |gh_org|
    {
      name: gh_org.,
      fullname: gh_org.name,
      url: gh_org.html_url
    }
  end
end