octokit 3.1.2 → 3.2.0
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.
- checksums.yaml +4 -4
- data/lib/octokit/client.rb +2 -0
- data/lib/octokit/client/commit_comments.rb +12 -12
- data/lib/octokit/client/commits.rb +21 -21
- data/lib/octokit/client/contents.rb +11 -11
- data/lib/octokit/client/deployments.rb +4 -4
- data/lib/octokit/client/downloads.rb +6 -6
- data/lib/octokit/client/events.rb +18 -15
- data/lib/octokit/client/gists.rb +4 -4
- data/lib/octokit/client/issues.rb +26 -30
- data/lib/octokit/client/labels.rb +22 -22
- data/lib/octokit/client/notifications.rb +4 -4
- data/lib/octokit/client/objects.rb +12 -12
- data/lib/octokit/client/organizations.rb +26 -28
- data/lib/octokit/client/pages.rb +6 -6
- data/lib/octokit/client/pull_requests.rb +36 -36
- data/lib/octokit/client/refs.rb +12 -12
- data/lib/octokit/client/releases.rb +4 -4
- data/lib/octokit/client/repositories.rb +79 -80
- data/lib/octokit/client/stats.rb +7 -7
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/users.rb +26 -28
- data/lib/octokit/error.rb +4 -0
- data/lib/octokit/organization.rb +17 -0
- data/lib/octokit/repository.rb +26 -1
- data/lib/octokit/user.rb +19 -0
- data/lib/octokit/version.rb +1 -1
- metadata +4 -2
data/lib/octokit/client/stats.rb
CHANGED
@@ -8,7 +8,7 @@ module Octokit
|
|
8
8
|
|
9
9
|
# Get contributors list with additions, deletions, and commit counts
|
10
10
|
#
|
11
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
12
|
# @return [Array<Sawyer::Resource>] Array of contributor stats
|
13
13
|
# @see https://developer.github.com/v3/repos/statistics/#contributors
|
14
14
|
# @example Get contributor stats for octokit
|
@@ -20,7 +20,7 @@ module Octokit
|
|
20
20
|
|
21
21
|
# Get the last year of commit activity data
|
22
22
|
#
|
23
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
23
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
24
24
|
# @return [Array<Sawyer::Resource>] The last year of commit activity grouped by
|
25
25
|
# week. The days array is a group of commits per day, starting on Sunday.
|
26
26
|
# @see https://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data
|
@@ -32,7 +32,7 @@ module Octokit
|
|
32
32
|
|
33
33
|
# Get the number of additions and deletions per week
|
34
34
|
#
|
35
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
35
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
36
36
|
# @return [Array<Sawyer::Resource>] Weekly aggregate of the number of additions
|
37
37
|
# and deletions pushed to a repository.
|
38
38
|
# @see https://developer.github.com/v3/repos/statistics/#code-frequency
|
@@ -44,7 +44,7 @@ module Octokit
|
|
44
44
|
|
45
45
|
# Get the weekly commit count for the repo owner and everyone else
|
46
46
|
#
|
47
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
47
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
48
48
|
# @return [Sawyer::Resource] Total commit counts for the owner and total commit
|
49
49
|
# counts in all. all is everyone combined, including the owner in the last
|
50
50
|
# 52 weeks. If you’d like to get the commit counts for non-owners, you can
|
@@ -58,7 +58,7 @@ module Octokit
|
|
58
58
|
|
59
59
|
# Get the number of commits per hour in each day
|
60
60
|
#
|
61
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
61
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
62
62
|
# @return [Array<Array>] Arrays containing the day number, hour number, and
|
63
63
|
# number of commits
|
64
64
|
# @see https://developer.github.com/v3/repos/statistics/#punch-card
|
@@ -73,11 +73,11 @@ module Octokit
|
|
73
73
|
|
74
74
|
# @private Get stats for a repository
|
75
75
|
#
|
76
|
-
# @param repo [String, Hash, Repository] A GitHub repository
|
76
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
77
77
|
# @param metric [String] The metrics you are looking for
|
78
78
|
# @return [Array<Sawyer::Resource>] Magical unicorn stats
|
79
79
|
def get_stats(repo, metric, options = {})
|
80
|
-
data = get("
|
80
|
+
data = get("#{Repository.path repo}/stats/#{metric}", options)
|
81
81
|
|
82
82
|
last_response.status == 202 ? nil : data
|
83
83
|
end
|
@@ -9,30 +9,30 @@ module Octokit
|
|
9
9
|
|
10
10
|
# List all statuses for a given commit
|
11
11
|
#
|
12
|
-
# @param repo [String, Repository, Hash] A GitHub repository
|
12
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
13
13
|
# @param sha [String] The SHA1 for the commit
|
14
14
|
# @return [Array<Sawyer::Resource>] A list of statuses
|
15
15
|
# @see https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
|
16
16
|
def statuses(repo, sha, options = {})
|
17
|
-
get "
|
17
|
+
get "#{Repository.path repo}/statuses/#{sha}", options
|
18
18
|
end
|
19
19
|
alias :list_statuses :statuses
|
20
20
|
|
21
21
|
# Get the combined status for a ref
|
22
22
|
#
|
23
|
-
# @param repo [String, Repository, Hash] a GitHub repository
|
23
|
+
# @param repo [Integer, String, Repository, Hash] a GitHub repository
|
24
24
|
# @param ref [String] A Sha or Ref to fetch the status of
|
25
25
|
# @return [Sawyer::Resource] The combined status for the commit
|
26
26
|
# @see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
|
27
27
|
def combined_status(repo, ref, options = {})
|
28
28
|
ensure_combined_status_api_media_type(options)
|
29
|
-
get "
|
29
|
+
get "#{Repository.path repo}/commits/#{ref}/status", options
|
30
30
|
end
|
31
31
|
alias :status :combined_status
|
32
32
|
|
33
33
|
# Create status for a commit
|
34
34
|
#
|
35
|
-
# @param repo [String, Repository, Hash] A GitHub repository
|
35
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
36
36
|
# @param sha [String] The SHA1 for the commit
|
37
37
|
# @param state [String] The state: pending, success, failure, error
|
38
38
|
# @option options [String] :context A context to differentiate this status from others
|
@@ -42,7 +42,7 @@ module Octokit
|
|
42
42
|
# @see https://developer.github.com/v3/repos/statuses/#create-a-status
|
43
43
|
def create_status(repo, sha, state, options = {})
|
44
44
|
options.merge!(:state => state)
|
45
|
-
post "
|
45
|
+
post "#{Repository.path repo}/statuses/#{sha}", options
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
data/lib/octokit/client/users.rb
CHANGED
@@ -24,18 +24,14 @@ module Octokit
|
|
24
24
|
|
25
25
|
# Get a single user
|
26
26
|
#
|
27
|
-
# @param user [String]
|
27
|
+
# @param user [Integer, String] GitHub user login or id.
|
28
28
|
# @return [Sawyer::Resource]
|
29
29
|
# @see https://developer.github.com/v3/users/#get-a-single-user
|
30
30
|
# @see https://developer.github.com/v3/users/#get-the-authenticated-user
|
31
31
|
# @example
|
32
32
|
# Octokit.user("sferik")
|
33
33
|
def user(user=nil, options = {})
|
34
|
-
|
35
|
-
get "users/#{user}", options
|
36
|
-
else
|
37
|
-
get 'user', options
|
38
|
-
end
|
34
|
+
get User.path(user), options
|
39
35
|
end
|
40
36
|
|
41
37
|
# Retrieve the access_token.
|
@@ -92,24 +88,28 @@ module Octokit
|
|
92
88
|
|
93
89
|
# Get a user's followers.
|
94
90
|
#
|
95
|
-
# @param user [String]
|
96
|
-
#
|
91
|
+
# @param user [Integer, String] GitHub user login or id of the user whose
|
92
|
+
# list of followers you are getting.
|
93
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing users
|
94
|
+
# followers.
|
97
95
|
# @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user
|
98
96
|
# @example
|
99
97
|
# Octokit.followers('pengwynn')
|
100
98
|
def followers(user=login, options = {})
|
101
|
-
paginate "
|
99
|
+
paginate "#{User.path user}/followers", options
|
102
100
|
end
|
103
101
|
|
104
102
|
# Get list of users a user is following.
|
105
103
|
#
|
106
|
-
# @param user [String]
|
107
|
-
#
|
104
|
+
# @param user [Intger, String] GitHub user login or id of the user who you
|
105
|
+
# are getting the list of the people they follow.
|
106
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing users a
|
107
|
+
# user is following.
|
108
108
|
# @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
|
109
109
|
# @example
|
110
110
|
# Octokit.following('pengwynn')
|
111
111
|
def following(user=login, options = {})
|
112
|
-
paginate "
|
112
|
+
paginate "#{User.path user}/following", options
|
113
113
|
end
|
114
114
|
|
115
115
|
# Check if you are following a user. Alternatively, check if a given user
|
@@ -118,10 +118,11 @@ module Octokit
|
|
118
118
|
# Requries an authenticated client.
|
119
119
|
#
|
120
120
|
# @overload follows?(target)
|
121
|
-
# @param target [String]
|
121
|
+
# @param target [String] GitHub login of the user that you want to
|
122
|
+
# check if you are following.
|
122
123
|
# @overload follows?(user, target)
|
123
|
-
# @param user [String]
|
124
|
-
# @param target [String]
|
124
|
+
# @param user [Integer, String] GitHub user login or id of first user
|
125
|
+
# @param target [String] GitHub login of the target user
|
125
126
|
# @return [Boolean] True following target user, false otherwise.
|
126
127
|
# @see https://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user
|
127
128
|
# @see https://developer.github.com/v3/users/followers/#check-if-one-user-follows-another
|
@@ -132,12 +133,7 @@ module Octokit
|
|
132
133
|
def follows?(*args)
|
133
134
|
target = args.pop
|
134
135
|
user = args.first
|
135
|
-
|
136
|
-
url = "user/following/#{target}"
|
137
|
-
else
|
138
|
-
url = "users/#{user}/following/#{target}"
|
139
|
-
end
|
140
|
-
boolean_from_response :get, url
|
136
|
+
boolean_from_response :get, "#{User.path user}/following/#{target}"
|
141
137
|
end
|
142
138
|
|
143
139
|
# Follow a user.
|
@@ -168,7 +164,8 @@ module Octokit
|
|
168
164
|
|
169
165
|
# Get list of repos starred by a user.
|
170
166
|
#
|
171
|
-
# @param user [String]
|
167
|
+
# @param user [Integer, String] GitHub user login of the user to get the
|
168
|
+
# list of their starred repositories.
|
172
169
|
# @param options [Hash] Optional options
|
173
170
|
# @option options [String] :sort (created) Sort: <tt>created</tt> or <tt>updated</tt>.
|
174
171
|
# @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
|
@@ -234,13 +231,14 @@ module Octokit
|
|
234
231
|
|
235
232
|
# Get list of public keys for user.
|
236
233
|
#
|
234
|
+
# @param user [Integer, String] GitHub user login or id.
|
237
235
|
# @return [Array<Sawyer::Resource>] Array of hashes representing public keys.
|
238
236
|
# @see https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
|
239
237
|
# @example
|
240
238
|
# @client.user_keys('pengwynn')
|
241
239
|
def user_keys(user, options = {})
|
242
240
|
# TODO: Roll this into .keys
|
243
|
-
paginate "
|
241
|
+
paginate "#{User.path user}/keys", options
|
244
242
|
end
|
245
243
|
|
246
244
|
# Add public key to user account.
|
@@ -266,7 +264,10 @@ module Octokit
|
|
266
264
|
# @option options [String] :title
|
267
265
|
# @option options [String] :key
|
268
266
|
# @return [Sawyer::Resource] Hash representing the updated public key.
|
267
|
+
#
|
268
|
+
# @deprecated This method is no longer supported in the API
|
269
269
|
# @see https://developer.github.com/v3/users/keys/#update-a-public-key
|
270
|
+
# @see https://developer.github.com/changes/2014-02-24-finer-grained-scopes-for-ssh-keys/
|
270
271
|
# @example
|
271
272
|
# @client.update_key(1, :title => 'new title', :key => "ssh-rsa BBB")
|
272
273
|
def update_key(key_id, options = {})
|
@@ -328,12 +329,9 @@ module Octokit
|
|
328
329
|
|
329
330
|
# List repositories being watched by a user.
|
330
331
|
#
|
331
|
-
# @param user [String]
|
332
|
-
#
|
332
|
+
# @param user [Integer, String] GitHub user login or id.
|
333
333
|
# @return [Array<Sawyer::Resource>] Array of repositories.
|
334
|
-
#
|
335
334
|
# @see https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
|
336
|
-
#
|
337
335
|
# @example
|
338
336
|
# @client.subscriptions("pengwynn")
|
339
337
|
def subscriptions(user=login, options = {})
|
@@ -349,7 +347,7 @@ module Octokit
|
|
349
347
|
if user == login && user_authenticated?
|
350
348
|
"user/#{path}"
|
351
349
|
else
|
352
|
-
"
|
350
|
+
"#{User.path user}/#{path}"
|
353
351
|
end
|
354
352
|
end
|
355
353
|
end
|
data/lib/octokit/error.rb
CHANGED
@@ -17,6 +17,7 @@ module Octokit
|
|
17
17
|
when 401 then error_for_401(headers)
|
18
18
|
when 403 then error_for_403(body)
|
19
19
|
when 404 then Octokit::NotFound
|
20
|
+
when 405 then Octokit::MethodNotAllowed
|
20
21
|
when 406 then Octokit::NotAcceptable
|
21
22
|
when 409 then Octokit::Conflict
|
22
23
|
when 415 then Octokit::UnsupportedMediaType
|
@@ -189,6 +190,9 @@ module Octokit
|
|
189
190
|
# Raised when GitHub returns a 404 HTTP status code
|
190
191
|
class NotFound < ClientError; end
|
191
192
|
|
193
|
+
# Raised when GitHub returns a 405 HTTP status code
|
194
|
+
class MethodNotAllowed < ClientError; end
|
195
|
+
|
192
196
|
# Raised when GitHub returns a 406 HTTP status code
|
193
197
|
class NotAcceptable < ClientError; end
|
194
198
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Octokit
|
2
|
+
# GitHub organization class to generate API path urls
|
3
|
+
class Organization
|
4
|
+
# Get the api path for an organization
|
5
|
+
#
|
6
|
+
# @param org [String, Integer] GitHub organization login or id
|
7
|
+
# @return [String] Organization Api path
|
8
|
+
def self.path org
|
9
|
+
case org
|
10
|
+
when String
|
11
|
+
"orgs/#{org}"
|
12
|
+
when Integer
|
13
|
+
"organizations/#{org}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/octokit/repository.rb
CHANGED
@@ -3,7 +3,7 @@ module Octokit
|
|
3
3
|
# Class to parse GitHub repository owner and name from
|
4
4
|
# URLs and to generate URLs
|
5
5
|
class Repository
|
6
|
-
attr_accessor :owner, :name
|
6
|
+
attr_accessor :owner, :name, :id
|
7
7
|
|
8
8
|
# Instantiate from a GitHub repository URL
|
9
9
|
#
|
@@ -14,6 +14,8 @@ module Octokit
|
|
14
14
|
|
15
15
|
def initialize(repo)
|
16
16
|
case repo
|
17
|
+
when Integer
|
18
|
+
@id = repo
|
17
19
|
when String
|
18
20
|
@owner, @name = repo.split('/')
|
19
21
|
when Repository
|
@@ -32,6 +34,29 @@ module Octokit
|
|
32
34
|
end
|
33
35
|
alias :to_s :slug
|
34
36
|
|
37
|
+
# @return [String] Repository API path
|
38
|
+
def path
|
39
|
+
return named_api_path if @owner && @name
|
40
|
+
return id_api_path if @id
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get the api path for a repo
|
44
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
45
|
+
# @return [String] Api path.
|
46
|
+
def self.path repo
|
47
|
+
new(repo).path
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String] Api path for owner/name identified repos
|
51
|
+
def named_api_path
|
52
|
+
"repos/#{slug}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String] Api path for id identified repos
|
56
|
+
def id_api_path
|
57
|
+
"repositories/#{@id}"
|
58
|
+
end
|
59
|
+
|
35
60
|
# Repository URL based on {Octokit::Client#web_endpoint}
|
36
61
|
# @return [String]
|
37
62
|
def url
|
data/lib/octokit/user.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Octokit
|
2
|
+
# GitHub user class to generate API path urls
|
3
|
+
class User
|
4
|
+
# Get the api path for a user
|
5
|
+
#
|
6
|
+
# @param user [String, Integer] GitHub user login or id
|
7
|
+
# @return [String] User Api path
|
8
|
+
def self.path user
|
9
|
+
case user
|
10
|
+
when String
|
11
|
+
"users/#{user}"
|
12
|
+
when Integer
|
13
|
+
"user/#{user}"
|
14
|
+
else
|
15
|
+
"user"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/octokit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-06-
|
13
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -97,11 +97,13 @@ files:
|
|
97
97
|
- lib/octokit/default.rb
|
98
98
|
- lib/octokit/error.rb
|
99
99
|
- lib/octokit/gist.rb
|
100
|
+
- lib/octokit/organization.rb
|
100
101
|
- lib/octokit/rate_limit.rb
|
101
102
|
- lib/octokit/repo_arguments.rb
|
102
103
|
- lib/octokit/repository.rb
|
103
104
|
- lib/octokit/response/feed_parser.rb
|
104
105
|
- lib/octokit/response/raise_error.rb
|
106
|
+
- lib/octokit/user.rb
|
105
107
|
- lib/octokit/version.rb
|
106
108
|
- lib/octokit.rb
|
107
109
|
homepage: https://github.com/octokit/octokit.rb
|