aptible-api 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0013944c43af6ae364441bcf5802e68defadc874
4
- data.tar.gz: 26b2de9b909d738085ab83b7b397e3e13fb625a5
3
+ metadata.gz: bf5bb691c313660234c7a06c17826cd33df75f9d
4
+ data.tar.gz: e44dff1c1e3a995f59f4156724861a5ff092fc08
5
5
  SHA512:
6
- metadata.gz: 12d71e142af40537c0a9c20974fb995604ebf7ac51340f994ab9915908bac2da3f37f74967c637939ed285b131938c36a019126b4f2f184415da46923dd534d0
7
- data.tar.gz: ff6a9b5150ab4dd95332e389c96934699c8ff25e6c5bd90040137f2b1fccb432154034a26248de21b1634e0c840d427fc218f86d43eb2ee5fdb0957db00af112
6
+ metadata.gz: 4c0d90be3dde38ed35651f47c26e230c8c90f009cd61b1f6feb513c5518573be7207b9869e826466faf1c891c29d587554aa58ed9fab1346a13f3e374119313a
7
+ data.tar.gz: 2902b720d1751424f4cb2daa540b05e09217fe78d5fde6b20f37fe43f94f762478b095eda3b243ccdf2520a138d1a9c566162bd8c9e282f788512edd350b1842
data/aptible-api.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'English'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'aptible-api'
9
- spec.version = '0.2.0'
9
+ spec.version = '0.2.1'
10
10
  spec.authors = ['Frank Macreery']
11
11
  spec.email = ['frank@macreery.com']
12
12
  spec.description = %q{Ruby client for api.aptible.com}
@@ -2,10 +2,18 @@ require 'active_support/inflector'
2
2
 
3
3
  module Aptible
4
4
  class Api::Resource < Api
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::Api.configuration
8
- config.root_url.chomp('/') + "/#{basename.downcase.pluralize}"
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::Api::Resource do
15
15
  Aptible::Api::Disk.find(42)
16
16
  end
17
17
  end
18
+
19
+ describe '.all' do
20
+ let(:app) { double Aptible::Api::App }
21
+ let(:collection) { double Aptible::Api }
22
+
23
+ before do
24
+ collection.stub(:apps) { [app] }
25
+ Aptible::Api::App.any_instance.stub(:find_by_url) { collection }
26
+ end
27
+
28
+ it 'should be an array' do
29
+ expect(Aptible::Api::App.all).to be_a Array
30
+ end
31
+
32
+ it 'should return the root collection' do
33
+ expect(Aptible::Api::App.all).to eq [app]
34
+ end
35
+
36
+ it 'should pass options to the HyperResource initializer' do
37
+ klass = Aptible::Api::App
38
+ options = { token: 'token' }
39
+ expect(klass).to receive(:new).with(options).and_return klass.new
40
+ Aptible::Api::App.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-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.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-09 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config