Module: Octoplex::Client::Root
- Included in:
- Octoplex::Client
- Defined in:
- lib/octoplex/client/root.rb
Instance Method Summary collapse
-
#orgs(login) ⇒ Object
(also: #organisations, #organizations)
GET /orgs/:org/repos.
-
#repos(*user_and_repo) ⇒ Object
(also: #repo, #repositories, #repository)
GET /repos/:user/:repo.
-
#user(login = nil) ⇒ Object
Get a single user.
-
#users(login) ⇒ Object
GET /users/:user.
Instance Method Details
#orgs(login) ⇒ Object Also known as: organisations, organizations
GET /orgs/:org/repos
29 30 31 |
# File 'lib/octoplex/client/root.rb', line 29 def orgs(login) Octoplex::API::Organisation.find(login) end |
#repos(*user_and_repo) ⇒ Object Also known as: repo, repositories, repository
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/octoplex/client/root.rb', line 48 def repos(*user_and_repo) if user_and_repo.size == 2 # We've been supplied two arguments user = user_and_repo[0] repo = user_and_repo[1] elsif user_and_repo.first.is_a?(String) && !user_and_repo.first.index('/').nil? # We've been supplied a string like "ivanvanderbyl/cloudist" user, repo = user_and_repo[0].split('/', 2) elsif user_and_repo.size == 1 # We've been supplied one argument, probably a username user = user_and_repo[0] repo = nil else raise ArgumentError, "Unknown arguments: #{user_and_repo.split(', ')}" end if repo.nil? path = "/users/#{user}/repos" else path = "/repos/#{user}/#{repo}" end data = get(path) if data.is_a?(Array) data.map { |o| Octoplex::Client::Repository.new(self, o) } else Octoplex::Client::Repository.new(self, data) end end |