cloudfiles 1.4.13 → 1.4.14

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ ================================================================================
2
+ 1.4.14 (2011/02/24)
3
+ ================================================================================
4
+ o Added CDN Purge functionality for containers and objects.
5
+
1
6
  ================================================================================
2
7
  1.4.13 (2011/02/22)
3
8
  ================================================================================
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.13
1
+ 1.4.14
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudfiles}
8
- s.version = "1.4.13"
8
+ s.version = "1.4.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["H. Wade Minter", "Rackspace Hosting"]
12
- s.date = %q{2011-02-22}
12
+ s.date = %q{2011-03-04}
13
13
  s.description = %q{A Ruby version of the Rackspace Cloud Files API.}
14
14
  s.email = %q{minter@lunenburg.org}
15
15
  s.extra_rdoc_files = [
@@ -289,7 +289,11 @@ module CloudFiles
289
289
  # Server closed the connection, retry
290
290
  raise CloudFiles::Exception::Connection, "Unable to reconnect to #{server} after #{count} attempts" if attempts >= 5
291
291
  attempts += 1
292
- @http[server].finish
292
+ begin
293
+ @http[server].finish
294
+ rescue
295
+ nil
296
+ end
293
297
  start_http(server, path, port, scheme, headers)
294
298
  retry
295
299
  rescue ExpiredAuthTokenException
@@ -300,7 +300,7 @@ module CloudFiles
300
300
  refresh
301
301
  true
302
302
  end
303
-
303
+
304
304
  # Makes a container private and returns true upon success. Throws NoSuchContainerException
305
305
  # if the container doesn't exist or if the request fails.
306
306
  #
@@ -316,6 +316,35 @@ module CloudFiles
316
316
  true
317
317
  end
318
318
 
319
+ # Purges CDN Edge Cache for all objects inside of this container
320
+ #
321
+ # :email, An valid email address or comma seperated
322
+ # list of emails to be notified once purge is complete .
323
+ #
324
+ # container.purge_from_cdn
325
+ # => true
326
+ #
327
+ # or
328
+ #
329
+ # container.purge_from_cdn("User@domain.com")
330
+ # => true
331
+ #
332
+ # or
333
+ #
334
+ # container.purge_from_cdn("User@domain.com, User2@domain.com")
335
+ # => true
336
+ def purge_from_cdn(email=nil)
337
+ if email
338
+ headers = {"X-Purge-Email" => email}
339
+ response = self.connection.cfreq("DELETE", @cdnmgmthost, @cdnmgmtpath, @cdnmgmtport, @cdnmgmtscheme, headers)
340
+ raise CloudFiles::Exception::Connection, "Error Unable to Purge Container: #{@name}" unless (response.code > "200" && response.code < "299")
341
+ else
342
+ response = self.connection.cfreq("DELETE", @cdnmgmthost, @cdnmgmtpath, @cdnmgmtport, @cdnmgmtscheme)
343
+ raise CloudFiles::Exception::Connection, "Error Unable to Purge Container: #{@name}" unless (response.code > "200" && response.code < "299")
344
+ true
345
+ end
346
+ end
347
+
319
348
  def to_s # :nodoc:
320
349
  @name
321
350
  end
@@ -24,6 +24,10 @@ module CloudFiles
24
24
  @storagepath = self.container.connection.storagepath + "/#{CloudFiles.escape @containername}/#{CloudFiles.escape @name, '/'}"
25
25
  @storageport = self.container.connection.storageport
26
26
  @storagescheme = self.container.connection.storagescheme
27
+ @cdnmgmthost = self.container.connection.cdnmgmthost
28
+ @cdnmgmtpath = self.container.connection.cdnmgmtpath + "/#{CloudFiles.escape @containername}/#{CloudFiles.escape @name, '/'}"
29
+ @cdnmgmtport = self.container.connection.cdnmgmtport
30
+ @cdnmgmtscheme = self.container.connection.cdnmgmtscheme
27
31
  if force_exists
28
32
  raise CloudFiles::Exception::NoSuchObject, "Object #{@name} does not exist" unless container.object_exists?(objectname)
29
33
  end
@@ -110,7 +114,7 @@ module CloudFiles
110
114
  headers['Range'] = range
111
115
  end
112
116
  self.container.connection.cfreq("GET", @storagehost, @storagepath, @storageport, @storagescheme, headers, nil) do |response|
113
- raise CloudFiles::Exception::NoSuchObject, "Object #{@name} does not exist" unless (response.code == "200")
117
+ raise CloudFiles::Exception::NoSuchObject, "Object #{@name} does not exist. Response code #{response.code}" unless (response.code =~ /^20./)
114
118
  response.read_body(&block)
115
119
  end
116
120
  end
@@ -189,6 +193,34 @@ module CloudFiles
189
193
  self.refresh
190
194
  true
191
195
  end
196
+ # Purges CDN Edge Cache for all objects inside of this container
197
+ #
198
+ # :email, An valid email address or comma seperated
199
+ # list of emails to be notified once purge is complete .
200
+ #
201
+ # obj.purge_from_cdn
202
+ # => true
203
+ #
204
+ # or
205
+ #
206
+ # obj.purge_from_cdn("User@domain.com")
207
+ # => true
208
+ #
209
+ # or
210
+ #
211
+ # obj.purge_from_cdn("User@domain.com, User2@domain.com")
212
+ # => true
213
+ def purge_from_cdn(email=nil)
214
+ if email
215
+ headers = {"X-Purge-Email" => email}
216
+ response = self.container.connection.cfreq("DELETE", @cdnmgmthost, @cdnmgmtpath, @cdnmgmtport, @cdnmgmtscheme, headers)
217
+ raise CloudFiles::Exception::Connection, "Error Unable to Purge Object: #{@name}" unless (response.code.to_s =~ /^20.$/)
218
+ else
219
+ response = self.container..connection.cfreq("DELETE", @cdnmgmthost, @cdnmgmtpath, @cdnmgmtport, @cdnmgmtscheme)
220
+ raise CloudFiles::Exception::Connection, "Error Unable to Purge Object: #{@name}" unless (response.code.to_s =~ /^20.$/)
221
+ end
222
+ true
223
+ end
192
224
 
193
225
  # A convenience method to stream data into an object from a local file (or anything that can be loaded by Ruby's open method)
194
226
  #
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudfiles
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 13
10
- version: 1.4.13
9
+ - 14
10
+ version: 1.4.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - H. Wade Minter
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-22 00:00:00 -05:00
19
+ date: 2011-03-04 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency