Module: Octoplex::Client::Root

Included in:
Octoplex::Client
Defined in:
lib/octoplex/client/root.rb

Instance Method Summary collapse

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()
  Octoplex::API::Organisation.find()
end

#repos(*user_and_repo) ⇒ Object Also known as: repo, repositories, repository

GET /repos/:user/:repo

Accepts either a user name and repo name as 2 arguments or one. Example:

Octoplex.repo('ivanvanderbyl/cloudist')
Octoplex.repo('ivanvanderbyl', 'cloudist')


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

#user(login = nil) ⇒ Object

Get a single user

API: GET /user

GET /users/:login


9
10
11
12
13
14
15
# File 'lib/octoplex/client/root.rb', line 9

def user(=nil)
  if 
    users()
  else
    Octoplex::Client::User.new(self, get("/user"))
  end
end

#users(login) ⇒ Object

GET /users/:user



18
19
20
# File 'lib/octoplex/client/root.rb', line 18

def users()
  Octoplex::Client::User.new(self, get("/users/#{}"))
end