Class: Github::Client::Repos
Defined Under Namespace
Classes: 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
-
#branch(*args) ⇒ Object
Get branch.
-
#branches(*args) ⇒ Object
(also: #list_branches)
List branches.
-
#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, root!, #run_callbacks, #set, #yield_or_eval
Methods included from Github::ClassMethods
#configuration, #configure, #require_all
Methods included from RateLimit
#ratelimit, #ratelimit_remaining, #ratelimit_reset
Methods included from Request::Verbs
#delete_request, #get_request, #head_request, #options_request, #patch_request, #post_request, #put_request
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
#branch(*args) ⇒ Object
Get branch
376 377 378 379 380 |
# File 'lib/github_api/client/repos.rb', line 376 def branch(*args) arguments(args, required: [:user, :repo, :branch]) get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params) end |
#branches(*args) ⇒ Object Also known as: list_branches
List branches
359 360 361 362 363 364 365 |
# File 'lib/github_api/client/repos.rb', line 359 def branches(*args) arguments(args, required: [:user, :repo]) response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params) return response unless block_given? response.each { |el| yield el } end |
#contributors(*args) ⇒ Object Also known as: list_contributors, contribs
List contributors
277 278 279 280 281 282 283 284 285 286 |
# File 'lib/github_api/client/repos.rb', line 277 def contributors(*args) arguments(args, required: [:user, :repo]) do permit %w[ anon ] end params = arguments.params 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
234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/github_api/client/repos.rb', line 234 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.
258 259 260 261 262 |
# File 'lib/github_api/client/repos.rb', line 258 def delete(*args) arguments(args, required: [:user, :repo]) delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params) end |
#edit(*args) ⇒ Object
Edit a repository
320 321 322 323 324 325 326 327 |
# File 'lib/github_api/client/repos.rb', line 320 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
158 159 160 161 162 |
# File 'lib/github_api/client/repos.rb', line 158 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
173 174 175 176 177 |
# File 'lib/github_api/client/repos.rb', line 173 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
414 415 416 417 418 419 420 |
# File 'lib/github_api/client/repos.rb', line 414 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.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/github_api/client/repos.rb', line 126 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
431 432 433 434 435 436 437 |
# File 'lib/github_api/client/repos.rb', line 431 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
453 454 455 456 457 458 459 |
# File 'lib/github_api/client/repos.rb', line 453 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 |