cfoundry 0.2.1 → 0.2.2
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.
- data/lib/cfoundry/app.rb +16 -11
- data/lib/cfoundry/client.rb +3 -2
- data/lib/cfoundry/errors.rb +20 -7
- data/lib/cfoundry/service.rb +2 -1
- data/lib/cfoundry/user.rb +2 -1
- data/lib/cfoundry/version.rb +1 -1
- metadata +5 -4
data/lib/cfoundry/app.rb
CHANGED
|
@@ -60,7 +60,8 @@ module CFoundry
|
|
|
60
60
|
@manifest = manifest
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
# Show string representing the application.
|
|
64
|
+
def inspect
|
|
64
65
|
"#<App '#@name'>"
|
|
65
66
|
end
|
|
66
67
|
|
|
@@ -209,7 +210,8 @@ module CFoundry
|
|
|
209
210
|
alias :url :uri
|
|
210
211
|
alias :url= :uri=
|
|
211
212
|
|
|
212
|
-
|
|
213
|
+
# Application framework.
|
|
214
|
+
def framework
|
|
213
215
|
manifest["staging"]["framework"] ||
|
|
214
216
|
manifest["staging"]["model"]
|
|
215
217
|
end
|
|
@@ -225,7 +227,8 @@ module CFoundry
|
|
|
225
227
|
end
|
|
226
228
|
end
|
|
227
229
|
|
|
228
|
-
|
|
230
|
+
# Application runtime.
|
|
231
|
+
def runtime
|
|
229
232
|
manifest["staging"]["runtime"] ||
|
|
230
233
|
manifest["staging"]["stack"]
|
|
231
234
|
end
|
|
@@ -242,7 +245,10 @@ module CFoundry
|
|
|
242
245
|
end
|
|
243
246
|
|
|
244
247
|
|
|
245
|
-
|
|
248
|
+
# Application startup command.
|
|
249
|
+
#
|
|
250
|
+
# Used for standalone apps.
|
|
251
|
+
def command
|
|
246
252
|
manifest["staging"]["command"]
|
|
247
253
|
end
|
|
248
254
|
|
|
@@ -253,7 +259,8 @@ module CFoundry
|
|
|
253
259
|
end
|
|
254
260
|
|
|
255
261
|
|
|
256
|
-
|
|
262
|
+
# Application memory.
|
|
263
|
+
def memory
|
|
257
264
|
manifest["resources"]["memory"]
|
|
258
265
|
end
|
|
259
266
|
|
|
@@ -264,7 +271,8 @@ module CFoundry
|
|
|
264
271
|
end
|
|
265
272
|
|
|
266
273
|
|
|
267
|
-
|
|
274
|
+
# Application debug mode.
|
|
275
|
+
def debug_mode
|
|
268
276
|
manifest.fetch("debug") do
|
|
269
277
|
manifest["meta"] && manifest["meta"]["debug"]
|
|
270
278
|
end
|
|
@@ -310,8 +318,6 @@ module CFoundry
|
|
|
310
318
|
end
|
|
311
319
|
|
|
312
320
|
# Default paths to exclude from upload payload.
|
|
313
|
-
#
|
|
314
|
-
# Value: .git, _darcs, .svn
|
|
315
321
|
UPLOAD_EXCLUDE = %w{.git _darcs .svn}
|
|
316
322
|
|
|
317
323
|
# Upload application's code to target. Do this after #create! and before
|
|
@@ -402,8 +408,6 @@ module CFoundry
|
|
|
402
408
|
end
|
|
403
409
|
|
|
404
410
|
# Minimum size for an application payload to bother checking resources.
|
|
405
|
-
#
|
|
406
|
-
# Value: 64kb
|
|
407
411
|
RESOURCE_CHECK_LIMIT = 64 * 1024
|
|
408
412
|
|
|
409
413
|
def determine_resources(path)
|
|
@@ -480,7 +484,8 @@ module CFoundry
|
|
|
480
484
|
@manifest = manifest
|
|
481
485
|
end
|
|
482
486
|
|
|
483
|
-
|
|
487
|
+
# Show string representing the application instance.
|
|
488
|
+
def inspect
|
|
484
489
|
"#<App::Instance '#@app' \##@index>"
|
|
485
490
|
end
|
|
486
491
|
|
data/lib/cfoundry/client.rb
CHANGED
|
@@ -9,13 +9,14 @@ module CFoundry
|
|
|
9
9
|
# values. Initialize with the target and, optionally, an auth token. These
|
|
10
10
|
# are the only two internal states.
|
|
11
11
|
class Client
|
|
12
|
-
|
|
12
|
+
# Internal RESTClient instance. Normally won't be touching this.
|
|
13
|
+
attr_reader :rest
|
|
13
14
|
|
|
14
15
|
# Create a new Client for interfacing with the given target.
|
|
15
16
|
#
|
|
16
17
|
# A token may also be provided to skip the login step.
|
|
17
18
|
def initialize(target = "http://api.cloudfoundry.com", token = nil)
|
|
18
|
-
@rest = RESTClient.new(
|
|
19
|
+
@rest = RESTClient.new(target, token)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# The current target URL of the client.
|
data/lib/cfoundry/errors.rb
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
module CFoundry
|
|
2
2
|
# Exception representing errors returned by the API.
|
|
3
3
|
class APIError < RuntimeError
|
|
4
|
-
class << self
|
|
5
|
-
|
|
4
|
+
class << self
|
|
5
|
+
# Generic error code for the exception.
|
|
6
|
+
attr_reader :error_code
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
# Generic description for the exception.
|
|
9
|
+
attr_reader :description
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def setup(code, description = nil)
|
|
8
14
|
@error_code = code
|
|
9
15
|
@description = description
|
|
10
16
|
end
|
|
@@ -26,7 +32,8 @@ module CFoundry
|
|
|
26
32
|
@description || self.class.description
|
|
27
33
|
end
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
# Exception message.
|
|
36
|
+
def to_s
|
|
30
37
|
if error_code
|
|
31
38
|
"#{error_code}: #{description}"
|
|
32
39
|
else
|
|
@@ -53,7 +60,8 @@ module CFoundry
|
|
|
53
60
|
@message = message
|
|
54
61
|
end
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
# Exception message.
|
|
64
|
+
def to_s
|
|
57
65
|
"#{description} (#{@message})"
|
|
58
66
|
end
|
|
59
67
|
end
|
|
@@ -66,7 +74,11 @@ module CFoundry
|
|
|
66
74
|
# Exception raised when access is denied to something, either because the
|
|
67
75
|
# user is not logged in or is not an administrator.
|
|
68
76
|
class Denied < APIError
|
|
69
|
-
|
|
77
|
+
# Specific error code.
|
|
78
|
+
attr_reader :error_code
|
|
79
|
+
|
|
80
|
+
# Specific description.
|
|
81
|
+
attr_reader :description
|
|
70
82
|
|
|
71
83
|
# Initialize, with a default error code and message.
|
|
72
84
|
def initialize(
|
|
@@ -86,7 +98,8 @@ module CFoundry
|
|
|
86
98
|
@body = body
|
|
87
99
|
end
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
# Exception message.
|
|
102
|
+
def to_s
|
|
90
103
|
"target failed to handle our request due to an internal error (#{@code})"
|
|
91
104
|
end
|
|
92
105
|
end
|
data/lib/cfoundry/service.rb
CHANGED
data/lib/cfoundry/user.rb
CHANGED
data/lib/cfoundry/version.rb
CHANGED
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: 19
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.2.2
|
|
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-06-
|
|
18
|
+
date: 2012-06-04 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: rest-client
|
|
@@ -154,3 +154,4 @@ test_files:
|
|
|
154
154
|
- spec/client_spec.rb
|
|
155
155
|
- spec/helpers.rb
|
|
156
156
|
- spec/Rakefile
|
|
157
|
+
has_rdoc:
|