cfoundry 0.3.39 → 0.3.40
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/baseclient.rb +21 -11
- data/lib/cfoundry/chatty_hash.rb +4 -0
- data/lib/cfoundry/v1/base.rb +1 -1
- data/lib/cfoundry/v2/app.rb +6 -2
- data/lib/cfoundry/v2/base.rb +1 -1
- data/lib/cfoundry/v2/client.rb +6 -3
- data/lib/cfoundry/version.rb +1 -1
- metadata +4 -4
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -101,12 +101,19 @@ module CFoundry
|
|
101
101
|
|
102
102
|
before = Time.now
|
103
103
|
|
104
|
-
RestClient::Request.execute(req) do |response, request|
|
104
|
+
RestClient::Request.execute(req) do |response, request, result, &block|
|
105
105
|
time = Time.now - before
|
106
106
|
|
107
|
-
print_trace(
|
108
|
-
log_request(time,
|
109
|
-
|
107
|
+
print_trace(request, response, caller) if @trace
|
108
|
+
log_request(time, request, response)
|
109
|
+
|
110
|
+
if [:get, :head].include?(method) && \
|
111
|
+
[301, 302, 307].include?(response.code) && \
|
112
|
+
accept != :headers
|
113
|
+
response.follow_redirection(request, result, &block)
|
114
|
+
else
|
115
|
+
handle_response(response, accept)
|
116
|
+
end
|
110
117
|
end
|
111
118
|
rescue SocketError, Errno::ECONNREFUSED => e
|
112
119
|
raise TargetRefused, e.message
|
@@ -175,11 +182,14 @@ module CFoundry
|
|
175
182
|
|
176
183
|
def log_data(time, request, response)
|
177
184
|
{ :time => time,
|
178
|
-
:request =>
|
185
|
+
:request => {
|
186
|
+
:method => request.method,
|
187
|
+
:url => request.url,
|
188
|
+
:headers => request.headers
|
189
|
+
},
|
179
190
|
:response => {
|
180
191
|
:code => response.code,
|
181
|
-
:headers => response.headers
|
182
|
-
:body => response
|
192
|
+
:headers => response.headers
|
183
193
|
}
|
184
194
|
}
|
185
195
|
end
|
@@ -229,10 +239,10 @@ module CFoundry
|
|
229
239
|
end
|
230
240
|
end
|
231
241
|
|
232
|
-
def print_trace(
|
242
|
+
def print_trace(request, response, locs)
|
233
243
|
$stderr.puts ">>>"
|
234
244
|
$stderr.puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
235
|
-
$stderr.puts "REQUEST: #{
|
245
|
+
$stderr.puts "REQUEST: #{request.method} #{request.url}"
|
236
246
|
$stderr.puts "RESPONSE_HEADERS:"
|
237
247
|
response.headers.each do |key, value|
|
238
248
|
$stderr.puts " #{key} : #{value}"
|
@@ -241,7 +251,7 @@ module CFoundry
|
|
241
251
|
request.headers.each do |key, value|
|
242
252
|
$stderr.puts " #{key} : #{value}"
|
243
253
|
end
|
244
|
-
$stderr.puts "REQUEST_BODY: #{
|
254
|
+
$stderr.puts "REQUEST_BODY: #{request.payload}" if request.payload
|
245
255
|
$stderr.puts "RESPONSE: [#{response.code}]"
|
246
256
|
begin
|
247
257
|
parsed_body = MultiJson.load(response.body)
|
@@ -274,7 +284,7 @@ module CFoundry
|
|
274
284
|
json = accept == :json
|
275
285
|
|
276
286
|
case response.code
|
277
|
-
when 200, 201, 204, 302
|
287
|
+
when 200, 201, 204, 301, 302, 307
|
278
288
|
if accept == :headers
|
279
289
|
return response.headers
|
280
290
|
end
|
data/lib/cfoundry/chatty_hash.rb
CHANGED
data/lib/cfoundry/v1/base.rb
CHANGED
data/lib/cfoundry/v2/app.rb
CHANGED
@@ -64,7 +64,9 @@ module CFoundry::V2
|
|
64
64
|
environment_json)
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
def env=(x)
|
68
|
+
self.environment_json = x.to_hash
|
69
|
+
end
|
68
70
|
|
69
71
|
def debug_mode # TODO v2
|
70
72
|
nil
|
@@ -111,7 +113,9 @@ module CFoundry::V2
|
|
111
113
|
alias :create_route :create_routes
|
112
114
|
|
113
115
|
def uri
|
114
|
-
|
116
|
+
if route = routes.first
|
117
|
+
"#{route.host}.#{route.domain.name}"
|
118
|
+
end
|
115
119
|
end
|
116
120
|
alias :url :uri
|
117
121
|
|
data/lib/cfoundry/v2/base.rb
CHANGED
data/lib/cfoundry/v2/client.rb
CHANGED
@@ -173,11 +173,14 @@ module CFoundry::V2
|
|
173
173
|
end
|
174
174
|
|
175
175
|
if has_name
|
176
|
-
define_method(:"#{singular}_by_name") do |name|
|
176
|
+
define_method(:"#{singular}_by_name") do |name, *args|
|
177
|
+
depth, _ = args
|
178
|
+
depth ||= 1
|
179
|
+
|
177
180
|
if has_space && current_space
|
178
|
-
current_space.send(plural,
|
181
|
+
current_space.send(plural, depth, :name => name).first
|
179
182
|
else
|
180
|
-
send(plural,
|
183
|
+
send(plural, depth, :name => name).first
|
181
184
|
end
|
182
185
|
end
|
183
186
|
end
|
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: 67
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 40
|
10
|
+
version: 0.3.40
|
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-
|
18
|
+
date: 2012-10-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|