github_api 0.4.11 → 0.5.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
|
@@ -1,202 +1,205 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Issues
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
class Issues::Labels < API
|
|
5
|
+
|
|
6
|
+
VALID_LABEL_INPUTS = %w[ name color ].freeze
|
|
7
|
+
|
|
8
|
+
# Creates new Issues::Labels API
|
|
9
|
+
def initialize(options = {})
|
|
10
|
+
super(options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# TODO Merge repository, issues and milesonte labels insdie one query
|
|
14
|
+
|
|
15
|
+
# List all labels for a repository
|
|
16
|
+
#
|
|
17
|
+
# = Examples
|
|
18
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
|
19
|
+
# github.issues.labels.list
|
|
20
|
+
# github.issues.labels.list { |label| ... }
|
|
21
|
+
#
|
|
22
|
+
def list(user_name, repo_name, params={})
|
|
23
|
+
_update_user_repo_params(user_name, repo_name)
|
|
24
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
25
|
+
_normalize_params_keys(params)
|
|
26
|
+
|
|
27
|
+
response = get_request("/repos/#{user}/#{repo}/labels", params)
|
|
28
|
+
return response unless block_given?
|
|
29
|
+
response.each { |el| yield el }
|
|
30
|
+
end
|
|
31
|
+
alias :all :list
|
|
32
|
+
|
|
33
|
+
# Get a single label
|
|
34
|
+
#
|
|
35
|
+
# = Examples
|
|
36
|
+
# github = Github.new
|
|
37
|
+
# github.issues.labels.find 'user-name', 'repo-name', 'label-id'
|
|
38
|
+
#
|
|
39
|
+
def get(user_name, repo_name, label_id, params={})
|
|
40
|
+
_update_user_repo_params(user_name, repo_name)
|
|
41
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
42
|
+
_validate_presence_of label_id
|
|
43
|
+
_normalize_params_keys(params)
|
|
44
|
+
|
|
45
|
+
get_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
|
46
|
+
end
|
|
47
|
+
alias :find :get
|
|
48
|
+
|
|
49
|
+
# Create a label
|
|
50
|
+
#
|
|
51
|
+
# = Inputs
|
|
52
|
+
# <tt>:name</tt> - Required string
|
|
53
|
+
# <tt>:color</tt> - Required string - 6 character hex code, without leading #
|
|
54
|
+
#
|
|
55
|
+
# = Examples
|
|
56
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
|
57
|
+
# github.issues.labels.create :name => 'API', :color => 'FFFFFF'
|
|
58
|
+
#
|
|
59
|
+
def create(user_name, repo_name, params={})
|
|
60
|
+
_update_user_repo_params(user_name, repo_name)
|
|
61
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
62
|
+
|
|
63
|
+
_normalize_params_keys(params)
|
|
64
|
+
_filter_params_keys(VALID_LABEL_INPUTS, params)
|
|
65
|
+
_validate_inputs(VALID_LABEL_INPUTS, params)
|
|
66
|
+
|
|
67
|
+
post_request("/repos/#{user}/#{repo}/labels", params)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Update a label
|
|
71
|
+
#
|
|
72
|
+
# = Inputs
|
|
73
|
+
# <tt>:name</tt> - Required string
|
|
74
|
+
# <tt>:color</tt> - Required string-6 character hex code, without leading #
|
|
75
|
+
#
|
|
76
|
+
# = Examples
|
|
77
|
+
# @github = Github.new
|
|
78
|
+
# @github.issues.labels.update 'user-name', 'repo-name', 'label-id',
|
|
79
|
+
# :name => 'API', :color => "FFFFFF"
|
|
80
|
+
#
|
|
81
|
+
def update(user_name, repo_name, label_id, params={})
|
|
82
|
+
_update_user_repo_params(user_name, repo_name)
|
|
83
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
84
|
+
_validate_presence_of label_id
|
|
85
|
+
|
|
86
|
+
_normalize_params_keys(params)
|
|
87
|
+
_filter_params_keys(VALID_LABEL_INPUTS, params)
|
|
88
|
+
_validate_inputs(VALID_LABEL_INPUTS, params)
|
|
89
|
+
|
|
90
|
+
patch_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
|
91
|
+
end
|
|
92
|
+
alias :edit :update
|
|
93
|
+
|
|
94
|
+
# Delete a label
|
|
95
|
+
#
|
|
96
|
+
# = Examples
|
|
97
|
+
# github = Github.new
|
|
98
|
+
# github.issues.labels.delete 'user-name', 'repo-name', 'label-id'
|
|
99
|
+
#
|
|
100
|
+
def delete(user_name, repo_name, label_id, params={})
|
|
101
|
+
_update_user_repo_params(user_name, repo_name)
|
|
102
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
103
|
+
|
|
104
|
+
_validate_presence_of label_id
|
|
105
|
+
_normalize_params_keys params
|
|
106
|
+
|
|
107
|
+
delete_request("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# List labels on an issue
|
|
111
|
+
#
|
|
112
|
+
# = Examples
|
|
113
|
+
# @github = Github.new
|
|
114
|
+
# @github.issues.labels.issue 'user-name', 'repo-name', 'issue-id'
|
|
115
|
+
#
|
|
116
|
+
def issue(user_name, repo_name, issue_id, params={})
|
|
117
|
+
_update_user_repo_params(user_name, repo_name)
|
|
118
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
119
|
+
_validate_presence_of(issue_id)
|
|
120
|
+
_normalize_params_keys(params)
|
|
121
|
+
|
|
122
|
+
get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Add labels to an issue
|
|
126
|
+
#
|
|
127
|
+
# = Examples
|
|
128
|
+
# github = Github.new
|
|
129
|
+
# github.issues.labels.add 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
|
130
|
+
#
|
|
131
|
+
def add(user_name, repo_name, issue_id, *args)
|
|
132
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
|
133
|
+
params['data'] = args unless args.empty?
|
|
134
|
+
|
|
135
|
+
_update_user_repo_params(user_name, repo_name)
|
|
136
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
137
|
+
_validate_presence_of(issue_id)
|
|
138
|
+
_normalize_params_keys(params)
|
|
139
|
+
|
|
140
|
+
post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
141
|
+
end
|
|
142
|
+
alias :<< :add
|
|
143
|
+
|
|
144
|
+
# Remove a label from an issue
|
|
145
|
+
#
|
|
146
|
+
# = Examples
|
|
147
|
+
# github = Github.new
|
|
148
|
+
# github.issues.labels.remove 'user-name', 'repo-name', 'issue-id', 'label-id'
|
|
149
|
+
#
|
|
150
|
+
# Remove all labels from an issue
|
|
151
|
+
# = Examples
|
|
152
|
+
# github = Github.new
|
|
153
|
+
# github.issues.labels.remove 'user-name', 'repo-name', 'issue-id'
|
|
154
|
+
#
|
|
155
|
+
def remove(user_name, repo_name, issue_id, label_id=nil, params={})
|
|
156
|
+
_update_user_repo_params(user_name, repo_name)
|
|
157
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
158
|
+
_validate_presence_of issue_id
|
|
159
|
+
_normalize_params_keys params
|
|
160
|
+
|
|
161
|
+
if label_id
|
|
162
|
+
delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params)
|
|
163
|
+
else
|
|
164
|
+
delete_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
24
165
|
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
# Update a label
|
|
65
|
-
#
|
|
66
|
-
# = Inputs
|
|
67
|
-
# <tt>:name</tt> - Required string
|
|
68
|
-
# <tt>:color</tt> - Required string - 6 character hex code, without leading #
|
|
69
|
-
#
|
|
70
|
-
# = Examples
|
|
71
|
-
# @github = Github.new
|
|
72
|
-
# @github.issues.update_label 'user-name', 'repo-name', 'label-id', :name => 'API', :color => "FFFFFF"
|
|
73
|
-
#
|
|
74
|
-
def update_label(user_name, repo_name, label_id, params={})
|
|
75
|
-
_update_user_repo_params(user_name, repo_name)
|
|
76
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
77
|
-
_validate_presence_of label_id
|
|
78
|
-
|
|
79
|
-
_normalize_params_keys(params)
|
|
80
|
-
_filter_params_keys(VALID_LABEL_INPUTS, params)
|
|
81
|
-
_validate_inputs(VALID_LABEL_INPUTS, params)
|
|
82
|
-
|
|
83
|
-
patch("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Delete a label
|
|
87
|
-
#
|
|
88
|
-
# = Examples
|
|
89
|
-
# @github = Github.new
|
|
90
|
-
# @github.issues.delete_label 'user-name', 'repo-name', 'label-id'
|
|
91
|
-
#
|
|
92
|
-
def delete_label(user_name, repo_name, label_id, params={})
|
|
93
|
-
_update_user_repo_params(user_name, repo_name)
|
|
94
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
95
|
-
|
|
96
|
-
_validate_presence_of label_id
|
|
97
|
-
_normalize_params_keys params
|
|
98
|
-
|
|
99
|
-
delete("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# List labels on an issue
|
|
103
|
-
#
|
|
104
|
-
# = Examples
|
|
105
|
-
# @github = Github.new
|
|
106
|
-
# @github.issues.labels_for 'user-name', 'repo-name', 'issue-id'
|
|
107
|
-
#
|
|
108
|
-
def labels_for(user_name, repo_name, issue_id, params={})
|
|
109
|
-
_update_user_repo_params(user_name, repo_name)
|
|
110
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
111
|
-
_validate_presence_of(issue_id)
|
|
112
|
-
_normalize_params_keys(params)
|
|
113
|
-
|
|
114
|
-
get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
115
|
-
end
|
|
116
|
-
alias :issue_labels :labels_for
|
|
117
|
-
|
|
118
|
-
# Add labels to an issue
|
|
119
|
-
#
|
|
120
|
-
# = Examples
|
|
121
|
-
# @github = Github.new
|
|
122
|
-
# @github.issues.add_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
|
123
|
-
#
|
|
124
|
-
def add_labels(user_name, repo_name, issue_id, *args)
|
|
125
|
-
params = args.last.is_a?(Hash) ? args.pop : {}
|
|
126
|
-
params['data'] = args unless args.empty?
|
|
127
|
-
|
|
128
|
-
_update_user_repo_params(user_name, repo_name)
|
|
129
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
130
|
-
_validate_presence_of(issue_id)
|
|
131
|
-
_normalize_params_keys(params)
|
|
132
|
-
|
|
133
|
-
post("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
134
|
-
end
|
|
135
|
-
alias :add_issue_labels :add_labels
|
|
136
|
-
|
|
137
|
-
# Remove a label from an issue
|
|
138
|
-
#
|
|
139
|
-
# = Examples
|
|
140
|
-
# @github = Github.new
|
|
141
|
-
# @github.issues.remove_label 'user-name', 'repo-name', 'issue-id', 'label-id'
|
|
142
|
-
#
|
|
143
|
-
# Remove all labels from an issue
|
|
144
|
-
# = Examples
|
|
145
|
-
# @github = Github.new
|
|
146
|
-
# @github.issues.remove_label 'user-name', 'repo-name', 'issue-id'
|
|
147
|
-
#
|
|
148
|
-
def remove_label(user_name, repo_name, issue_id, label_id=nil, params={})
|
|
149
|
-
_update_user_repo_params(user_name, repo_name)
|
|
150
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
151
|
-
_validate_presence_of issue_id
|
|
152
|
-
_normalize_params_keys params
|
|
153
|
-
|
|
154
|
-
if label_id
|
|
155
|
-
delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params)
|
|
156
|
-
else
|
|
157
|
-
delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
alias :remove_label_from_issue :remove_label
|
|
161
|
-
|
|
162
|
-
# Replace all labels for an issue
|
|
163
|
-
#
|
|
164
|
-
# Sending an empty array ([]) will remove all Labels from the Issue.
|
|
165
|
-
#
|
|
166
|
-
# = Examples
|
|
167
|
-
# @github = Github.new
|
|
168
|
-
# @github.issues.replace_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
|
169
|
-
#
|
|
170
|
-
def replace_labels(user_name, repo_name, issue_id, *args)
|
|
171
|
-
params = args.last.is_a?(Hash) ? args.pop : {}
|
|
172
|
-
params['data'] = args unless args.empty?
|
|
173
|
-
|
|
174
|
-
_update_user_repo_params(user_name, repo_name)
|
|
175
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
176
|
-
_validate_presence_of issue_id
|
|
177
|
-
_normalize_params_keys(params)
|
|
178
|
-
|
|
179
|
-
put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
# Get labels for every issue in a milestone
|
|
183
|
-
#
|
|
184
|
-
# = Examples
|
|
185
|
-
# @github = Github.new
|
|
186
|
-
# @github.issues.get_label 'user-name', 'repo-name', 'milestone-id'
|
|
187
|
-
#
|
|
188
|
-
def milestone_labels(user_name, repo_name, milestone_id, params={})
|
|
189
|
-
_update_user_repo_params(user_name, repo_name)
|
|
190
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
191
|
-
_validate_presence_of milestone_id
|
|
192
|
-
|
|
193
|
-
response = get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
|
|
194
|
-
return response unless block_given?
|
|
195
|
-
response.each { |el| yield el }
|
|
196
|
-
end
|
|
197
|
-
alias :milestone_issues_labels :milestone_labels
|
|
198
|
-
alias :list_milestone_labels :milestone_labels
|
|
199
|
-
|
|
200
|
-
end # Labels
|
|
201
|
-
end # Issues
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Replace all labels for an issue
|
|
169
|
+
#
|
|
170
|
+
# Sending an empty array ([]) will remove all Labels from the Issue.
|
|
171
|
+
#
|
|
172
|
+
# = Examples
|
|
173
|
+
# github = Github.new
|
|
174
|
+
# github.issues.labels.replace 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
|
175
|
+
#
|
|
176
|
+
def replace(user_name, repo_name, issue_id, *args)
|
|
177
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
|
178
|
+
params['data'] = args unless args.empty?
|
|
179
|
+
|
|
180
|
+
_update_user_repo_params(user_name, repo_name)
|
|
181
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
182
|
+
_validate_presence_of issue_id
|
|
183
|
+
_normalize_params_keys(params)
|
|
184
|
+
|
|
185
|
+
put_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Get labels for every issue in a milestone
|
|
189
|
+
#
|
|
190
|
+
# = Examples
|
|
191
|
+
# github = Github.new
|
|
192
|
+
# github.issues.labels. 'user-name', 'repo-name', 'milestone-id'
|
|
193
|
+
#
|
|
194
|
+
def milestone(user_name, repo_name, milestone_id, params={})
|
|
195
|
+
_update_user_repo_params(user_name, repo_name)
|
|
196
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
197
|
+
_validate_presence_of milestone_id
|
|
198
|
+
|
|
199
|
+
response = get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
|
|
200
|
+
return response unless block_given?
|
|
201
|
+
response.each { |el| yield el }
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end # Issues::Labels
|
|
202
205
|
end # Github
|
|
@@ -1,138 +1,141 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
module Github
|
|
4
|
-
class Issues
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
4
|
+
class Issues::Milestones < API
|
|
5
|
+
|
|
6
|
+
VALID_MILESTONE_OPTIONS = {
|
|
7
|
+
'state' => %w[ open closed ],
|
|
8
|
+
'sort' => %w[ due_date completeness ],
|
|
9
|
+
'direction' => %w[ desc asc ]
|
|
10
|
+
}.freeze # :nodoc:
|
|
11
|
+
|
|
12
|
+
VALID_MILESTONE_INPUTS = %w[
|
|
13
|
+
title
|
|
14
|
+
state
|
|
15
|
+
description
|
|
16
|
+
due_on
|
|
17
|
+
].freeze # :nodoc:
|
|
18
|
+
|
|
19
|
+
# Creates new Issues::Milestones API
|
|
20
|
+
def initialize(options = {})
|
|
21
|
+
super(options)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# List milestones for a repository
|
|
25
|
+
#
|
|
26
|
+
# = Parameters
|
|
27
|
+
# <tt>:state</tt> - <tt>open</tt>, <tt>closed</tt>, default: <tt>open</tt>
|
|
28
|
+
# <tt>:sort</tt> - <tt>due_date</tt>, <tt>completeness</tt>, default: <tt>due_date</tt>
|
|
29
|
+
# <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
|
|
30
|
+
#
|
|
31
|
+
# = Examples
|
|
32
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
|
33
|
+
# github.issues.milestones.list
|
|
34
|
+
#
|
|
35
|
+
# or
|
|
36
|
+
#
|
|
37
|
+
# github.issues.milestones.list :state => 'open',
|
|
38
|
+
# :sort => 'due_date',
|
|
39
|
+
# :direction => 'asc'
|
|
40
|
+
#
|
|
41
|
+
def list(user_name, repo_name, params={})
|
|
42
|
+
_update_user_repo_params(user_name, repo_name)
|
|
43
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
44
|
+
|
|
45
|
+
_normalize_params_keys(params)
|
|
46
|
+
_filter_params_keys(VALID_MILESTONE_OPTIONS.keys, params)
|
|
47
|
+
_validate_params_values(VALID_MILESTONE_OPTIONS, params)
|
|
48
|
+
|
|
49
|
+
response = get_request("/repos/#{user}/#{repo}/milestones", params)
|
|
50
|
+
return response unless block_given?
|
|
51
|
+
response.each { |el| yield el }
|
|
52
|
+
end
|
|
53
|
+
alias :all :list
|
|
54
|
+
|
|
55
|
+
# Get a single milestone
|
|
56
|
+
#
|
|
57
|
+
# = Examples
|
|
58
|
+
# github = Github.new
|
|
59
|
+
# github.issues.milestones.get 'user-name', 'repo-name', 'milestone-id'
|
|
60
|
+
#
|
|
61
|
+
def get(user_name, repo_name, milestone_id, params={})
|
|
62
|
+
_update_user_repo_params(user_name, repo_name)
|
|
63
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
64
|
+
_validate_presence_of milestone_id
|
|
65
|
+
_normalize_params_keys(params)
|
|
66
|
+
|
|
67
|
+
get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
|
68
|
+
end
|
|
69
|
+
alias :find :get
|
|
70
|
+
|
|
71
|
+
# Create a milestone
|
|
72
|
+
#
|
|
73
|
+
# = Inputs
|
|
74
|
+
# <tt>:title</tt> - Required string
|
|
75
|
+
# <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
|
|
76
|
+
# <tt>:description</tt> - Optional string
|
|
77
|
+
# <tt>:due_on</tt> - Optional string - ISO 8601 time
|
|
78
|
+
#
|
|
79
|
+
# = Examples
|
|
80
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
|
81
|
+
# github.issues.milestones.create :title => 'hello-world',
|
|
82
|
+
# :state => "open or closed",
|
|
83
|
+
# :description => "String",
|
|
84
|
+
# :due_on => "Time"
|
|
85
|
+
#
|
|
86
|
+
def create(user_name, repo_name, params={})
|
|
87
|
+
_update_user_repo_params(user_name, repo_name)
|
|
88
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
89
|
+
|
|
90
|
+
_normalize_params_keys(params)
|
|
91
|
+
_filter_params_keys(VALID_MILESTONE_INPUTS, params)
|
|
92
|
+
_validate_inputs(%w[ title ], params)
|
|
93
|
+
|
|
94
|
+
post_request("/repos/#{user}/#{repo}/milestones", params)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Update a milestone
|
|
98
|
+
#
|
|
99
|
+
# = Inputs
|
|
100
|
+
# <tt>:title</tt> - Required string
|
|
101
|
+
# <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
|
|
102
|
+
# <tt>:description</tt> - Optional string
|
|
103
|
+
# <tt>:due_on</tt> - Optional string - ISO 8601 time
|
|
104
|
+
#
|
|
105
|
+
# = Examples
|
|
106
|
+
# github = Github.new
|
|
107
|
+
# github.issues.milestones.update 'user-name', 'repo-name', 'milestone-id',
|
|
108
|
+
# :title => 'hello-world',
|
|
109
|
+
# :state => "open or closed",
|
|
110
|
+
# :description => "String",
|
|
111
|
+
# :due_on => "Time"
|
|
112
|
+
#
|
|
113
|
+
def update(user_name, repo_name, milestone_id, params={})
|
|
114
|
+
_update_user_repo_params(user_name, repo_name)
|
|
115
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
116
|
+
_validate_presence_of milestone_id
|
|
117
|
+
|
|
118
|
+
_normalize_params_keys(params)
|
|
119
|
+
_filter_params_keys(VALID_MILESTONE_INPUTS, params)
|
|
120
|
+
_validate_inputs(%w[ title ], params)
|
|
121
|
+
|
|
122
|
+
patch_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Delete a milestone
|
|
126
|
+
#
|
|
127
|
+
# = Examples
|
|
128
|
+
# github = Github.new
|
|
129
|
+
# github.issues.milestones.delete 'user-name', 'repo-name', 'milestone-id'
|
|
130
|
+
#
|
|
131
|
+
def delete(user_name, repo_name, milestone_id, params={})
|
|
132
|
+
_update_user_repo_params(user_name, repo_name)
|
|
133
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
|
134
|
+
_validate_presence_of milestone_id
|
|
135
|
+
_normalize_params_keys(params)
|
|
136
|
+
|
|
137
|
+
delete_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end # Issues::Milestones
|
|
138
141
|
end # Github
|