aptible-auth 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 101f4e5eba0e9ddacf579ed8758ebbbdfba30d84
4
- data.tar.gz: b2daa6d3703e05bfcba62c36d7469890430a7463
3
+ metadata.gz: 34caa61e053fc96d4a43bd90c73db5a00776c634
4
+ data.tar.gz: fef45746c7c7ab4d42be4bf720f0b42c0f192edf
5
5
  SHA512:
6
- metadata.gz: 535418028b5197789fb200a8608133df28e5f2c6622d7a9d614c259409850139231209988a633a592fc6ef45e6808ecd8012ba1bea42223220b55e99df4280c8
7
- data.tar.gz: c784ba5e1f430fd0ee88de2dc06a13214d7b0f4aab0c5ef57055fcd447dc4c56a69e02312f1293ff17612b179894c6b53ad8e734bd4a5c099d1a31fc9eae6c42
6
+ metadata.gz: 9f2d7eb28d29eddd7cf8e5473a3d143fc01ff67c3605f5471a8e34190c3256ddcd22784967001841a95a357d86eff03e144886f32772821536f2fb5b6aa4304e
7
+ data.tar.gz: 06e82bb7831bbf3b3dfeda977dd3b655a5977986e7de8223567b3b693ea84ad719e84db86697c7e049cf2d82ae2ae9da1668b3178189ec2a096180825f8b71c2
data/README.md CHANGED
@@ -12,9 +12,12 @@ Add the following lines to your application's Gemfile.
12
12
 
13
13
  gem 'aptible-auth'
14
14
  gem 'oauth2', github: 'fancyremarker/oauth2', branch: 'aptible'
15
+ gem 'hyperresource', github: 'fancyremarker/hyperresource', branch: 'aptible'
15
16
 
16
17
  The forked version of the OAuth2 gem is necessary until [intridea/oauth2#165](https://github.com/intridea/oauth2/pull/165) and [intridea/oauth2#166](https://github.com/intridea/oauth2/pull/166) are merged.
17
18
 
19
+ The forked version of the HyperResource gem is necessary until [gamache/hyperresource#19](https://github.com/gamache/hyperresource/pull/19) is merged.
20
+
18
21
  And then run `bundle install`.
19
22
 
20
23
  ## Usage
@@ -33,12 +36,11 @@ auth = Aptible::Auth::Client.new(token: token)
33
36
  From here, you can interact with the Authorization API however you wish:
34
37
 
35
38
  ```ruby
36
- auth.get
37
- auth.clients.count
39
+ auth.get.clients.count
38
40
  # => 4
39
- auth.clients.first.name
41
+ auth.get.clients.first.name
40
42
  # => "Client 0"
41
- client = auth.clients.create(name: 'Dogeclient')
43
+ client = auth.get.clients.create(name: 'Dogeclient')
42
44
  client.href
43
45
  # => "http://localhost:4000/clients/60765b69-ffd8-4762-b9d2-96354ddb16f9"
44
46
  ```
@@ -9,17 +9,26 @@ module Aptible
9
9
  unless options.is_a?(Hash)
10
10
  fail ArgumentError, 'Call Aptible::Auth::Client.new with a Hash'
11
11
  end
12
- @token = options[:token]
12
+ self.token = options[:token]
13
13
 
14
14
  options[:root] ||= config.root_url
15
15
  options[:headers] ||= { 'Content-Type' => 'application/json' }
16
16
  options[:headers].merge!(
17
- 'Authorization' => "Bearer #{options[:token].access_token}"
17
+ 'Authorization' => "Bearer #{bearer_token}"
18
18
  ) if options[:token]
19
19
 
20
20
  super(options)
21
21
  end
22
22
 
23
+ def bearer_token
24
+ # REVIEW: Should we really allow any token type here?
25
+ case token
26
+ when Aptible::Auth::Token then token.access_token
27
+ when Fridge::AccessToken then token.to_s
28
+ when String then token
29
+ end
30
+ end
31
+
23
32
  def config
24
33
  @config ||= Aptible::Auth.configuration
25
34
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Auth
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+ date: 2014-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config