Class: Github::Client::Repos
Defined Under Namespace
Classes: Branches, Collaborators, Comments, Commits, Contents, Deployments, Downloads, Forks, Hooks, Keys, Merging, Pages, Projects, PubSubHubbub, Releases, Statistics, Statuses
Constant Summary collapse
- REQUIRED_REPO_OPTIONS =
%w[ name ]
- VALID_REPO_OPTIONS =
%w[ name description homepage private has_issues has_wiki has_downloads team_id auto_init gitignore_template default_branch ].freeze
- VALID_REPO_TYPES =
%w[ all public private member ].freeze
Constants included from MimeType
Constants included from Github::Constants
Github::Constants::ACCEPT, Github::Constants::ACCEPTED_OAUTH_SCOPES, Github::Constants::ACCEPT_CHARSET, Github::Constants::CACHE_CONTROL, Github::Constants::CONTENT_LENGTH, Github::Constants::CONTENT_TYPE, Github::Constants::DATE, Github::Constants::ETAG, Github::Constants::HEADER_LAST, Github::Constants::HEADER_LINK, Github::Constants::HEADER_NEXT, Github::Constants::LOCATION, Github::Constants::META_FIRST, Github::Constants::META_LAST, Github::Constants::META_NEXT, Github::Constants::META_PREV, Github::Constants::META_REL, Github::Constants::OAUTH_SCOPES, Github::Constants::PARAM_PAGE, Github::Constants::PARAM_PER_PAGE, Github::Constants::PARAM_START_PAGE, Github::Constants::RATELIMIT_LIMIT, Github::Constants::RATELIMIT_REMAINING, Github::Constants::RATELIMIT_RESET, Github::Constants::SERVER, Github::Constants::USER_AGENT
Instance Attribute Summary
Attributes inherited from API
Instance Method Summary collapse
-
#contributors(*args) ⇒ Object
(also: #list_contributors, #contribs)
List contributors.
-
#create(*args) ⇒ Object
Create a new repository for the autheticated user.
-
#delete(*args) ⇒ Object
(also: #remove)
Delete a repository.
-
#edit(*args) ⇒ Object
Edit a repository.
-
#get(*args) ⇒ Object
(also: #find)
Get a repository.
-
#get_by_id(*args) ⇒ Object
(also: #find_by_id)
Get a repository.
-
#languages(*args) ⇒ Object
(also: #list_languages)
List languages.
-
#list(*args) ⇒ Object
(also: #all)
List repositories for the authenticated user.
-
#tags(*args) ⇒ Object
(also: #list_tags, #repo_tags, #repository_tags)
List tags.
-
#teams(*args) ⇒ Object
(also: #list_teams, #repo_teams, #repository_teams)
List teams.
Methods inherited from API
after_callbacks, after_request, #api_methods_in, #arguments, before_callbacks, before_request, clear_request_methods!, #disable_redirects, #execute, extend_with_actions, extra_methods, #extract_basic_auth, extract_class_name, #filter_callbacks, inherited, #initialize, internal_methods, method_added, #method_missing, #module_methods_in, namespace, request_methods, require_all, #respond_to?, root!, #run_callbacks, #set, #yield_or_eval
Methods included from Request::Verbs
#delete_request, #get_request, #head_request, #options_request, #patch_request, #post_request, #put_request
Methods included from RateLimit
#ratelimit, #ratelimit_remaining, #ratelimit_reset
Methods included from MimeType
Methods included from Authorization
#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token
Constructor Details
This class inherits a constructor from Github::API
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Github::API
Instance Method Details
#contributors(*args) ⇒ Object Also known as: list_contributors, contribs
List contributors
283 284 285 286 287 288 289 290 291 |
# File 'lib/github_api/client/repos.rb', line 283 def contributors(*args) arguments(args, required: [:user, :repo]) do permit %w[ anon ] end response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#create(*args) ⇒ Object
Create a new repository for the autheticated user.
Create a new repository in this organisation. The authenticated user must be a member of this organisation
240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/github_api/client/repos.rb', line 240 def create(*args) arguments(args) do assert_required %w[ name ] end params = arguments.params # Requires authenticated user if (org = params.delete('org') || org) post_request("/orgs/#{org}/repos", params) else post_request("/user/repos", params) end end |
#delete(*args) ⇒ Object Also known as: remove
Delete a repository
Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required.
264 265 266 267 268 |
# File 'lib/github_api/client/repos.rb', line 264 def delete(*args) arguments(args, required: [:user, :repo]) delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params) end |
#edit(*args) ⇒ Object
Edit a repository
325 326 327 328 329 330 331 332 |
# File 'lib/github_api/client/repos.rb', line 325 def edit(*args) arguments(args, required: [:user, :repo]) do permit VALID_REPO_OPTIONS assert_required %w[ name ] end patch_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params) end |
#get(*args) ⇒ Object Also known as: find
Get a repository
164 165 166 167 168 |
# File 'lib/github_api/client/repos.rb', line 164 def get(*args) arguments(args, required: [:user, :repo]) get_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params) end |
#get_by_id(*args) ⇒ Object Also known as: find_by_id
Get a repository
179 180 181 182 183 |
# File 'lib/github_api/client/repos.rb', line 179 def get_by_id(*args) arguments(args, required: [:id]) get_request("/repositories/#{arguments.id}", arguments.params) end |
#languages(*args) ⇒ Object Also known as: list_languages
List languages
418 419 420 421 422 423 424 |
# File 'lib/github_api/client/repos.rb', line 418 def languages(*args) arguments(args, required: [:user, :repo]) response = get_request("/repos/#{arguments.user}/#{arguments.repo}/languages", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#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.
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([: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 |
#tags(*args) ⇒ Object Also known as: , ,
List tags
435 436 437 438 439 440 441 |
# File 'lib/github_api/client/repos.rb', line 435 def (*args) arguments(args, required: [:user, :repo]) response = get_request("/repos/#{arguments.user}/#{arguments.repo}/tags", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#teams(*args) ⇒ Object Also known as: list_teams, repo_teams, repository_teams
List teams
457 458 459 460 461 462 463 |
# File 'lib/github_api/client/repos.rb', line 457 def teams(*args) arguments(args, required: [:user, :repo]) response = get_request("/repos/#{arguments.user}/#{arguments.repo}/teams", arguments.params) return response unless block_given? response.each { |el| yield el } end |