cfoundry 0.3.20 → 0.3.21
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/baseclient.rb +6 -5
- data/lib/cfoundry/uaaclient.rb +1 -1
- data/lib/cfoundry/v1/app.rb +7 -1
- data/lib/cfoundry/v1/base.rb +3 -4
- data/lib/cfoundry/v1/framework.rb +5 -0
- data/lib/cfoundry/v1/runtime.rb +5 -0
- data/lib/cfoundry/v1/service.rb +5 -0
- data/lib/cfoundry/v1/service_instance.rb +6 -0
- data/lib/cfoundry/v1/user.rb +6 -0
- data/lib/cfoundry/v2/app.rb +2 -2
- data/lib/cfoundry/v2/base.rb +3 -3
- data/lib/cfoundry/v2/client.rb +3 -1
- data/lib/cfoundry/v2/model.rb +5 -1
- data/lib/cfoundry/v2/service_binding.rb +0 -3
- data/lib/cfoundry/v2/service_instance.rb +0 -2
- data/lib/cfoundry/version.rb +1 -1
- metadata +8 -8
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "restclient"
|
2
|
-
require "
|
2
|
+
require "multi_json"
|
3
3
|
|
4
4
|
module CFoundry
|
5
5
|
class BaseClient # :nodoc:
|
@@ -30,7 +30,7 @@ module CFoundry
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def parse_json(x)
|
33
|
-
|
33
|
+
MultiJson.load(x, :symbolize_keys => true)
|
34
34
|
end
|
35
35
|
|
36
36
|
def request(method, path, options = {})
|
@@ -54,7 +54,7 @@ module CFoundry
|
|
54
54
|
unless payload.is_a?(String)
|
55
55
|
case type
|
56
56
|
when :json
|
57
|
-
payload = payload
|
57
|
+
payload = MultiJson.dump(payload)
|
58
58
|
when :form
|
59
59
|
payload = encode_params(payload)
|
60
60
|
end
|
@@ -93,7 +93,8 @@ module CFoundry
|
|
93
93
|
$stderr.puts "REQUEST_BODY: #{req[:payload]}" if req[:payload]
|
94
94
|
$stderr.puts "RESPONSE: [#{response.code}]"
|
95
95
|
begin
|
96
|
-
|
96
|
+
parsed_body = MultiJson.load(response.body)
|
97
|
+
$stderr.puts MultiJson.dump(parsed_body, :pretty => true)
|
97
98
|
rescue
|
98
99
|
$stderr.puts "#{response.body}"
|
99
100
|
end
|
@@ -127,7 +128,7 @@ module CFoundry
|
|
127
128
|
def encode_params(hash, escape = true)
|
128
129
|
hash.keys.map do |k|
|
129
130
|
v = hash[k]
|
130
|
-
v = v
|
131
|
+
v = MultiJson.dump(v) if v.is_a?(Hash)
|
131
132
|
v = URI.escape(v.to_s, /[^#{URI::PATTERN::UNRESERVED}]/) if escape
|
132
133
|
"#{k}=#{v}"
|
133
134
|
end.join("&")
|
data/lib/cfoundry/uaaclient.rb
CHANGED
data/lib/cfoundry/v1/app.rb
CHANGED
@@ -70,6 +70,12 @@ module CFoundry::V1
|
|
70
70
|
"#<App '#@name'>"
|
71
71
|
end
|
72
72
|
|
73
|
+
# Basic equality test by name.
|
74
|
+
def eql?(other)
|
75
|
+
other.is_a?(self.class) && other.name == @name
|
76
|
+
end
|
77
|
+
alias :== :eql?
|
78
|
+
|
73
79
|
# Delete the application from the target.
|
74
80
|
#
|
75
81
|
# Keeps the metadata, but clears target-specific state from it.
|
@@ -300,7 +306,7 @@ module CFoundry::V1
|
|
300
306
|
end
|
301
307
|
|
302
308
|
def binds?(instance)
|
303
|
-
services.
|
309
|
+
services.include? instance
|
304
310
|
end
|
305
311
|
|
306
312
|
# Retrieve file listing under path for the first instance of the application.
|
data/lib/cfoundry/v1/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "multi_json"
|
2
2
|
|
3
3
|
require "cfoundry/baseclient"
|
4
4
|
require "cfoundry/uaaclient"
|
@@ -105,7 +105,6 @@ module CFoundry::V1
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def delete_app(name)
|
108
|
-
# TODO: no JSON response?
|
109
108
|
delete("apps", name)
|
110
109
|
true
|
111
110
|
end
|
@@ -121,7 +120,7 @@ module CFoundry::V1
|
|
121
120
|
def upload_app(name, zipfile, resources = [])
|
122
121
|
payload = {
|
123
122
|
:_method => "put",
|
124
|
-
:resources => resources
|
123
|
+
:resources => MultiJson.dump(resources),
|
125
124
|
:multipart => true,
|
126
125
|
:application =>
|
127
126
|
if zipfile.is_a? File
|
@@ -185,7 +184,7 @@ module CFoundry::V1
|
|
185
184
|
when 411, 500, 504
|
186
185
|
begin
|
187
186
|
raise_error(parse_json(response))
|
188
|
-
rescue
|
187
|
+
rescue MultiJson::DecodeError
|
189
188
|
raise CFoundry::BadResponse.new(response.code, response)
|
190
189
|
end
|
191
190
|
|
data/lib/cfoundry/v1/runtime.rb
CHANGED
data/lib/cfoundry/v1/service.rb
CHANGED
@@ -41,6 +41,12 @@ module CFoundry::V1
|
|
41
41
|
"#<ServiceInstance '#@name'>"
|
42
42
|
end
|
43
43
|
|
44
|
+
# Basic equality test by name.
|
45
|
+
def eql?(other)
|
46
|
+
other.is_a?(self.class) && other.name == @name
|
47
|
+
end
|
48
|
+
alias :== :eql?
|
49
|
+
|
44
50
|
# Delete the service from the target.
|
45
51
|
def delete!
|
46
52
|
@client.base.delete_service(@name)
|
data/lib/cfoundry/v1/user.rb
CHANGED
@@ -23,6 +23,12 @@ module CFoundry::V1
|
|
23
23
|
"#<User '#@email'>"
|
24
24
|
end
|
25
25
|
|
26
|
+
# Basic equality test by email.
|
27
|
+
def eql?(other)
|
28
|
+
other.is_a?(self.class) && other.email == @email
|
29
|
+
end
|
30
|
+
alias :== :eql?
|
31
|
+
|
26
32
|
# Delete the user from the target.
|
27
33
|
def delete!
|
28
34
|
@client.base.delete_user(@email)
|
data/lib/cfoundry/v2/app.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "tmpdir"
|
2
|
-
require "
|
2
|
+
require "multi_json"
|
3
3
|
|
4
4
|
require "cfoundry/zip"
|
5
5
|
require "cfoundry/upload_helpers"
|
@@ -42,7 +42,7 @@ module CFoundry::V2
|
|
42
42
|
def env
|
43
43
|
@env ||= CFoundry::ChattyHash.new(
|
44
44
|
method(:env=),
|
45
|
-
|
45
|
+
MultiJson.load(environment_json))
|
46
46
|
end
|
47
47
|
|
48
48
|
def env=(hash)
|
data/lib/cfoundry/v2/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "multi_json"
|
2
2
|
require "base64"
|
3
3
|
|
4
4
|
require "cfoundry/baseclient"
|
@@ -84,7 +84,7 @@ module CFoundry::V2
|
|
84
84
|
|
85
85
|
def upload_app(guid, zipfile, resources = [])
|
86
86
|
payload = {
|
87
|
-
:resources => resources
|
87
|
+
:resources => MultiJson.dump(resources),
|
88
88
|
:multipart => true,
|
89
89
|
:application =>
|
90
90
|
if zipfile.is_a? File
|
@@ -149,7 +149,7 @@ module CFoundry::V2
|
|
149
149
|
begin
|
150
150
|
info = parse_json(response)
|
151
151
|
raise CFoundry::APIError.new(info[:code], info[:description])
|
152
|
-
rescue
|
152
|
+
rescue MultiJson::DecodeError
|
153
153
|
raise CFoundry::BadResponse.new(response.code, response)
|
154
154
|
end
|
155
155
|
|
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "multi_json"
|
1
2
|
require "base64"
|
2
3
|
|
3
4
|
require "cfoundry/v2/base"
|
@@ -61,6 +62,7 @@ module CFoundry::V2
|
|
61
62
|
# printed out.
|
62
63
|
def trace=(bool)
|
63
64
|
@base.trace = bool
|
65
|
+
@base.uaa.trace = bool if @base.uaa
|
64
66
|
end
|
65
67
|
|
66
68
|
# The currently authenticated user.
|
@@ -199,7 +201,7 @@ module CFoundry::V2
|
|
199
201
|
def token_data
|
200
202
|
tok = Base64.decode64(@base.token.sub(/^bearer\s+/, ""))
|
201
203
|
tok.sub!(/\{.+?\}/, "") # clear algo
|
202
|
-
|
204
|
+
MultiJson.load(tok[/\{.+?\}/], :symbolize_keys => true)
|
203
205
|
|
204
206
|
# normally i don't catch'em all, but can't expect all tokens to be the
|
205
207
|
# proper format, so just silently fail as this is not critical
|
data/lib/cfoundry/v2/model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
1
3
|
module CFoundry::V2
|
2
4
|
class Model
|
3
5
|
class << self
|
@@ -155,7 +157,7 @@ module CFoundry::V2
|
|
155
157
|
end
|
156
158
|
end
|
157
159
|
elsif k.to_s.end_with?("_json") && v.is_a?(String)
|
158
|
-
payload[k] =
|
160
|
+
payload[k] = MultiJson.load(v)
|
159
161
|
elsif k.to_s.end_with?("_url")
|
160
162
|
else
|
161
163
|
payload[k] = v
|
@@ -189,6 +191,8 @@ module CFoundry::V2
|
|
189
191
|
if @manifest
|
190
192
|
@manifest.delete :metadata
|
191
193
|
end
|
194
|
+
|
195
|
+
true
|
192
196
|
end
|
193
197
|
|
194
198
|
def exists?
|
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: 57
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 21
|
10
|
+
version: 0.3.21
|
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-08-
|
18
|
+
date: 2012-08-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|
@@ -34,19 +34,19 @@ dependencies:
|
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: multi_json
|
38
38
|
prerelease: false
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 23
|
45
45
|
segments:
|
46
46
|
- 1
|
47
|
+
- 3
|
47
48
|
- 6
|
48
|
-
|
49
|
-
version: 1.6.5
|
49
|
+
version: 1.3.6
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|