aptible-resource 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/aptible-resource.gemspec +1 -1
- data/lib/aptible/resource/base.rb +9 -2
- data/lib/aptible/resource/version.rb +1 -1
- data/spec/aptible/resource/base_spec.rb +17 -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: 00d2a4af5d237bbb3f2ed2133240fa087d40fc31
|
4
|
+
data.tar.gz: a2cb0cc2cb94cdb8dafc5c27123a8dce0714d4dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d49416b1b045515b6d09de321582df201f66d9c5418e58ed1816d626635d0619c5c3ba6689e41c00f99061f09c5caf50bb3ffb5184bb8e98864c78cdb6932b7
|
7
|
+
data.tar.gz: ef29aede6cd4afabdb434a7ece2bcd006391a19640838410f4afe4fc59e9449d6e17d05bc12287ac7ff262bc730f3c80464e68f00b0f2f3a24806402c103f9fb
|
data/aptible-resource.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files`.split($RS)
|
19
|
-
spec.test_files = spec.files.grep(
|
19
|
+
spec.test_files = spec.files.grep(%r{^spec\/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
# HyperResource dependencies
|
@@ -35,11 +35,18 @@ module Aptible
|
|
35
35
|
name.split('::').last.underscore.pluralize
|
36
36
|
end
|
37
37
|
|
38
|
+
# rubocop:disable AbcSize
|
38
39
|
def self.all(options = {})
|
39
|
-
resource = find_by_url(collection_href, options)
|
40
|
+
resource = find_by_url(options[:href] || collection_href, options)
|
40
41
|
return [] unless resource
|
41
|
-
resource.
|
42
|
+
if resource.links.key?('next')
|
43
|
+
options[:href] = resource.links['next'].href
|
44
|
+
resource.send(basename).entries + all(options)
|
45
|
+
else
|
46
|
+
resource.send(basename).entries
|
47
|
+
end
|
42
48
|
end
|
49
|
+
# rubocop: enable AbcSize
|
43
50
|
|
44
51
|
def self.where(options = {})
|
45
52
|
params = options.except(:token, :root, :namespace, :headers)
|
@@ -32,6 +32,7 @@ describe Aptible::Resource::Base do
|
|
32
32
|
|
33
33
|
before do
|
34
34
|
collection.stub(:mainframes) { [mainframe] }
|
35
|
+
collection.stub(:links) { Hash.new }
|
35
36
|
Api::Mainframe.any_instance.stub(:find_by_url) { collection }
|
36
37
|
end
|
37
38
|
|
@@ -49,6 +50,22 @@ describe Aptible::Resource::Base do
|
|
49
50
|
expect(klass).to receive(:new).with(options).and_return klass.new
|
50
51
|
Api::Mainframe.all(options)
|
51
52
|
end
|
53
|
+
|
54
|
+
describe 'when paginated' do
|
55
|
+
before do
|
56
|
+
page = double('page')
|
57
|
+
allow(page).to receive(:href).and_return(
|
58
|
+
'/next/page', '/next/page', '/next/page'
|
59
|
+
)
|
60
|
+
allow(collection).to receive(:links).and_return(
|
61
|
+
{ 'next' => page }, { 'next' => page }, {}
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should collect entries on all pages' do
|
66
|
+
expect(Api::Mainframe.all).to eq [mainframe] + [mainframe]
|
67
|
+
end
|
68
|
+
end
|
52
69
|
end
|
53
70
|
|
54
71
|
describe '.create' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
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:
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri_template
|