cloudfiles 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.2
1
+ 1.4.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudfiles}
8
- s.version = "1.4.2"
8
+ s.version = "1.4.3"
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{2009-11-03}
12
+ s.date = %q{2009-11-13}
13
13
  s.description = %q{A Ruby version of the Rackspace Cloud Files API.}
14
14
  s.email = %q{wade.minter@rackspace.com}
15
15
  s.extra_rdoc_files = [
@@ -23,6 +23,12 @@ module CloudFiles
23
23
 
24
24
  # The parent CloudFiles::Connection object for this container
25
25
  attr_reader :connection
26
+
27
+ # The container ACL on the User Agent
28
+ attr_reader :user_agent_acl
29
+
30
+ # The container ACL on the site Referrer
31
+ attr_reader :referrer_acl
26
32
 
27
33
  # Retrieves an existing CloudFiles::Container object tied to the current CloudFiles::Connection. If the requested
28
34
  # container does not exist, it will raise a NoSuchContainerException.
@@ -64,8 +70,10 @@ module CloudFiles
64
70
  # Get the CDN-related details
65
71
  response = self.connection.cfreq("HEAD",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme)
66
72
  @cdn_enabled = ((response["x-cdn-enabled"] || "").downcase == "true") ? true : false
67
- @cdn_ttl = @cdn_enabled ? response["x-ttl"] : false
73
+ @cdn_ttl = @cdn_enabled ? response["x-ttl"].to_i : false
68
74
  @cdn_url = @cdn_enabled ? response["x-cdn-uri"] : false
75
+ @user_agent_acl = response["x-user-agent-acl"]
76
+ @referrer_acl = response["x-referrer-acl"]
69
77
  if @cdn_enabled
70
78
  @cdn_log = response["x-log-retention"] == "False" ? false : true
71
79
  else
@@ -238,17 +246,38 @@ module CloudFiles
238
246
  # Makes a container publicly available via the Cloud Files CDN and returns true upon success. Throws NoSuchContainerException
239
247
  # if the container doesn't exist or if the request fails.
240
248
  #
241
- # Takes an optional argument, which is the CDN cache TTL in seconds (default 86400 seconds or 1 day, maximum 259200 or 3 days)
249
+ # Takes an optional hash of options, including:
250
+ #
251
+ # :ttl, which is the CDN cache TTL in seconds (default 86400 seconds or 1 day, minimum 3600 or 1 hour, maximum 259200 or 3 days)
242
252
  #
243
- # container.make_public(432000)
253
+ # :user_agent_acl, a Perl-compatible regular expression limiting access to this container to user agents matching the given regular expression
254
+ #
255
+ # :referrer_acl, a Perl-compatible regular expression limiting access to this container to HTTP referral URLs matching the given regular expression
256
+ #
257
+ # container.make_public(:ttl => 8900, :user_agent_acl => "/Mozilla/", :referrer_acl => "/^http://rackspace.com")
244
258
  # => true
245
- def make_public(ttl = 86400)
259
+ def make_public(options = {:ttl => 86400})
260
+ if options.is_a?(Fixnum)
261
+ print "DEPRECATED: make_public takes a hash of options now, instead of a TTL number"
262
+ ttl = options
263
+ options = {:ttl => ttl}
264
+ end
265
+ if options[:ttl] < 3600
266
+ options[:ttl] = 3600
267
+ end
268
+ if options[:ttl] > 259200
269
+ options[:ttl] = 259200
270
+ end
271
+
246
272
  response = self.connection.cfreq("PUT",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme)
247
273
  raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
248
274
 
249
- headers = { "X-TTL" => ttl.to_s , "X-CDN-Enabled" => "True" }
275
+ headers = { "X-TTL" => options[:ttl].to_s , "X-CDN-Enabled" => "True" }
276
+ headers["X-User-Agent-ACL"] = options[:user_agent_acl] if options[:user_agent_acl]
277
+ headers["X-Referrer-ACL"] = options[:referrer_acl] if options[:referrer_acl]
250
278
  response = self.connection.cfreq("POST",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme,headers)
251
279
  raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
280
+ populate
252
281
  true
253
282
  end
254
283
 
@@ -263,6 +292,7 @@ module CloudFiles
263
292
  headers = { "X-CDN-Enabled" => "False" }
264
293
  response = self.connection.cfreq("POST",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme,headers)
265
294
  raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
295
+ populate
266
296
  true
267
297
  end
268
298
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudfiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - H. Wade Minter
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-03 00:00:00 -06:00
13
+ date: 2009-11-13 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies: []
16
16