lib/github_api/issues/labels.rb in github_api-0.7.0 vs lib/github_api/issues/labels.rb in github_api-0.7.1
- old
+ new
@@ -8,22 +8,20 @@
# Creates new Issues::Labels API
def initialize(options = {})
super(options)
end
- # TODO Merge repository, issues and milesonte labels insdie one query
-
# List all labels for a repository
#
# = Examples
# github = Github.new :user => 'user-name', :repo => 'repo-name'
# github.issues.labels.list
# github.issues.labels.list { |label| ... }
#
def list(user_name, repo_name, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
+ assert_presence_of user, repo
normalize! params
response = get_request("/repos/#{user}/#{repo}/labels", params)
return response unless block_given?
response.each { |el| yield el }
@@ -36,12 +34,11 @@
# github = Github.new
# github.issues.labels.find 'user-name', 'repo-name', 'label-id'
#
def get(user_name, repo_name, label_id, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of label_id
+ assert_presence_of user, repo, label_id
normalize! params
get_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
end
alias :find :get
@@ -56,11 +53,11 @@
# github = Github.new :user => 'user-name', :repo => 'repo-name'
# github.issues.labels.create :name => 'API', :color => 'FFFFFF'
#
def create(user_name, repo_name, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
+ assert_presence_of user, repo
normalize! params
filter! VALID_LABEL_INPUTS, params
assert_required_keys(VALID_LABEL_INPUTS, params)
@@ -78,12 +75,11 @@
# @github.issues.labels.update 'user-name', 'repo-name', 'label-id',
# :name => 'API', :color => "FFFFFF"
#
def update(user_name, repo_name, label_id, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of label_id
+ assert_presence_of user, repo, label_id
normalize! params
filter! VALID_LABEL_INPUTS, params
assert_required_keys(VALID_LABEL_INPUTS, params)
@@ -97,13 +93,13 @@
# github = Github.new
# github.issues.labels.delete 'user-name', 'repo-name', 'label-id'
#
def delete(user_name, repo_name, label_id, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
+ assert_presence_of user, repo
- _validate_presence_of label_id
+ assert_presence_of label_id
normalize! params
delete_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
end
@@ -113,12 +109,11 @@
# @github = Github.new
# @github.issues.labels.issue 'user-name', 'repo-name', 'issue-id'
#
def issue(user_name, repo_name, issue_id, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of(issue_id)
+ assert_presence_of user, repo, issue_id
normalize! params
get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
end
@@ -131,12 +126,11 @@
def add(user_name, repo_name, issue_id, *args)
params = args.extract_options!
params['data'] = args unless args.empty?
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of(issue_id)
+ assert_presence_of user, repo, issue_id
normalize! params
post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
end
alias :<< :add
@@ -152,12 +146,11 @@
# github = Github.new
# github.issues.labels.remove 'user-name', 'repo-name', 'issue-id'
#
def remove(user_name, repo_name, issue_id, label_id=nil, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of issue_id
+ assert_presence_of user, repo, issue_id
normalize! params
if label_id
delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params)
else
@@ -176,12 +169,11 @@
def replace(user_name, repo_name, issue_id, *args)
params = args.extract_options!
params['data'] = args unless args.empty?
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of issue_id
+ assert_presence_of user, repo, issue_id
normalize! params
put_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
end
@@ -191,11 +183,10 @@
# github = Github.new
# github.issues.labels. 'user-name', 'repo-name', 'milestone-id'
#
def milestone(user_name, repo_name, milestone_id, params={})
_update_user_repo_params(user_name, repo_name)
- _validate_user_repo_params(user, repo) unless user? && repo?
- _validate_presence_of milestone_id
+ assert_presence_of user, repo, milestone_id
normalize! params
response = get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
return response unless block_given?
response.each { |el| yield el }