Class: Tinybucket::Client

Inherits:
Object
  • Object
show all
Includes:
Model::Concerns::Enumerable
Defined in:
lib/tinybucket/client.rb

Instance Method Summary collapse

Instance Method Details

#repo(owner, repo_slug) ⇒ Tinybucket::Model::Repository

Get the repository

Parameters:

  • owner (String)

    repository owner name.

  • repo_slug (String)

Returns:


48
49
50
51
52
53
# File 'lib/tinybucket/client.rb', line 48

def repo(owner, repo_slug)
  Tinybucket::Model::Repository.new({}).tap do |m|
    m.repo_owner = owner
    m.repo_slug = repo_slug
  end
end

#repos(owner, options) ⇒ Tinybucket::Resource::Repos #repos(options) ⇒ Tinybucket::Resource::Repos

Get Repositories

when you want to get repositories of the owner, call with owner, options. ex) repos('owner', options) or repos('owner')

when you want to get public repositories of the owner, call with options. ex) repos(options) or repos

Overloads:

  • #repos(owner, options) ⇒ Tinybucket::Resource::Repos

    get the repositories of the owner.

    Parameters:

    • owner (String, Symbol)

      string or symbol to describe the owner.

    Options Hash (options):

    • a (Hash)

      hash with options

  • #repos(options) ⇒ Tinybucket::Resource::Repos

    get public repositories.

    Options Hash (options):

    • a (Hash)

      hash with options

Returns:


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tinybucket/client.rb', line 23

def repos(*args)
  case args.size
  when 0
    public_repos
  when 1
    case args.first
    when Hash           then public_repos(args.first)
    when String, Symbol then owners_repos(args.first)
    else                     raise ArgumentError
    end
  when 2
    case args.first
    when String, Symbol then owners_repos(args[0], args[1])
    else                     raise ArgumentError
    end
  else
    raise ArgumentError
  end
end

#team(teamname) ⇒ Tinybucket::Model::Team

Get the team

Parameters:

  • teamname (String)

    the team name.

Returns:


68
69
70
71
72
# File 'lib/tinybucket/client.rb', line 68

def team(teamname)
  Tinybucket::Model::Team.new({}).tap do |m|
    m.username = teamname
  end
end

#teams(role_name, options = {}) ⇒ Tinybucket::Resource::Teams

Get teams

Parameters:

  • role_name (String)

    role name (one of “admin”, “contributor”, or “member”)

  • options (defaults to: {})

Returns:


60
61
62
# File 'lib/tinybucket/client.rb', line 60

def teams(role_name, options = {})
  Tinybucket::Resource::Teams.new(role_name, options)
end

#user(username) ⇒ Tinybucket::Model::Profile

Get the user profile

Parameters:

  • username (String)

    the user name.

Returns:


78
79
80
81
82
# File 'lib/tinybucket/client.rb', line 78

def user(username)
  Tinybucket::Model::Profile.new({}).tap do |m|
    m.username = username
  end
end