cfoundry 0.3.60 → 0.3.61

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.
@@ -55,8 +55,10 @@ module CFoundry
55
55
  def to_s
56
56
  if error_code
57
57
  "#{error_code}: #{description}"
58
- else
58
+ elsif description
59
59
  description
60
+ else
61
+ super
60
62
  end
61
63
  end
62
64
  end
@@ -93,7 +93,7 @@ module CFoundry::V1
93
93
  end
94
94
 
95
95
  # Retrieve available services.
96
- def services
96
+ def services(depth = 0, query = {})
97
97
  services = []
98
98
 
99
99
  @base.system_services.each do |type, vendors|
@@ -112,7 +112,7 @@ module CFoundry::V1
112
112
  end
113
113
 
114
114
  # Retrieve available runtimes.
115
- def runtimes
115
+ def runtimes(depth = 1, query = {})
116
116
  runtimes = []
117
117
 
118
118
  @base.system_runtimes.each do |name, meta|
@@ -129,7 +129,7 @@ module CFoundry::V1
129
129
  end
130
130
 
131
131
  # Retrieve available frameworks.
132
- def frameworks
132
+ def frameworks(depth = 1, query = {})
133
133
  fs = info[:frameworks]
134
134
  return unless fs
135
135
 
@@ -152,7 +152,7 @@ module CFoundry::V1
152
152
  end
153
153
 
154
154
  # Retrieve user list. Admin-only.
155
- def users
155
+ def users(depth = 1, query = {})
156
156
  @base.users.collect do |json|
157
157
  User.new(
158
158
  json[:email],
@@ -330,6 +330,10 @@ module CFoundry::V2
330
330
  Instance.new(self, "0", @client).file(*path)
331
331
  end
332
332
 
333
+ def stream_file(*path, &blk)
334
+ Instance.new(self, "0", @client).stream_file(*path, &blk)
335
+ end
336
+
333
337
  class Instance
334
338
  attr_reader :app, :id
335
339
 
@@ -389,6 +393,10 @@ module CFoundry::V2
389
393
  def file(*path)
390
394
  @client.base.files(@app.guid, @id, *path)
391
395
  end
396
+
397
+ def stream_file(*path, &blk)
398
+ @client.base.stream_file(@app.guid, @id, *path, &blk)
399
+ end
392
400
  end
393
401
 
394
402
  private
@@ -101,6 +101,31 @@ module CFoundry::V2
101
101
  end
102
102
  alias :file :files
103
103
 
104
+ def stream_file(guid, instance, *path)
105
+ redirect =
106
+ request_with_options(
107
+ Net::HTTP::Get,
108
+ ["v2", "apps", guid, "instances", instance, "files", *path],
109
+ :return_response => true)
110
+
111
+ if loc = redirect["location"]
112
+ uri = URI.parse(loc + "&tail")
113
+
114
+ Net::HTTP.start(uri.host, uri.port) do |http|
115
+ req = Net::HTTP::Get.new(uri.request_uri)
116
+ req["Authorization"] = @token
117
+
118
+ http.request(req) do |response|
119
+ response.read_body do |chunk|
120
+ yield chunk
121
+ end
122
+ end
123
+ end
124
+ else
125
+ yield redirect.body
126
+ end
127
+ end
128
+
104
129
  def instances(guid)
105
130
  get("v2", "apps", guid, "instances", :accept => :json)
106
131
  end
@@ -163,6 +188,8 @@ module CFoundry::V2
163
188
  Net::HTTPNotImplemented, Net::HTTPServiceUnavailable
164
189
  begin
165
190
  info = parse_json(response.body)
191
+ return super unless info[:code]
192
+
166
193
  cls = CFoundry::APIError.v2_classes[info[:code]]
167
194
 
168
195
  raise (cls || CFoundry::APIError).new(info[:code], info[:description])
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.60"
3
+ VERSION = "0.3.61"
4
4
  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: 107
4
+ hash: 105
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 60
10
- version: 0.3.60
9
+ - 61
10
+ version: 0.3.61
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-11-13 00:00:00 -08:00
18
+ date: 2012-11-15 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency