gh 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gh.rb CHANGED
@@ -59,7 +59,7 @@ module GH
59
59
  DefaultStack = Stack.new do
60
60
  use Instrumentation
61
61
  use Parallel
62
- #use TokenCheck
62
+ use TokenCheck
63
63
  use Pagination
64
64
  use LinkFollower
65
65
  use MergeCommit
@@ -50,6 +50,6 @@ module GH
50
50
  end
51
51
  end
52
52
 
53
- class TokenInvalid < Exception
53
+ class TokenInvalid < Error
54
54
  end
55
55
  end
@@ -1,22 +1,25 @@
1
1
  require 'gh/error'
2
+ require 'base64'
2
3
 
3
4
  module GH
4
5
  class TokenCheck < Wrapper
5
- attr_accessor :client_id, :token
6
+ attr_accessor :client_id, :client_secret, :token
6
7
 
7
8
  def setup(backend, options)
8
- @client_id = options[:client_id]
9
- @token = options[:token]
10
- @check_token = true
9
+ @client_secret = options[:client_secret]
10
+ @client_id = options[:client_id]
11
+ @token = options[:token]
12
+ @check_token = true
11
13
  super
12
14
  end
13
15
 
14
16
  def check_token
15
- return unless @check_token and client_id and token
16
- http :head, "/applications/#{client_id}/tokens/#{token}"
17
+ return unless @check_token and client_id and client_secret and token
18
+ auth_header = "Basic %s" % Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", "")
19
+ http :head, "/applications/#{client_id}/tokens/#{token}", "Authorization" => auth_header
17
20
  @check_token = false
18
- rescue GH::Error
19
- raise GH::TokenInvalid
21
+ rescue GH::Error => error
22
+ raise GH::TokenInvalid, error
20
23
  end
21
24
 
22
25
  def fetch_resource(*)
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.10.2"
3
+ VERSION = "0.10.3"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-18 00:00:00.000000000 Z
12
+ date: 2013-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec