Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add yard docs to Repositories methods. Closes #147. #153

Merged
merged 1 commit into from

2 participants

Joey Wendt Wynn Netherland
Joey Wendt
Collaborator

edit: messed up the closes #147 in the commit comment. ><

Wynn Netherland pengwynn merged commit 6bb388f into from
Wynn Netherland
Owner

:metal:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2012
  1. Joey Wendt
This page is out of date. Refresh to see the latest.
Showing with 307 additions and 1 deletion.
  1. +307 −1 lib/octokit/client/repositories.rb
308 lib/octokit/client/repositories.rb
View
@@ -186,73 +186,254 @@ def set_public(repo, options={})
update_repository repo, options.merge({ :private => false })
end
+ # Get deploy keys on a repo
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository
+ # @return [Array<Hashie::Mash>] Array of hashes representing deploy keys.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/keys/#get
+ # @example
+ # @client.deploy_keys('pengwynn/octokit')
+ # @example
+ # @client.list_deploy_keys('pengwynn/octokit')
def deploy_keys(repo, options={})
get "repos/#{Repository.new repo}/keys", options, 3
end
alias :list_deploy_keys :deploy_keys
+ # Add deploy key to a repo
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param title [String] Title reference for the deploy key.
+ # @param key [String] Public key.
+ # @return [Hashie::Mash] Hash representing newly added key.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/keys/#create
+ # @example
+ # @client.add_deploy_key('pengwynn/octokit', 'Staging server', 'ssh-rsa AAA...')
def add_deploy_key(repo, title, key, options={})
post "repos/#{Repository.new repo}/keys", options.merge(:title => title, :key => key), 3
end
+ # Remove deploy key from a repo
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param id [Integer] Id of the deploy key to remove.
+ # @return [Boolean] True if key removed, false otherwise.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/keys/#delete
+ # @example
+ # @client.remove_deploy_key('pengwynn/octokit', 100000)
def remove_deploy_key(repo, id, options={})
delete "repos/#{Repository.new repo}/keys/#{id}", options, 3
end
+ # List collaborators
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing collaborating users.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/collaborators/#list
+ # @example
+ # Octokit.collaborators('pengwynn/octokit')
+ # @example
+ # Octokit.collabs('pengwynn/octokit')
+ # @example
+ # @client.collabs('pengwynn/octokit')
def collaborators(repo, options={})
get "repos/#{Repository.new repo}/collaborators", options, 3
end
alias :collabs :collaborators
+ # Add collaborator to repo
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param collaborator [String] Collaborator GitHub username to add.
+ # @return [Boolean] True if collaborator added, false otherwise.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/collaborators/#add-collaborator
+ # @example
+ # @client.add_collaborator('pengwynn/octokit', 'holman')
+ # @example
+ # @client.add_collab('pengwynn/octokit', 'holman')
def add_collaborator(repo, collaborator, options={})
put "repos/#{Repository.new repo}/collaborators/#{collaborator}", options, 3
end
alias :add_collab :add_collaborator
+ # Remove collaborator from repo.
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param collaborator [String] Collaborator GitHub username to remove.
+ # @return [Boolean] True if collaborator removed, false otherwise.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/collaborators/#remove-collaborator
+ # @example
+ # @client.remove_collaborator('pengwynn/octokit', 'holman')
+ # @example
+ # @client.remove_collab('pengwynn/octokit', 'holman')
def remove_collaborator(repo, collaborator, options={})
delete "repos/#{Repository.new repo}/collaborators/#{collaborator}", options, 3
end
alias :remove_collab :remove_collaborator
+ # List teams for a repo
+ #
+ # Requires authenticated client that is an owner or collaborator of the repo.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing teams.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/#list-teams
+ # @example
+ # @client.repository_teams('octokit/pengwynn')
+ # @example
+ # @client.repo_teams('octokit/pengwynn')
+ # @example
+ # @client.teams('octokit/pengwynn')
def repository_teams(repo, options={})
get "repos/#{Repository.new repo}/teams", options, 3
end
alias :repo_teams :repository_teams
alias :teams :repository_teams
+ # List contributors to a repo
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param anon [Boolean] Set true to include annonymous contributors.
+ # @return [Array<Hashie::Mash>] Array of hashes representing users.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/#list-contributors
+ # @example
+ # Octokit.contributors('pengwynn/octokit', true)
+ # @example
+ # Octokit.contribs('pengwynn/octokit')
+ # @example
+ # @client.contribs('pengwynn/octokit')
def contributors(repo, anon=false, options={})
get "repos/#{Repository.new repo}/contributors", options.merge(:anon => anon), 3
end
alias :contribs :contributors
+ # List stargazers of a repo
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing users.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/starring/#list-stargazers
+ # @example
+ # Octokit.stargazers('pengwynn/octokit')
+ # @example
+ # @client.stargazers('pengwynn/octokit')
def stargazers(repo, options={})
get "repos/#{Repository.new repo}/stargazers", options, 3
end
+ # @deprecated Use #stargazers instead
+ #
+ # List watchers of repo.
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing users.
+ # @see Octokit::Client::Repositories#stargazers
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/watching/#list-watchers
+ # @example
+ # Octokit.watchers('pengwynn/octokit')
+ # @example
+ # @client.watchers('pengwynn/octokit')
def watchers(repo, options={})
get "repos/#{Repository.new repo}/watchers", options, 3
end
+ # List forks
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing repos.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/forks/#list-forks
+ # @example
+ # Octokit.forks('pengwynn/octokit')
+ # @example
+ # Octokit.network('pengwynn/octokit')
+ # @example
+ # @client.forks('pengwynn/octokit')
def forks(repo, options={})
get "repos/#{Repository.new repo}/forks", options, 3
end
alias :network :forks
+ # List languages of code in the repo.
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of Hashes representing languages.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/#list-languages
+ # @example
+ # Octokit.langauges('pengwynn/octokit')
+ # @example
+ # @client.languages('pengwynn/octokit')
def languages(repo, options={})
get "repos/#{Repository.new repo}/languages", options, 3
end
+ # List tags
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing tags.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/#list-tags
+ # @example
+ # Octokit.tags('pengwynn/octokit')
+ # @example
+ # @client.tags('pengwynn/octokit')
def tags(repo, options={})
get "repos/#{Repository.new repo}/tags", options, 3
end
+ # List branches
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing branches.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/#list-branches
+ # @example
+ # Octokit.branches('pengwynn/octokit')
+ # @example
+ # @client.branches('pengwynn/octokit')
def branches(repo, options={})
get "repos/#{Repository.new repo}/branches", options, 3
end
# Get a single branch from a repository
#
- # @param repo [String, Repository, Hash] A GitHub repository
+ # @param repo [String, Hash, Repository] A GitHub repository.
# @param branch [String] Branch name
# @return [Branch] The branch requested, if it exists
# @see http://developer.github.com/v3/repos/#get-branch
@@ -263,28 +444,139 @@ def branch(repo, branch, options={})
end
alias :get_branch :branch
+ # List repo hooks
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @return [Array<Hashie::Mash>] Array of hashes representing hooks.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/hooks/#list
+ # @example
+ # @client.hooks('pengwynn/octokit')
def hooks(repo, options={})
get "repos/#{Repository.new repo}/hooks", options, 3
end
+ # Get single hook
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param id [Integer] Id of the hook to get.
+ # @return [Hashie::Mash] Hash representing hook.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/hooks/#get-single-hook
+ # @example
+ # @client.hook('pengwynn/octokit', 100000)
def hook(repo, id, options={})
get "repos/#{Repository.new repo}/hooks/#{id}", options, 3
end
+ # Create a hook
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param name [String] The name of the service that is being called. See
+ # {https://api.github.com/hooks Hooks} for the possible names.
+ # @param config [Hash] A Hash containing key/value pairs to provide
+ # settings for this hook. These settings vary between the services and
+ # are defined in the {https://github.com/github/github-services github-services} repo.
+ # @option options [Array<String>] :events ('["push"]') Determines what
+ # events the hook is triggered for.
+ # @option options [Boolean] :active Determines whether the hook is
+ # actually triggered on pushes.
+ # @see Octokit::Client
+ # @see https://api.github.com/hooks
+ # @see https://github.com/github/github-services
+ # @see http://developer.github.com/v3/repos/hooks/#create-a-hook
+ # @example
+ # @client.create_hook(
+ # 'pengwynn/octokit',
+ # 'web',
+ # {
+ # :url => 'http://something.com/webhook',
+ # :content_type => 'json'
+ # },
+ # {
+ # :events => ['push', 'pull_request'],
+ # :active => true
+ # }
+ # )
def create_hook(repo, name, config, options={})
options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
post "repos/#{Repository.new repo}/hooks", options, 3
end
+ # Edit a hook
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param id [Integer] Id of the hook being updated.
+ # @param name [String] The name of the service that is being called. See
+ # {https://api.github.com/hooks Hooks} for the possible names.
+ # @param config [Hash] A Hash containing key/value pairs to provide
+ # settings for this hook. These settings vary between the services and
+ # are defined in the {https://github.com/github/github-services github-services} repo.
+ # @option options [Array<String>] :events ('["push"]') Determines what
+ # events the hook is triggered for.
+ # @option options [Array<String>] :add_events Determines a list of events
+ # to be added to the list of events that the Hook triggers for.
+ # @option options [Array<String>] :remove_events Determines a list of events
+ # to be removed from the list of events that the Hook triggers for.
+ # @option options [Boolean] :active Determines whether the hook is
+ # actually triggered on pushes.
+ # @see Octokit::Client
+ # @see https://api.github.com/hooks
+ # @see https://github.com/github/github-services
+ # @see http://developer.github.com/v3/repos/hooks/#edit-a-hook
+ # @example
+ # @client.edit_hook(
+ # 'pengwynn/octokit',
+ # 'web',
+ # {
+ # :url => 'http://something.com/webhook',
+ # :content_type => 'json'
+ # },
+ # {
+ # :add_events => ['status'],
+ # :remove_events => ['pull_request'],
+ # :active => true
+ # }
+ # )
def edit_hook(repo, id, name, config, options={})
options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
patch "repos/#{Repository.new repo}/hooks/#{id}", options, 3
end
+ # Delete hook
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param id [Integer] Id of the hook to remove.
+ # @return [Boolean] True if hook removed, false otherwise.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/hooks/#delete-a-hook
+ # @example
+ # @client.remove_hook('pengwynn/octokit', 1000000)
def remove_hook(repo, id, options={})
delete "repos/#{Repository.new repo}/hooks/#{id}", options, 3
end
+ # Test hook
+ #
+ # Requires authenticated client.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @param id [Integer] Id of the hook to test.
+ # @return [nil]
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/repos/hooks/#test-a-hook
+ # @example
+ # @client.test_hook('pengwynn/octokit', 1000000)
def test_hook(repo, id, options={})
post "repos/#{Repository.new repo}/hooks/#{id}/test", options, 3
end
@@ -302,6 +594,20 @@ def repository_issue_events(repo, options={})
end
alias :repo_issue_events :repository_issue_events
+ # List users available for assigning to issues.
+ #
+ # Requires authenticated client for private repos.
+ #
+ # @param repo [String, Hash, Repository] A GitHub repository.
+ # @returns [Array<Hashie::Mash>] Array of hashes representing users.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/issues/assignees/#list-assignees
+ # @example
+ # Octokit.repository_assignees('pengwynn/octokit')
+ # @example
+ # Octokit.repo_assignees('pengwynn/octokit')
+ # @example
+ # @client.repository_assignees('pengwynn/octokit')
def repository_assignees(repo, options={})
get "repos/#{Repository.new repo}/assignees", options, 3
end
Something went wrong with that request. Please try again.