lib/github_api/orgs/teams.rb in github_api-0.2.1 vs lib/github_api/orgs/teams.rb in github_api-0.2.2
- old
+ new
@@ -5,13 +5,13 @@
# All actions against teams require at a minimum an authenticated user
# who is a member of the owner’s team in the :org being managed.
# Api calls that require explicit permissions are noted.
module Teams
- VALID_TEAM_PARAM_NAMES = %w[ name repo_names permission ]
+ VALID_TEAM_PARAM_NAMES = %w[ name repo_names permission ].freeze
VALID_TEAM_PARAM_VALUES = {
- 'permission' => %w[ pull push admin ]
+ 'permission' => %w[ pull push admin ].freeze
}
# List teams
#
# = Examples
@@ -20,14 +20,15 @@
#
def teams(org_name, params={})
_validate_presence_of org_name
_normalize_params_keys(params)
- get("/orgs/#{org_name}/teams", params)
+ response = get("/orgs/#{org_name}/teams", params)
return response unless block_given?
response.each { |el| yield el }
end
+ alias :list_teams :teams
# Get a team
#
# = Examples
# @github = Github.new :oauth_token => '...'
@@ -37,10 +38,11 @@
_validate_presence_of team_name
_normalize_params_keys(params)
get("/teams/#{team_name}", params)
end
+ alias :get_team :team
# Create a team
#
# In order to create a team, the authenticated user must be an owner of<tt>:org</tt>.
# = Inputs
@@ -69,11 +71,11 @@
raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
post("/orgs/#{org_name}/teams", params)
end
- # Create a team
+ # Edit a team
# In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
#
# = Inputs
# <tt>:name</tt> - Required string
# <tt>:permission</tt> - Optional string
@@ -121,14 +123,15 @@
#
def team_members(team_name, params={})
_validate_presence_of team_name
_normalize_params_keys(params)
- response = get("/teams/:id/members", params)
+ response = get("/teams/#{team_name}/members", params)
return response unless block_given?
response.each { |el| yield el }
end
+ alias :list_team_members :team_members
# Check if a user is a member of a team
#
# = Examples
# @github = Github.new :oauth_token => '...'
@@ -153,10 +156,11 @@
def add_team_member(team_name, member_name, params={})
_validate_presence_of team_name, member_name
_normalize_params_keys(params)
put("/teams/#{team_name}/members/#{member_name}", params)
end
+ alias :add_member :add_team_member
# Remove a team member
# In order to remove a user from a team, the authenticated user must
# have ‘admin’ permissions to the team or be an owner of the org that
# the team is associated with.
@@ -169,40 +173,43 @@
def remove_team_member(team_name, member_name, params={})
_validate_presence_of team_name, member_name
_normalize_params_keys(params)
delete("/teams/#{team_name}/members/#{member_name}", params)
end
+ alias :remove_member :remove_team_member
# List team repositories
#
# = Examples
# @github = Github.new :oauth_token => '...'
# @github.orgs.team_repos 'team-name'
#
def team_repos(team_name, params={})
- _validate_presence_of team_name, member_name
+ _validate_presence_of team_name
_normalize_params_keys(params)
response = get("/teams/#{team_name}/repos", params)
return response unless block_given?
response.each { |el| yield el }
end
+ alias :team_repositories :team_repos
# Check if a repository belongs to a team
#
# = Examples
# @github = Github.new :oauth_token => '...'
- # @github.orgs.team_repo? 'team-name'
+ # @github.orgs.team_repo? 'team-name', 'user-name', 'repo-name'
#
def team_repo?(team_name, user_name, repo_name, params={})
_validate_presence_of team_name, user_name, repo_name
_normalize_params_keys(params)
get("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
true
rescue Github::ResourceNotFound
false
end
+ alias :team_repository? :team_repo?
# Add a team repository
# In order to add a repo to a team, the authenticated user must be
# an owner of the org that the team is associated with.
#
@@ -213,10 +220,11 @@
def add_team_repo(team_name, user_name, repo_name, params={})
_validate_presence_of team_name, user_name, repo_name
_normalize_params_keys(params)
put("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
end
+ alias :add_team_repository :add_team_repo
# Remove a team repository
# In order to add a repo to a team, the authenticated user must be
# an owner of the org that the team is associated with.
# note: This does not delete the repo, it just removes it from the team.
@@ -228,9 +236,10 @@
def remove_team_repo(team_name, user_name, repo_name, params={})
_validate_presence_of team_name, user_name, repo_name
_normalize_params_keys(params)
delete("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
end
+ alias :remove_team_repository :remove_team_repo
end # Teams
end # Orgs
end # Github