cloudfiles 1.4.0 → 1.4.1

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.
@@ -8,7 +8,7 @@ This is a Ruby interface into the Rackspace[http://rackspace.com/] {Cloud Files}
8
8
 
9
9
  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
10
10
 
11
- gem sources -a http://gems.rubyforge.org/
11
+ gem sources -a http://gemcutter.org/
12
12
 
13
13
  sudo gem install cloudfiles
14
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cloudfiles}
8
- s.version = "1.4.0"
8
+ s.version = "1.4.1"
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-10-08}
12
+ s.date = %q{2009-10-20}
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 = [
@@ -60,3 +60,4 @@ Gem::Specification.new do |s|
60
60
  else
61
61
  end
62
62
  end
63
+
@@ -18,7 +18,7 @@
18
18
  # To create a new CloudFiles connection, use the CloudFiles::Connection.new('user_name', 'api_key') method.
19
19
  module CloudFiles
20
20
 
21
- VERSION = '1.4.0.0'
21
+ VERSION = IO.read(File.dirname(__FILE__) + '/../VERSION')
22
22
  require 'net/http'
23
23
  require 'net/https'
24
24
  require 'rexml/document'
@@ -26,7 +26,7 @@ module CloudFiles
26
26
  connection.cdnmgmtpath = URI.parse(response["x-cdn-management-url"]).path
27
27
  connection.cdnmgmtport = URI.parse(response["x-cdn-management-url"]).port
28
28
  connection.cdnmgmtscheme = URI.parse(response["x-cdn-management-url"]).scheme
29
- connection.storagehost = URI.parse(response["x-storage-url"]).host
29
+ connection.storagehost = set_snet(connection,URI.parse(response["x-storage-url"]).host)
30
30
  connection.storagepath = URI.parse(response["x-storage-url"]).path
31
31
  connection.storageport = URI.parse(response["x-storage-url"]).port
32
32
  connection.storagescheme = URI.parse(response["x-storage-url"]).scheme
@@ -38,5 +38,15 @@ module CloudFiles
38
38
  end
39
39
  server.finish
40
40
  end
41
+
42
+ private
43
+
44
+ def set_snet(connection,hostname)
45
+ if connection.snet?
46
+ "snet-#{hostname}"
47
+ else
48
+ hostname
49
+ end
50
+ end
41
51
  end
42
52
  end
@@ -44,20 +44,27 @@ module CloudFiles
44
44
 
45
45
  # The total number of containers under this connection
46
46
  attr_reader :count
47
-
47
+
48
48
  # Creates a new CloudFiles::Connection object. Uses CloudFiles::Authentication to perform the login for the connection.
49
49
  # The authuser is the Rackspace Cloud username, the authkey is the Rackspace Cloud API key.
50
50
  #
51
51
  # Setting the optional retry_auth variable to false will cause an exception to be thrown if your authorization token expires.
52
52
  # Otherwise, it will attempt to reauthenticate.
53
53
  #
54
+ # Setting the optional snet variable to true or setting an environment variable of RACKSPACE_SERVICENET to any value will cause
55
+ # storage URLs to be returned with a prefix pointing them to the internal Rackspace service network, instead of a public URL.
56
+ #
57
+ # This is useful if you are using the library on a Rackspace-hosted system, as it provides faster speeds, keeps traffic off of
58
+ # the public network, and the bandwidth is not billed.
59
+ #
54
60
  # This will likely be the base class for most operations.
55
61
  #
56
62
  # cf = CloudFiles::Connection.new(MY_USERNAME, MY_API_KEY)
57
- def initialize(authuser,authkey,retry_auth = true)
63
+ def initialize(authuser,authkey,retry_auth = true,snet=false)
58
64
  @authuser = authuser
59
65
  @authkey = authkey
60
66
  @retry_auth = retry_auth
67
+ @snet = (ENV['RACKSPACE_SERVICENET'] || snet) ? true : false
61
68
  @authok = false
62
69
  @http = {}
63
70
  CloudFiles::Authentication.new(self)
@@ -70,6 +77,11 @@ module CloudFiles
70
77
  def authok?
71
78
  @authok
72
79
  end
80
+
81
+ # Returns true if the library is requesting the use of the Rackspace service network
82
+ def snet?
83
+ @snet
84
+ end
73
85
 
74
86
  # Returns an CloudFiles::Container object that can be manipulated easily. Throws a NoSuchContainerException if
75
87
  # the container doesn't exist.
@@ -167,7 +167,7 @@ module CloudFiles
167
167
  doc = REXML::Document.new(response.body)
168
168
  detailhash = {}
169
169
  doc.elements.each("container/object") { |o|
170
- detailhash[o.elements["name"].text] = { :bytes => o.elements["bytes"].text, :hash => o.elements["hash"].text, :content_type => o.elements["content_type"].text, :last_modified => Time.parse(o.elements["last_modified"].text) }
170
+ detailhash[o.elements["name"].text] = { :bytes => o.elements["bytes"].text, :hash => o.elements["hash"].text, :content_type => o.elements["content_type"].text, :last_modified => DateTime.parse(o.elements["last_modified"].text) }
171
171
  }
172
172
  doc = nil
173
173
  return detailhash
@@ -9,7 +9,18 @@ class CloudfilesAuthenticationTest < Test::Unit::TestCase
9
9
  server = mock(:use_ssl= => true, :verify_mode= => true, :start => true, :finish => true)
10
10
  server.stubs(:get).returns(response)
11
11
  Net::HTTP.stubs(:new).returns(server)
12
- @connection = stub(:authuser => 'dummy_user', :authkey => 'dummy_key', :cdnmgmthost= => true, :cdnmgmtpath= => true, :cdnmgmtport= => true, :cdnmgmtscheme= => true, :storagehost= => true, :storagepath= => true, :storageport= => true, :storagescheme= => true, :authtoken= => true, :authok= => true)
12
+ @connection = stub(:authuser => 'dummy_user', :authkey => 'dummy_key', :cdnmgmthost= => true, :cdnmgmtpath= => true, :cdnmgmtport= => true, :cdnmgmtscheme= => true, :storagehost= => true, :storagepath= => true, :storageport= => true, :storagescheme= => true, :authtoken= => true, :authok= => true, :snet? => false)
13
+ result = CloudFiles::Authentication.new(@connection)
14
+ assert_equal result.class, CloudFiles::Authentication
15
+ end
16
+
17
+ def test_snet_authentication
18
+ response = {'x-cdn-management-url' => 'http://cdn.example.com/path', 'x-storage-url' => 'http://cdn.example.com/storage', 'authtoken' => 'dummy_token'}
19
+ response.stubs(:code).returns('204')
20
+ server = mock(:use_ssl= => true, :verify_mode= => true, :start => true, :finish => true)
21
+ server.stubs(:get).returns(response)
22
+ Net::HTTP.stubs(:new).returns(server)
23
+ @connection = stub(:authuser => 'dummy_user', :authkey => 'dummy_key', :cdnmgmthost= => true, :cdnmgmtpath= => true, :cdnmgmtport= => true, :cdnmgmtscheme= => true, :storagehost= => true, :storagepath= => true, :storageport= => true, :storagescheme= => true, :authtoken= => true, :authok= => true, :snet? => true)
13
24
  result = CloudFiles::Authentication.new(@connection)
14
25
  assert_equal result.class, CloudFiles::Authentication
15
26
  end
@@ -22,7 +22,14 @@ class CloudfilesConnectionTest < Test::Unit::TestCase
22
22
  @connection.expects(:authok?).returns(true)
23
23
  assert_equal @connection.authok?, true
24
24
  end
25
-
25
+
26
+ def test_snet
27
+ # This would normally be set in CloudFiles::Authentication
28
+ assert_equal @connection.snet?, false
29
+ @connection.expects(:snet?).returns(true)
30
+ assert_equal @connection.snet?, true
31
+ end
32
+
26
33
  def test_cfreq_get
27
34
  build_net_http_object
28
35
  assert_nothing_raised do
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.0
4
+ version: 1.4.1
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-10-08 00:00:00 -05:00
13
+ date: 2009-10-20 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies: []
16
16