github-auth 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 925a47ece6e17d63b118306d952b7f05de6334dd
4
- data.tar.gz: 8994acc3a3c067d7cf60524d2d8da9be40beb77c
3
+ metadata.gz: 112ea81b2134fd852537569815137af0aec98fc2
4
+ data.tar.gz: a7a9f347a1ac0eb642b28516d82246c46975d17b
5
5
  SHA512:
6
- metadata.gz: b4d5eeec641cb3da34d54b38735906030bcca3b9814b069455567045d1ccd07424865572447eb6a4c2538aa4e1dc2b53912d53202d52e7335b850bcf1d474e70
7
- data.tar.gz: 291fb365b5d28120baee5ced839a191bf07efbeb263f674dff564732410f48859b84643101d164a0571cc72045eb37b8efdc4018ccb5913daded3098645ed480
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 "#{hostname}/users/#{username}/keys"
34
- raise GithubUserDoesNotExistError if response.code == 404
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
@@ -1,5 +1,5 @@
1
1
  module Github
2
2
  module Auth
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -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.2.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-22 00:00:00.000000000 Z
11
+ date: 2013-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler