aptible-auth 0.3.0 → 0.3.1
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 +4 -4
- data/README.md +2 -2
- data/aptible-auth.gemspec +1 -1
- data/lib/aptible/auth/resource.rb +10 -2
- data/spec/aptible/auth/resource_spec.rb +25 -0
- 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: c11aa57a4ce568364c6a15d9b10705c760adac2f
|
4
|
+
data.tar.gz: af79f64c068aa5d7c4f2317da1987ac3cf7995f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef0b24dd70e5e975a296a891445752083f67d1e9b901e2172cc72d89d37c1e7a7fccb1a05430d453af3d1ce0140eee688eb4ee7df56f65e568abd9b2da72493
|
7
|
+
data.tar.gz: 750595b584386a619ada01656482562a9a9b2cfbe8ee73b3dfa06651f926b3e10f4efd69aeed7f5352022222a26bff98e2d2794cdc74b3f08f840e4640eba689
|
data/README.md
CHANGED
@@ -25,12 +25,12 @@ The forked version of the HyperResource gem is necessary until [gamache/hyperres
|
|
25
25
|
First, get a token:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
token = Aptible::Auth::Token.
|
28
|
+
token = Aptible::Auth::Token.create(email: 'user0@example.com', password: 'password')
|
29
29
|
```
|
30
30
|
|
31
31
|
Then, initialize a resource agent:
|
32
32
|
```ruby
|
33
|
-
auth = Aptible::Auth
|
33
|
+
auth = Aptible::Auth.new(token: token)
|
34
34
|
```
|
35
35
|
|
36
36
|
From here, you can interact with the Authorization API however you wish:
|
data/aptible-auth.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'English'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'aptible-auth'
|
9
|
-
spec.version = '0.3.
|
9
|
+
spec.version = '0.3.1'
|
10
10
|
spec.authors = ['Frank Macreery']
|
11
11
|
spec.email = ['frank@macreery.com']
|
12
12
|
spec.description = 'Ruby client for auth.aptible.com'
|
@@ -2,10 +2,18 @@ require 'active_support/inflector'
|
|
2
2
|
|
3
3
|
module Aptible
|
4
4
|
class Auth::Resource < Auth
|
5
|
+
def self.basename
|
6
|
+
name.split('::').last.downcase.pluralize
|
7
|
+
end
|
8
|
+
|
5
9
|
def self.collection_url
|
6
|
-
basename = name.split('::').last
|
7
10
|
config = Aptible::Auth.configuration
|
8
|
-
config.root_url.chomp('/') + "/#{basename
|
11
|
+
config.root_url.chomp('/') + "/#{basename}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.all(options = {})
|
15
|
+
resource = new(options).find_by_url(collection_url)
|
16
|
+
resource.send(basename).entries
|
9
17
|
end
|
10
18
|
|
11
19
|
def self.find(id)
|
@@ -15,4 +15,29 @@ describe Aptible::Auth::Resource do
|
|
15
15
|
Aptible::Auth::Role.find(42)
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
describe '.all' do
|
20
|
+
let(:session) { double Aptible::Auth::Session }
|
21
|
+
let(:collection) { double Aptible::Auth }
|
22
|
+
|
23
|
+
before do
|
24
|
+
collection.stub(:sessions) { [session] }
|
25
|
+
Aptible::Auth::Session.any_instance.stub(:find_by_url) { collection }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should be an array' do
|
29
|
+
expect(Aptible::Auth::Session.all).to be_a Array
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return the root collection' do
|
33
|
+
expect(Aptible::Auth::Session.all).to eq [session]
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should pass options to the HyperResource initializer' do
|
37
|
+
klass = Aptible::Auth::Session
|
38
|
+
options = { token: 'token' }
|
39
|
+
expect(klass).to receive(:new).with(options).and_return klass.new
|
40
|
+
Aptible::Auth::Session.all(options)
|
41
|
+
end
|
42
|
+
end
|
18
43
|
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.3.
|
4
|
+
version: 0.3.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-03-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|