cfoundry-IronFoundry 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 +2 -2
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -104,12 +104,19 @@ module CFoundry
|
|
104
104
|
proxy_uri = URI.parse(req[:url]).find_proxy()
|
105
105
|
RestClient.proxy = proxy_uri.to_s if proxy_uri
|
106
106
|
|
107
|
-
RestClient::Request.execute(req) do |response, request|
|
107
|
+
RestClient::Request.execute(req) do |response, request, result, &block|
|
108
108
|
time = Time.now - before
|
109
109
|
|
110
|
-
print_trace(
|
111
|
-
log_request(time,
|
112
|
-
|
110
|
+
print_trace(request, response, caller) if @trace
|
111
|
+
log_request(time, request, response)
|
112
|
+
|
113
|
+
if [:get, :head].include?(method) && \
|
114
|
+
[301, 302, 307].include?(response.code) && \
|
115
|
+
accept != :headers
|
116
|
+
response.follow_redirection(request, result, &block)
|
117
|
+
else
|
118
|
+
handle_response(response, accept)
|
119
|
+
end
|
113
120
|
end
|
114
121
|
rescue SocketError, Errno::ECONNREFUSED => e
|
115
122
|
raise TargetRefused, e.message
|
@@ -178,11 +185,14 @@ module CFoundry
|
|
178
185
|
|
179
186
|
def log_data(time, request, response)
|
180
187
|
{ :time => time,
|
181
|
-
:request =>
|
188
|
+
:request => {
|
189
|
+
:method => request.method,
|
190
|
+
:url => request.url,
|
191
|
+
:headers => request.headers
|
192
|
+
},
|
182
193
|
:response => {
|
183
194
|
:code => response.code,
|
184
|
-
:headers => response.headers
|
185
|
-
:body => response
|
195
|
+
:headers => response.headers
|
186
196
|
}
|
187
197
|
}
|
188
198
|
end
|
@@ -232,10 +242,10 @@ module CFoundry
|
|
232
242
|
end
|
233
243
|
end
|
234
244
|
|
235
|
-
def print_trace(
|
245
|
+
def print_trace(request, response, locs)
|
236
246
|
$stderr.puts ">>>"
|
237
247
|
$stderr.puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
238
|
-
$stderr.puts "REQUEST: #{
|
248
|
+
$stderr.puts "REQUEST: #{request.method} #{request.url}"
|
239
249
|
$stderr.puts "RESPONSE_HEADERS:"
|
240
250
|
response.headers.each do |key, value|
|
241
251
|
$stderr.puts " #{key} : #{value}"
|
@@ -244,7 +254,7 @@ module CFoundry
|
|
244
254
|
request.headers.each do |key, value|
|
245
255
|
$stderr.puts " #{key} : #{value}"
|
246
256
|
end
|
247
|
-
$stderr.puts "REQUEST_BODY: #{
|
257
|
+
$stderr.puts "REQUEST_BODY: #{request.payload}" if request.payload
|
248
258
|
$stderr.puts "RESPONSE: [#{response.code}]"
|
249
259
|
begin
|
250
260
|
parsed_body = MultiJson.load(response.body)
|
@@ -277,7 +287,7 @@ module CFoundry
|
|
277
287
|
json = accept == :json
|
278
288
|
|
279
289
|
case response.code
|
280
|
-
when 200, 201, 204, 302
|
290
|
+
when 200, 201, 204, 301, 302, 307
|
281
291
|
if accept == :headers
|
282
292
|
return response.headers
|
283
293
|
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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry-IronFoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.40
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|