github-auth 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/github/auth/keys_client.rb +9 -2
- data/lib/github/auth/version.rb +1 -1
- data/spec/unit/github/auth/keys_client_spec.rb +2 -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: 112ea81b2134fd852537569815137af0aec98fc2
|
4
|
+
data.tar.gz: a7a9f347a1ac0eb642b28516d82246c46975d17b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49c8300123940bc4d127d128ef7ba8c29ad291a677e9ef3050109a691c8d1913284cf458e691c8699902f499701b0d3432bbae76865068e210373f5a9543b738
|
7
|
+
data.tar.gz: 476040e680a640d521f3db05a20478200524bff868213cd7c1b570baf3a01ee7bb9266b1c2ca4117a98edce48e7cf6cb948e970e879d0bdbb44b50264e3b2417
|
@@ -9,6 +9,7 @@ module Github::Auth
|
|
9
9
|
GithubUserDoesNotExistError = Class.new StandardError
|
10
10
|
|
11
11
|
DEFAULT_HOSTNAME = 'https://api.github.com'
|
12
|
+
USER_AGENT = "github_auth-#{VERSION}"
|
12
13
|
|
13
14
|
DEFAULT_OPTIONS = {
|
14
15
|
username: nil,
|
@@ -30,8 +31,10 @@ module Github::Auth
|
|
30
31
|
private
|
31
32
|
|
32
33
|
def github_response
|
33
|
-
response = http_client.get
|
34
|
-
|
34
|
+
response = http_client.get(
|
35
|
+
"#{hostname}/users/#{username}/keys", headers: headers
|
36
|
+
)
|
37
|
+
raise GithubUserDoesNotExistError if response.code == 404
|
35
38
|
response.parsed_response
|
36
39
|
rescue SocketError, Errno::ECONNREFUSED => e
|
37
40
|
raise GithubUnavailableError.new e
|
@@ -40,5 +43,9 @@ module Github::Auth
|
|
40
43
|
def http_client
|
41
44
|
HTTParty
|
42
45
|
end
|
46
|
+
|
47
|
+
def headers
|
48
|
+
{ 'User-Agent' => USER_AGENT }
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
data/lib/github/auth/version.rb
CHANGED
@@ -37,7 +37,8 @@ describe Github::Auth::KeysClient do
|
|
37
37
|
describe '#keys' do
|
38
38
|
it 'requests keys from the Github API' do
|
39
39
|
http_client.should_receive(:get).with(
|
40
|
-
"https://api.github.com/users/#{username}/keys"
|
40
|
+
"https://api.github.com/users/#{username}/keys",
|
41
|
+
{ headers: { 'User-Agent' => "github_auth-#{Github::Auth::VERSION}" } }
|
41
42
|
)
|
42
43
|
subject.keys
|
43
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|