Class: GithubClient
- Inherits:
-
Object
- Object
- GithubClient
- Defined in:
- lib/w-stdlib/github_client.rb
Instance Method Summary collapse
-
#initialize(username = '', base_url = 'https://api.github.com') ⇒ GithubClient
constructor
A new instance of GithubClient.
- #repos ⇒ Object
- #repos_for_org(org) ⇒ Object
- #user_perms(owner, repo, username) ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(username = '', base_url = 'https://api.github.com') ⇒ GithubClient
Returns a new instance of GithubClient.
11 12 13 14 |
# File 'lib/w-stdlib/github_client.rb', line 11 def initialize(username='', base_url='https://api.github.com') @url = URI.parse base_url @username = username end |
Instance Method Details
#repos ⇒ Object
16 17 18 |
# File 'lib/w-stdlib/github_client.rb', line 16 def repos paginate('/repositories') end |
#repos_for_org(org) ⇒ Object
20 21 22 |
# File 'lib/w-stdlib/github_client.rb', line 20 def repos_for_org(org) paginate("/orgs/#{org}/repos") end |
#user_perms(owner, repo, username) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/w-stdlib/github_client.rb', line 28 def user_perms(owner, repo, username) url = @url.clone url.path = "/repos/#{owner}/#{repo}/collaborators/#{username}/permission" auth = {user: @username, pass: token} puts url.to_s HTTP.basic_auth(auth) .headers({"Accept" => "application/vnd.github.v3+json"}) .get(url.to_s) .to_s end |
#users ⇒ Object
24 25 26 |
# File 'lib/w-stdlib/github_client.rb', line 24 def users paginate('/users') end |