Method: Github::Client::Repos#list

Defined in:
lib/github_api/client/repos.rb

#list(*args) ⇒ Object Also known as: all

List repositories for the authenticated user

List all repositories

This provides a dump of every repository, in the order that they were created.

List public repositories for the specified user.

List repositories for the specified organisation.

Examples:

github = Github.new oauth_token: '...'
github.repos.list
github.repos.list { |repo| ... }
github = Github.new
github.repos.list :every
github.repos.list :every { |repo| ... }
github = Github.new
github.repos.list user: 'user-name'
github.repos.list user: 'user-name', { |repo| ... }
github = Github.new
github.repos.list org: 'org-name'
github.repos.list org: 'org-name', { |repo| ... }

Parameters:



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/github_api/client/repos.rb', line 132

def list(*args)
  arguments(args) do
    permit %w[ user org type sort direction since ]
  end
  params = arguments.params
  unless params.symbolize_keys[:per_page]
    params.merge!(Pagination.per_page_as_param(current_options[:per_page]))
  end

  response = if (user_name = params.delete('user') || user)
    get_request("/users/#{user_name}/repos", params)
  elsif (org_name = params.delete('org') || org)
    get_request("/orgs/#{org_name}/repos", params)
  elsif args.map(&:to_s).include?('every')
    get_request('/repositories', params)
  else
    # For authenticated user
    get_request('/user/repos', params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end