cloudfiles 1.4.7 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,6 +4,16 @@
4
4
 
5
5
  This is a Ruby interface into the Rackspace[http://rackspace.com/] {Cloud Files}[http://www.rackspacecloud.com/cloud_hosting_products/files] service. Cloud Files is reliable, scalable and affordable web-based storage hosting for backing up and archiving all your static content. Cloud Files is the first and only cloud service that leverages a tier one CDN provider to create such an easy and complete storage-to-delivery solution for media content.
6
6
 
7
+ == Upgrade Gotchas
8
+
9
+ As of gem version 1.4.8, the connection method has changed from positional arguments to a hash of options. This is the new style:
10
+
11
+ cf = CloudFiles::Connection.new(:username => "MY_USERNAME", :api_key => "MY_API_KEY")
12
+
13
+ This is the old style, which still works but is deprecated:
14
+
15
+ cf = CloudFiles::Connection.new("MY_USERNAME","MY_API_KEY")
16
+
7
17
  == Installation
8
18
 
9
19
  This source is available on Github[http://github.com/rackspace/ruby-cloudfiles/] and the gem is available on Gemcutter[http://gemcutter.org/]. To install it, do
@@ -25,7 +35,7 @@ See the class definitions for documentation on specific methods and operations.
25
35
  require 'cloudfiles'
26
36
 
27
37
  # Log into the Cloud Files system
28
- cf = CloudFiles::Connection.new(USERNAME, API_KEY)
38
+ cf = CloudFiles::Connection.new(:username => "MY_USERNAME", :api_key => "MY_API_KEY")
29
39
 
30
40
  # Get a listing of all containers under this account
31
41
  cf.containers
@@ -53,7 +63,7 @@ See the class definitions for documentation on specific methods and operations.
53
63
 
54
64
  Initial work by Major Hayden <major.hayden@rackspace.com>
55
65
 
56
- Subsequent work by H. Wade Minter <wade.minter@rackspace.com>
66
+ Subsequent work by H. Wade Minter <minter@lunenburg.org>
57
67
 
58
68
  == License
59
69
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  gemspec.name = "cloudfiles"
7
7
  gemspec.summary = "A Ruby API into Rackspace Cloud Files"
8
8
  gemspec.description = "A Ruby version of the Rackspace Cloud Files API."
9
- gemspec.email = "wade.minter@rackspace.com"
9
+ gemspec.email = "minter@lunenburg.org"
10
10
  gemspec.homepage = "http://www.rackspacecloud.com/cloud_hosting_products/files"
11
11
  gemspec.authors = ["H. Wade Minter", "Rackspace Hosting"]
12
12
  gemspec.add_dependency('mime-types', '>= 1.16')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.7
1
+ 1.4.8
data/cloudfiles.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudfiles}
8
- s.version = "1.4.7"
8
+ s.version = "1.4.8"
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{2010-03-05}
12
+ s.date = %q{2010-08-02}
13
13
  s.description = %q{A Ruby version of the Rackspace Cloud Files API.}
14
- s.email = %q{wade.minter@rackspace.com}
14
+ s.email = %q{minter@lunenburg.org}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc",
17
17
  "TODO"
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.homepage = %q{http://www.rackspacecloud.com/cloud_hosting_products/files}
41
41
  s.rdoc_options = ["--charset=UTF-8"]
42
42
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.6}
43
+ s.rubygems_version = %q{1.3.7}
44
44
  s.summary = %q{A Ruby API into Rackspace Cloud Files}
45
45
  s.test_files = [
46
46
  "test/cf-testunit.rb",
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
55
55
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
56
  s.specification_version = 3
57
57
 
58
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
59
  s.add_runtime_dependency(%q<mime-types>, [">= 1.16"])
60
60
  else
61
61
  s.add_dependency(%q<mime-types>, [">= 1.16"])
data/lib/cloudfiles.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # ==== Connects Ruby Applications to Rackspace's {Cloud Files service}[http://www.rackspacecloud.com/cloud_hosting_products/files]
5
5
  # Initial work by Major Hayden <major.hayden@rackspace.com>
6
6
  #
7
- # Subsequent work by H. Wade Minter <wade.minter@rackspace.com>
7
+ # Subsequent work by H. Wade Minter <minter@lunenburg.org>
8
8
  #
9
9
  # See COPYING for license information.
10
10
  # Copyright (c) 2009, Rackspace US, Inc.
@@ -13,7 +13,7 @@ module CloudFiles
13
13
  path = '/v1.0'
14
14
  hdrhash = { "X-Auth-User" => connection.authuser, "X-Auth-Key" => connection.authkey }
15
15
  begin
16
- server = Net::HTTP.new('auth.api.rackspacecloud.com',443)
16
+ server = Net::HTTP::Proxy(connection.proxy_host, connection.proxy_port).new('auth.api.rackspacecloud.com',443)
17
17
  server.use_ssl = true
18
18
  server.verify_mode = OpenSSL::SSL::VERIFY_NONE
19
19
  server.start
@@ -45,6 +45,10 @@ module CloudFiles
45
45
  # The total number of containers under this connection
46
46
  attr_reader :count
47
47
 
48
+ # Optional proxy variables
49
+ attr_reader :proxy_host
50
+ attr_reader :proxy_port
51
+
48
52
  # Creates a new CloudFiles::Connection object. Uses CloudFiles::Authentication to perform the login for the connection.
49
53
  # The authuser is the Rackspace Cloud username, the authkey is the Rackspace Cloud API key.
50
54
  #
@@ -58,13 +62,30 @@ module CloudFiles
58
62
  # the public network, and the bandwidth is not billed.
59
63
  #
60
64
  # This will likely be the base class for most operations.
65
+ #
66
+ # With gem 1.4.8, the connection style has changed. It is now a hash of arguments. Note that the proxy options are currently only
67
+ # supported in the new style.
68
+ #
69
+ # cf = CloudFiles::Connection.new(:username => "MY_USERNAME", :api_key => "MY_API_KEY", :retry_auth => true, :snet => false, :proxy_host => "localhost", :proxy_port => "1234")
61
70
  #
62
- # cf = CloudFiles::Connection.new(MY_USERNAME, MY_API_KEY)
63
- def initialize(authuser,authkey,retry_auth = true,snet=false)
64
- @authuser = authuser
65
- @authkey = authkey
66
- @retry_auth = retry_auth
67
- @snet = (ENV['RACKSPACE_SERVICENET'] || snet) ? true : false
71
+ # The old style (positional arguments) is deprecated and will be removed at some point in the future.
72
+ #
73
+ # cf = CloudFiles::Connection.new(MY_USERNAME, MY_API_KEY, RETRY_AUTH, USE_SNET)
74
+ def initialize(*args)
75
+ if args[0].is_a?(Hash)
76
+ options = args[0]
77
+ @authuser = options[:username] ||( raise AuthenticationException, "Must supply a :username")
78
+ @authkey = options[:api_key] || (raise AuthenticationException, "Must supply an :api_key")
79
+ @retry_auth = options[:retry_auth] || true
80
+ @snet = ENV['RACKSPACE_SERVICENET'] || options[:snet]
81
+ @proxy_host = options[:proxy_host]
82
+ @proxy_port = options[:proxy_port]
83
+ elsif args[0].is_a?(String)
84
+ @authuser = args[0] ||( raise AuthenticationException, "Must supply the username as the first argument")
85
+ @authkey = args[1] || (raise AuthenticationException, "Must supply the API key as the second argument")
86
+ @retry_auth = args[2] || true
87
+ @snet = (ENV['RACKSPACE_SERVICENET'] || args[3]) ? true : false
88
+ end
68
89
  @authok = false
69
90
  @http = {}
70
91
  CloudFiles::Authentication.new(self)
@@ -279,7 +300,7 @@ module CloudFiles
279
300
  def start_http(server,path,port,scheme,headers) # :nodoc:
280
301
  if (@http[server].nil?)
281
302
  begin
282
- @http[server] = Net::HTTP.new(server,port)
303
+ @http[server] = Net::HTTP::Proxy(self.proxy_host, self.proxy_port).new(server,port)
283
304
  if scheme == "https"
284
305
  @http[server].use_ssl = true
285
306
  @http[server].verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -133,8 +133,8 @@ module CloudFiles
133
133
  # if the request fails.
134
134
  def objects(params = {})
135
135
  paramarr = []
136
- paramarr << ["limit=#{URI.encode(params[:limit].to_i.to_s).gsub(/&/,'%26')}"] if params[:limit]
137
- paramarr << ["offset=#{URI.encode(params[:offset].to_i.to_s).gsub(/&/,'%26')}"] if params[:offset]
136
+ paramarr << ["limit=#{URI.encode(params[:limit].to_s).gsub(/&/,'%26')}"] if params[:limit]
137
+ paramarr << ["offset=#{URI.encode(params[:offset].to_s).gsub(/&/,'%26')}"] if params[:offset]
138
138
  paramarr << ["prefix=#{URI.encode(params[:prefix]).gsub(/&/,'%26')}"] if params[:prefix]
139
139
  paramarr << ["path=#{URI.encode(params[:path]).gsub(/&/,'%26')}"] if params[:path]
140
140
  paramstr = (paramarr.size > 0)? paramarr.join("&") : "" ;
@@ -164,8 +164,8 @@ module CloudFiles
164
164
  def objects_detail(params = {})
165
165
  paramarr = []
166
166
  paramarr << ["format=xml"]
167
- paramarr << ["limit=#{URI.encode(params[:limit].to_i).gsub(/&/,'%26')}"] if params[:limit]
168
- paramarr << ["offset=#{URI.encode(params[:offset].to_i).gsub(/&/,'%26')}"] if params[:offset]
167
+ paramarr << ["limit=#{URI.encode(params[:limit].to_s).gsub(/&/,'%26')}"] if params[:limit]
168
+ paramarr << ["offset=#{URI.encode(params[:offset].to_s).gsub(/&/,'%26')}"] if params[:offset]
169
169
  paramarr << ["prefix=#{URI.encode(params[:prefix]).gsub(/&/,'%26')}"] if params[:prefix]
170
170
  paramarr << ["path=#{URI.encode(params[:path]).gsub(/&/,'%26')}"] if params[:path]
171
171
  paramstr = (paramarr.size > 0)? paramarr.join("&") : "" ;
@@ -262,12 +262,6 @@ module CloudFiles
262
262
  ttl = options
263
263
  options = {:ttl => ttl}
264
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
265
 
272
266
  response = self.connection.cfreq("PUT",@cdnmgmthost,@cdnmgmtpath,@cdnmgmtport,@cdnmgmtscheme)
273
267
  raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudfiles
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 4
8
- - 7
9
- version: 1.4.7
9
+ - 8
10
+ version: 1.4.8
10
11
  platform: ruby
11
12
  authors:
12
13
  - H. Wade Minter
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-03-05 00:00:00 -06:00
19
+ date: 2010-08-02 00:00:00 -04:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: mime-types
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 47
28
31
  segments:
29
32
  - 1
30
33
  - 16
@@ -32,7 +35,7 @@ dependencies:
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  description: A Ruby version of the Rackspace Cloud Files API.
35
- email: wade.minter@rackspace.com
38
+ email: minter@lunenburg.org
36
39
  executables: []
37
40
 
38
41
  extensions: []
@@ -70,23 +73,27 @@ rdoc_options:
70
73
  require_paths:
71
74
  - lib
72
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
73
77
  requirements:
74
78
  - - ">="
75
79
  - !ruby/object:Gem::Version
80
+ hash: 3
76
81
  segments:
77
82
  - 0
78
83
  version: "0"
79
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
80
86
  requirements:
81
87
  - - ">="
82
88
  - !ruby/object:Gem::Version
89
+ hash: 3
83
90
  segments:
84
91
  - 0
85
92
  version: "0"
86
93
  requirements: []
87
94
 
88
95
  rubyforge_project:
89
- rubygems_version: 1.3.6
96
+ rubygems_version: 1.3.7
90
97
  signing_key:
91
98
  specification_version: 3
92
99
  summary: A Ruby API into Rackspace Cloud Files