cfoundry 0.3.38 → 0.3.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -68,8 +68,10 @@ module CFoundry::V2
68
68
  end
69
69
 
70
70
  define_method(plural) do |*args|
71
- get("v2", plural, nil => :json, :params => params_from(args))
71
+ all_pages(
72
+ get("v2", plural, nil => :json, :params => params_from(args)))
72
73
  end
74
+
73
75
  end
74
76
 
75
77
  def resource_match(fingerprints)
@@ -120,6 +122,17 @@ module CFoundry::V2
120
122
  params
121
123
  end
122
124
 
125
+ def all_pages(paginated)
126
+ payload = paginated[:resources]
127
+
128
+ while next_page = paginated[:next_url]
129
+ paginated = request_path(:get, next_page, nil => :json)
130
+ payload += paginated[:resources]
131
+ end
132
+
133
+ payload
134
+ end
135
+
123
136
  private
124
137
 
125
138
  def handle_response(response, accept)
@@ -167,7 +167,7 @@ module CFoundry::V2
167
167
  query[:space_guid] ||= current_space.guid
168
168
  end
169
169
 
170
- @base.send(plural, depth, query)[:resources].collect do |json|
170
+ @base.send(plural, depth, query).collect do |json|
171
171
  send(:"make_#{singular}", json)
172
172
  end
173
173
  end
@@ -193,11 +193,14 @@ module CFoundry::V2
193
193
  end
194
194
 
195
195
  define_method(:"#{plural}_from") do |path, *args|
196
- @base.request_path(
196
+ objs = @base.all_pages(
197
+ @base.request_path(
197
198
  :get,
198
199
  path,
199
200
  nil => :json,
200
- :params => @base.params_from(args))[:resources].collect do |json|
201
+ :params => @base.params_from(args)))
202
+
203
+ objs.collect do |json|
201
204
  send(:"make_#{singular}", json)
202
205
  end
203
206
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.38"
3
+ VERSION = "0.3.39"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- hash: 95
4
+ hash: 93
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 38
10
- version: 0.3.38
9
+ - 39
10
+ version: 0.3.39
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-02 00:00:00 Z
18
+ date: 2012-10-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client