gh 0.10.2 → 0.10.3
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.
- data/lib/gh.rb +1 -1
- data/lib/gh/error.rb +1 -1
- data/lib/gh/token_check.rb +11 -8
- data/lib/gh/version.rb +1 -1
- metadata +2 -2
data/lib/gh.rb
CHANGED
data/lib/gh/error.rb
CHANGED
data/lib/gh/token_check.rb
CHANGED
@@ -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
|
-
@
|
9
|
-
@
|
10
|
-
@
|
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
|
-
|
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(*)
|
data/lib/gh/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|