cfoundry 0.4.14 → 0.4.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/baseclient.rb +4 -0
- data/lib/cfoundry/errors.rb +14 -0
- data/lib/cfoundry/version.rb +1 -1
- data/spec/cfoundry/baseclient_spec.rb +17 -0
- data/spec/cfoundry/errors_spec.rb +14 -0
- metadata +58 -56
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -8,6 +8,8 @@ module CFoundry
|
|
8
8
|
class BaseClient # :nodoc:
|
9
9
|
LOG_LENGTH = 10
|
10
10
|
|
11
|
+
attr_reader :target
|
12
|
+
|
11
13
|
attr_accessor :trace, :backtrace, :log
|
12
14
|
|
13
15
|
def initialize(target, token = nil)
|
@@ -141,6 +143,8 @@ module CFoundry
|
|
141
143
|
handle_response(response, accept)
|
142
144
|
end
|
143
145
|
end
|
146
|
+
rescue ::Timeout::Error => e
|
147
|
+
raise Timeout.new(method, uri, e)
|
144
148
|
rescue SocketError, Errno::ECONNREFUSED => e
|
145
149
|
raise TargetRefused, e.message
|
146
150
|
end
|
data/lib/cfoundry/errors.rb
CHANGED
@@ -30,6 +30,20 @@ module CFoundry
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
class Timeout < Timeout::Error
|
34
|
+
attr_reader :method, :uri, :parent
|
35
|
+
|
36
|
+
def initialize(method, uri, parent = nil)
|
37
|
+
@method = method
|
38
|
+
@uri = uri
|
39
|
+
@parent = parent
|
40
|
+
super(to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
"#{method::METHOD} #{uri} timed out"
|
45
|
+
end
|
46
|
+
end
|
33
47
|
|
34
48
|
# Exception representing errors returned by the API.
|
35
49
|
class APIError < RuntimeError
|
data/lib/cfoundry/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CFoundry::BaseClient do
|
4
|
+
let(:base) { CFoundry::BaseClient.new("https://api.cloudfoundry.com") }
|
5
|
+
|
6
|
+
describe '#request_uri' do
|
7
|
+
subject { base.request_uri URI.parse(base.target + "/foo"), Net::HTTP::Get }
|
8
|
+
|
9
|
+
context 'when a timeout exception occurs' do
|
10
|
+
before { stub_request(:get, 'https://api.cloudfoundry.com/foo').to_raise(::Timeout::Error) }
|
11
|
+
|
12
|
+
it 'raises the correct error' do
|
13
|
+
expect { subject }.to raise_error CFoundry::Timeout, "GET https://api.cloudfoundry.com/foo timed out"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Errors' do
|
4
|
+
describe CFoundry::Timeout do
|
5
|
+
let(:parent) { Timeout::Error.new }
|
6
|
+
|
7
|
+
subject { CFoundry::Timeout.new(Net::HTTP::Post, '/blah', parent) }
|
8
|
+
|
9
|
+
its(:to_s) { should eq "POST /blah timed out" }
|
10
|
+
its(:method) { should eq Net::HTTP::Post }
|
11
|
+
its(:uri) { should eq '/blah' }
|
12
|
+
its(:parent) { should eq parent }
|
13
|
+
end
|
14
|
+
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 15
|
10
|
+
version: 0.4.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-12-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-12-17 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: multipart-post
|
@@ -150,60 +149,61 @@ extra_rdoc_files: []
|
|
150
149
|
files:
|
151
150
|
- LICENSE
|
152
151
|
- Rakefile
|
153
|
-
- lib/cfoundry.rb
|
152
|
+
- lib/cfoundry/baseclient.rb
|
153
|
+
- lib/cfoundry/chatty_hash.rb
|
154
154
|
- lib/cfoundry/client.rb
|
155
|
-
- lib/cfoundry/version.rb
|
156
155
|
- lib/cfoundry/errors.rb
|
157
|
-
- lib/cfoundry/validator.rb
|
158
|
-
- lib/cfoundry/uaaclient.rb
|
159
156
|
- lib/cfoundry/spec_helper.rb
|
160
|
-
- lib/cfoundry/
|
161
|
-
- lib/cfoundry/
|
157
|
+
- lib/cfoundry/uaaclient.rb
|
158
|
+
- lib/cfoundry/upload_helpers.rb
|
159
|
+
- lib/cfoundry/v1/app.rb
|
160
|
+
- lib/cfoundry/v1/base.rb
|
161
|
+
- lib/cfoundry/v1/client.rb
|
162
|
+
- lib/cfoundry/v1/framework.rb
|
163
|
+
- lib/cfoundry/v1/model.rb
|
164
|
+
- lib/cfoundry/v1/model_magic.rb
|
165
|
+
- lib/cfoundry/v1/runtime.rb
|
166
|
+
- lib/cfoundry/v1/service.rb
|
167
|
+
- lib/cfoundry/v1/service_instance.rb
|
168
|
+
- lib/cfoundry/v1/user.rb
|
169
|
+
- lib/cfoundry/v2/app.rb
|
170
|
+
- lib/cfoundry/v2/base.rb
|
162
171
|
- lib/cfoundry/v2/client.rb
|
163
|
-
- lib/cfoundry/v2/
|
164
|
-
- lib/cfoundry/v2/user.rb
|
172
|
+
- lib/cfoundry/v2/domain.rb
|
165
173
|
- lib/cfoundry/v2/framework.rb
|
174
|
+
- lib/cfoundry/v2/model.rb
|
166
175
|
- lib/cfoundry/v2/model_magic.rb
|
167
|
-
- lib/cfoundry/v2/service_auth_token.rb
|
168
|
-
- lib/cfoundry/v2/space.rb
|
169
|
-
- lib/cfoundry/v2/app.rb
|
170
|
-
- lib/cfoundry/v2/service_plan.rb
|
171
|
-
- lib/cfoundry/v2/base.rb
|
172
176
|
- lib/cfoundry/v2/organization.rb
|
173
177
|
- lib/cfoundry/v2/route.rb
|
174
|
-
- lib/cfoundry/v2/domain.rb
|
175
178
|
- lib/cfoundry/v2/runtime.rb
|
179
|
+
- lib/cfoundry/v2/service.rb
|
180
|
+
- lib/cfoundry/v2/service_auth_token.rb
|
181
|
+
- lib/cfoundry/v2/service_binding.rb
|
176
182
|
- lib/cfoundry/v2/service_instance.rb
|
177
|
-
- lib/cfoundry/
|
178
|
-
- lib/cfoundry/
|
179
|
-
- lib/cfoundry/
|
180
|
-
- lib/cfoundry/
|
181
|
-
- lib/cfoundry/
|
182
|
-
- lib/cfoundry/v1/user.rb
|
183
|
-
- lib/cfoundry/v1/framework.rb
|
184
|
-
- lib/cfoundry/v1/model_magic.rb
|
185
|
-
- lib/cfoundry/v1/app.rb
|
186
|
-
- lib/cfoundry/v1/base.rb
|
187
|
-
- lib/cfoundry/v1/runtime.rb
|
188
|
-
- lib/cfoundry/v1/service_instance.rb
|
183
|
+
- lib/cfoundry/v2/service_plan.rb
|
184
|
+
- lib/cfoundry/v2/space.rb
|
185
|
+
- lib/cfoundry/v2/user.rb
|
186
|
+
- lib/cfoundry/validator.rb
|
187
|
+
- lib/cfoundry/version.rb
|
189
188
|
- lib/cfoundry/zip.rb
|
190
|
-
- lib/cfoundry
|
191
|
-
- spec/
|
192
|
-
- spec/
|
193
|
-
- spec/
|
194
|
-
- spec/factories/
|
189
|
+
- lib/cfoundry.rb
|
190
|
+
- spec/cfoundry/baseclient_spec.rb
|
191
|
+
- spec/cfoundry/errors_spec.rb
|
192
|
+
- spec/cfoundry/uaaclient_spec.rb
|
193
|
+
- spec/factories/app_factory.rb
|
194
|
+
- spec/factories/client_factory.rb
|
195
|
+
- spec/factories/domain_factory.rb
|
195
196
|
- spec/factories/factory.rb
|
196
|
-
- spec/factories/runtime_factory.rb
|
197
|
-
- spec/factories/space_factory.rb
|
198
|
-
- spec/factories/organization_factory.rb
|
199
197
|
- spec/factories/framework_factory.rb
|
200
|
-
- spec/factories/
|
201
|
-
- spec/factories/
|
202
|
-
- spec/factories/
|
198
|
+
- spec/factories/organization_factory.rb
|
199
|
+
- spec/factories/route_factory.rb
|
200
|
+
- spec/factories/runtime_factory.rb
|
201
|
+
- spec/factories/service_binding_factory.rb
|
202
|
+
- spec/factories/service_factory.rb
|
203
|
+
- spec/factories/service_instance_factory.rb
|
203
204
|
- spec/factories/service_plan_factory.rb
|
205
|
+
- spec/factories/space_factory.rb
|
204
206
|
- spec/spec_helper.rb
|
205
|
-
- spec/cfoundry/uaaclient_spec.rb
|
206
|
-
has_rdoc: true
|
207
207
|
homepage: http://cloudfoundry.com/
|
208
208
|
licenses: []
|
209
209
|
|
@@ -233,23 +233,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
requirements: []
|
234
234
|
|
235
235
|
rubyforge_project: cfoundry
|
236
|
-
rubygems_version: 1.
|
236
|
+
rubygems_version: 1.8.24
|
237
237
|
signing_key:
|
238
238
|
specification_version: 3
|
239
239
|
summary: High-level library for working with the Cloud Foundry API.
|
240
240
|
test_files:
|
241
|
-
- spec/
|
242
|
-
- spec/
|
243
|
-
- spec/
|
244
|
-
- spec/factories/
|
241
|
+
- spec/cfoundry/baseclient_spec.rb
|
242
|
+
- spec/cfoundry/errors_spec.rb
|
243
|
+
- spec/cfoundry/uaaclient_spec.rb
|
244
|
+
- spec/factories/app_factory.rb
|
245
|
+
- spec/factories/client_factory.rb
|
246
|
+
- spec/factories/domain_factory.rb
|
245
247
|
- spec/factories/factory.rb
|
246
|
-
- spec/factories/runtime_factory.rb
|
247
|
-
- spec/factories/space_factory.rb
|
248
|
-
- spec/factories/organization_factory.rb
|
249
248
|
- spec/factories/framework_factory.rb
|
250
|
-
- spec/factories/
|
251
|
-
- spec/factories/
|
252
|
-
- spec/factories/
|
249
|
+
- spec/factories/organization_factory.rb
|
250
|
+
- spec/factories/route_factory.rb
|
251
|
+
- spec/factories/runtime_factory.rb
|
252
|
+
- spec/factories/service_binding_factory.rb
|
253
|
+
- spec/factories/service_factory.rb
|
254
|
+
- spec/factories/service_instance_factory.rb
|
253
255
|
- spec/factories/service_plan_factory.rb
|
256
|
+
- spec/factories/space_factory.rb
|
254
257
|
- spec/spec_helper.rb
|
255
|
-
- spec/cfoundry/uaaclient_spec.rb
|