octokit 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/octokit/client/authorizations.rb +6 -2
- data/lib/octokit/client/repositories.rb +2 -0
- data/lib/octokit/enterprise_admin_client/users.rb +1 -1
- data/lib/octokit/error.rb +4 -0
- data/lib/octokit/repository.rb +21 -6
- data/lib/octokit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94d991c0ebb91eff8b87688e204c80b3820bcdbc
|
4
|
+
data.tar.gz: e81a6b01eadef14a4a2680dc192e6915a750af7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a000cbae7cfd114165a405ca9cba6dc2ed847d979ec5b9a427ca5516ccda7705af72494eb82a5ba64c880c30acc9e40ef74b6cce7232d897ef17d39f77dbb5d8
|
7
|
+
data.tar.gz: ad4876a4392214c9a8b2c353bb7ff76f81d028c27c765e6b7c2da5c7404ec3c8801cd59a175d0377f129aab1f5c8cc688be846b33ff12d018fe2fbcf59804503
|
data/README.md
CHANGED
@@ -639,8 +639,11 @@ Constraint][pvc] with two digits of precision. For example:
|
|
639
639
|
|
640
640
|
spec.add_dependency 'octokit', '~> 3.0'
|
641
641
|
|
642
|
+
The changes made between versions can be seen on the [project releases page][releases].
|
643
|
+
|
642
644
|
[semver]: http://semver.org/
|
643
645
|
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
646
|
+
[releases]: https://github.com/octokit/octokit.rb/releases
|
644
647
|
|
645
648
|
## License
|
646
649
|
|
@@ -113,12 +113,16 @@ module Octokit
|
|
113
113
|
# Check scopes for a token
|
114
114
|
#
|
115
115
|
# @param token [String] GitHub OAuth token
|
116
|
+
# @param options [Hash] Header params for request
|
116
117
|
# @return [Array<String>] OAuth scopes
|
117
118
|
# @see https://developer.github.com/v3/oauth/#scopes
|
118
|
-
def scopes(token = @access_token)
|
119
|
+
def scopes(token = @access_token, options = {})
|
119
120
|
raise ArgumentError.new("Access token required") if token.nil?
|
120
121
|
|
121
|
-
|
122
|
+
auth = { "Authorization" => "token #{token}" }
|
123
|
+
headers = (options.delete(:headers) || {}).merge(auth)
|
124
|
+
|
125
|
+
agent.call(:get, "user", :headers => headers).
|
122
126
|
headers['X-OAuth-Scopes'].
|
123
127
|
to_s.
|
124
128
|
split(',').
|
@@ -106,7 +106,7 @@ module Octokit
|
|
106
106
|
|
107
107
|
# Deletes a public SSH keys.
|
108
108
|
#
|
109
|
-
# @param
|
109
|
+
# @param id [Number] The ID of the key to delete.
|
110
110
|
# @see https://developer.github.com/v3/users/administration/#delete-a-public-key
|
111
111
|
# @example
|
112
112
|
# @admin_client.delete_key(1)
|
data/lib/octokit/error.rb
CHANGED
@@ -238,4 +238,8 @@ module Octokit
|
|
238
238
|
# Raised when a method requires an application client_id
|
239
239
|
# and secret but none is provided
|
240
240
|
class ApplicationCredentialsRequired < StandardError; end
|
241
|
+
|
242
|
+
# Raised when a repository is created with an invalid format
|
243
|
+
class InvalidRepository < ArgumentError; end
|
244
|
+
|
241
245
|
end
|
data/lib/octokit/repository.rb
CHANGED
@@ -4,6 +4,7 @@ module Octokit
|
|
4
4
|
# URLs and to generate URLs
|
5
5
|
class Repository
|
6
6
|
attr_accessor :owner, :name, :id
|
7
|
+
NAME_WITH_OWNER_PATTERN = /\A[\w.-]+\/[\w.-]+\z/i
|
7
8
|
|
8
9
|
# Instantiate from a GitHub repository URL
|
9
10
|
#
|
@@ -12,15 +13,14 @@ module Octokit
|
|
12
13
|
Repository.new(URI.parse(url).path[1..-1])
|
13
14
|
end
|
14
15
|
|
16
|
+
# @raise [Octokit::InvalidRepository] if the repository
|
17
|
+
# has an invalid format
|
15
18
|
def initialize(repo)
|
16
19
|
case repo
|
17
20
|
when Integer
|
18
21
|
@id = repo
|
19
|
-
when
|
20
|
-
@owner, @name = repo.split(
|
21
|
-
unless @owner && @name
|
22
|
-
raise ArgumentError, "Invalid Repository. Use user/repo format."
|
23
|
-
end
|
22
|
+
when NAME_WITH_OWNER_PATTERN
|
23
|
+
@owner, @name = repo.split("/")
|
24
24
|
when Repository
|
25
25
|
@owner = repo.owner
|
26
26
|
@name = repo.name
|
@@ -28,7 +28,10 @@ module Octokit
|
|
28
28
|
@name = repo[:repo] ||= repo[:name]
|
29
29
|
@owner = repo[:owner] ||= repo[:user] ||= repo[:username]
|
30
30
|
else
|
31
|
-
|
31
|
+
raise_invalid_repository!
|
32
|
+
end
|
33
|
+
if @owner && @name
|
34
|
+
validate_owner_and_name!
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -71,5 +74,17 @@ module Octokit
|
|
71
74
|
alias :user :owner
|
72
75
|
alias :username :owner
|
73
76
|
alias :repo :name
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def validate_owner_and_name!
|
81
|
+
if @owner.include?('/') || @name.include?('/') || !url.match(/\A#{URI.regexp}\z/)
|
82
|
+
raise_invalid_repository!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def raise_invalid_repository!
|
87
|
+
raise Octokit::InvalidRepository, "Invalid Repository. Use user/repo format."
|
88
|
+
end
|
74
89
|
end
|
75
90
|
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: 4.1.
|
4
|
+
version: 4.1.1
|
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: 2015-
|
13
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|