aptible-api 0.2.2 → 0.3.0

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: 9d2457b7c3accb03805735dfaaa760880eee3588
4
- data.tar.gz: 30e94d083309a23e8ef0da7e2f7a19ab284f949a
3
+ metadata.gz: 9ae1f234749249ba10c4e830f31cc403b78de9c8
4
+ data.tar.gz: a984b4d81ba494532f92a52090e067ff7aa5154d
5
5
  SHA512:
6
- metadata.gz: cab3f8b2378c7cdba2abfb5ee9c5fee35cd2d66032fcc544da03f85f7da212bb44e7a2039b26a09d6412456cf99810c00917bba7244f031e3cf909f8fd65bcb5
7
- data.tar.gz: dd7e70a80f2ce6b4197c21a55b16e078436c1ba2020b3bd37a756b166c69e1211c3e3d329c72bedb62964e618fb8d76efb4c046e4c5e7d770d18e299eb572b50
6
+ metadata.gz: e66e1bafd9405e86e9bbfda05b92ea533b726dab6c7dfe8b15f0c28774053ea3f04abaadbe836401f070dbabf3df2e9a45de9579ac5fb17282a02373f939255f
7
+ data.tar.gz: b39e936172ff7a45d2e24994f44f2caeff0519b0f970693876ea1e647b2ea952f4f921ac1d367cc41628fc18a0a7c60f494252c38f6070c9a1961bb8542a20b8
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.2'
9
+ spec.version = '0.3.0'
10
10
  spec.authors = ['Frank Macreery']
11
11
  spec.email = ['frank@macreery.com']
12
12
  spec.description = %q{Ruby client for api.aptible.com}
@@ -1,5 +1,6 @@
1
1
  module Aptible
2
2
  class Api::App < Api::Resource
3
+ belongs_to :account
3
4
  has_many :configurations
4
5
  has_many :images
5
6
  has_many :operations
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Attachment < Api::Resource
3
+ belongs_to :disk
3
4
  end
4
5
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Configuration < Api::Resource
3
+ belongs_to :resource
3
4
  end
4
5
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Container < Api::Resource
3
+ belongs_to :release
3
4
  end
4
5
  end
@@ -1,5 +1,6 @@
1
1
  module Aptible
2
2
  class Api::Disk < Api::Resource
3
+ belongs_to :account
3
4
  has_many :operations
4
5
  has_many :permissions
5
6
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Image < Api::Resource
3
+ belongs_to :app
3
4
  end
4
5
  end
@@ -1,4 +1,10 @@
1
1
  module Aptible
2
2
  class Api::Operation < Api::Resource
3
+ belongs_to :resource
4
+
5
+ def user
6
+ auth = Aptible::Auth::User.new(token: token, headers: headers)
7
+ auth.find_by_url(links['user'].href)
8
+ end
3
9
  end
4
10
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Permission < Api::Resource
3
+ belongs_to :resource
3
4
  end
4
5
  end
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Proxy < Api::Resource
3
+ belongs_to :service
3
4
  end
4
5
  end
@@ -1,5 +1,6 @@
1
1
  module Aptible
2
2
  class Api::Release < Api::Resource
3
+ belongs_to :service
3
4
  has_many :containers
4
5
  end
5
6
  end
@@ -12,17 +12,17 @@ module Aptible
12
12
  end
13
13
 
14
14
  def self.all(options = {})
15
- resource = new(options).find_by_url(collection_url)
15
+ resource = find_by_url(collection_url, options)
16
16
  resource.send(basename).entries
17
17
  end
18
18
 
19
- def self.find(id)
20
- find_by_url("#{collection_url}/#{id}")
19
+ def self.find(id, options = {})
20
+ find_by_url("#{collection_url}/#{id}", options)
21
21
  end
22
22
 
23
- def self.find_by_url(url)
23
+ def self.find_by_url(url, options = {})
24
24
  # REVIEW: Should exception be raised if return type mismatch?
25
- new.find_by_url(url)
25
+ new(options).find_by_url(url)
26
26
  rescue
27
27
  nil
28
28
  end
@@ -40,6 +40,17 @@ module Aptible
40
40
  end
41
41
  # rubocop:enable PredicateName
42
42
 
43
+ def self.belongs_to(relation)
44
+ define_method relation do
45
+ get unless loaded
46
+ if (memoized = instance_variable_get("@#{relation}"))
47
+ memoized
48
+ else
49
+ instance_variable_set("@#{relation}", links[relation].get)
50
+ end
51
+ end
52
+ end
53
+
43
54
  private
44
55
 
45
56
  def self.define_has_many_getter(relation)
@@ -1,5 +1,6 @@
1
1
  module Aptible
2
2
  class Api::Service < Api::Resource
3
+ belongs_to :account
3
4
  has_many :vhosts
4
5
  has_many :operations
5
6
  has_many :permissions
@@ -1,4 +1,5 @@
1
1
  module Aptible
2
2
  class Api::Vhost < Api::Resource
3
+ belongs_to :service
3
4
  end
4
5
  end
@@ -11,7 +11,7 @@ describe Aptible::Api::Resource do
11
11
  describe '.find' do
12
12
  it 'should call find_by_url' do
13
13
  url = 'https://api.aptible.com/disks/42'
14
- expect(Aptible::Api::Disk).to receive(:find_by_url).with url
14
+ expect(Aptible::Api::Disk).to receive(:find_by_url).with url, {}
15
15
  Aptible::Api::Disk.find(42)
16
16
  end
17
17
  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.2
4
+ version: 0.3.0
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-10 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config