rackspace-cloudfiles 1.3.0.3 → 1.3.0.5
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.
- data/cloudfiles.gemspec +2 -5
- data/lib/cloudfiles.rb +9 -4
- data/lib/cloudfiles/connection.rb +3 -7
- data/lib/cloudfiles/container.rb +14 -15
- data/lib/cloudfiles/storage_object.rb +1 -2
- data/test/cloudfiles_container_test.rb +6 -6
- metadata +4 -13
data/cloudfiles.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cloudfiles}
|
5
|
-
s.version = "1.3.0.
|
5
|
+
s.version = "1.3.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["H. Wade Minter, Rackspace Hosting"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-28}
|
10
10
|
s.description = %q{A Ruby version of the Mosso Cloud Files API.}
|
11
11
|
s.email = %q{wade.minter@rackspace.com}
|
12
12
|
s.extra_rdoc_files = ["lib/cloudfiles/authentication.rb", "lib/cloudfiles/connection.rb", "lib/cloudfiles/container.rb", "lib/cloudfiles/storage_object.rb", "lib/cloudfiles.rb", "README.rdoc", "TODO"]
|
@@ -26,13 +26,10 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<mime-types>, [">= 1.0"])
|
29
|
-
s.add_development_dependency(%q<echoe>, [">= 0"])
|
30
29
|
else
|
31
30
|
s.add_dependency(%q<mime-types>, [">= 1.0"])
|
32
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
33
31
|
end
|
34
32
|
else
|
35
33
|
s.add_dependency(%q<mime-types>, [">= 1.0"])
|
36
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
37
34
|
end
|
38
35
|
end
|
data/lib/cloudfiles.rb
CHANGED
@@ -18,18 +18,20 @@
|
|
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.3.0.
|
21
|
+
VERSION = '1.3.0.5'
|
22
22
|
require 'net/http'
|
23
23
|
require 'net/https'
|
24
24
|
require 'rexml/document'
|
25
25
|
require 'uri'
|
26
26
|
require 'digest/md5'
|
27
|
-
require 'jcode'
|
28
27
|
require 'time'
|
29
28
|
require 'rubygems'
|
30
29
|
require 'mime/types'
|
31
30
|
|
32
|
-
|
31
|
+
unless "".respond_to? :each_char
|
32
|
+
require "jcode"
|
33
|
+
$KCODE = 'u'
|
34
|
+
end
|
33
35
|
|
34
36
|
$:.unshift(File.dirname(__FILE__))
|
35
37
|
require 'cloudfiles/authentication'
|
@@ -37,6 +39,9 @@ module CloudFiles
|
|
37
39
|
require 'cloudfiles/container'
|
38
40
|
require 'cloudfiles/storage_object'
|
39
41
|
|
42
|
+
def self.lines(str)
|
43
|
+
(str.respond_to?(:lines) ? str.lines : str).to_a.map { |x| x.chomp }
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
|
@@ -66,4 +71,4 @@ end
|
|
66
71
|
class ObjectExistsException < StandardError # :nodoc:
|
67
72
|
end
|
68
73
|
class ExpiredAuthTokenException < StandardError # :nodoc:
|
69
|
-
end
|
74
|
+
end
|
@@ -18,9 +18,6 @@ module CloudFiles
|
|
18
18
|
# Path for managing containers on the CDN management server
|
19
19
|
attr_accessor :cdnmgmtpath
|
20
20
|
|
21
|
-
# Array of requests that have been made so far
|
22
|
-
attr_reader :reqlog
|
23
|
-
|
24
21
|
# Hostname of the storage server
|
25
22
|
attr_accessor :storagehost
|
26
23
|
|
@@ -51,7 +48,6 @@ module CloudFiles
|
|
51
48
|
@retry_auth = retry_auth
|
52
49
|
@authok = false
|
53
50
|
@http = {}
|
54
|
-
@reqlog = []
|
55
51
|
CloudFiles::Authentication.new(self)
|
56
52
|
end
|
57
53
|
|
@@ -109,7 +105,7 @@ module CloudFiles
|
|
109
105
|
response = cfreq("GET",@storagehost,"#{@storagepath}?#{paramstr}")
|
110
106
|
return [] if (response.code == "204")
|
111
107
|
raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code == "200")
|
112
|
-
response.body
|
108
|
+
CloudFiles.lines(response.body)
|
113
109
|
end
|
114
110
|
alias :list_containers :containers
|
115
111
|
|
@@ -205,7 +201,7 @@ module CloudFiles
|
|
205
201
|
response = cfreq("GET",@cdnmgmthost,"#{@cdnmgmtpath}?#{paramstr}")
|
206
202
|
return [] if (response.code == "204")
|
207
203
|
raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code == "200")
|
208
|
-
response.body
|
204
|
+
CloudFiles.lines(response.body)
|
209
205
|
end
|
210
206
|
|
211
207
|
# This method actually makes the HTTP calls out to the server
|
@@ -271,4 +267,4 @@ module CloudFiles
|
|
271
267
|
|
272
268
|
end
|
273
269
|
|
274
|
-
end
|
270
|
+
end
|
data/lib/cloudfiles/container.rb
CHANGED
@@ -59,15 +59,11 @@ module CloudFiles
|
|
59
59
|
|
60
60
|
# Get the CDN-related details
|
61
61
|
response = self.connection.cfreq("HEAD",@cdnmgmthost,@cdnmgmtpath)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@cdn_enabled = false
|
68
|
-
@cdn_ttl = false
|
69
|
-
@cdn_url = false
|
70
|
-
end
|
62
|
+
raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "204")
|
63
|
+
@cdn_enabled = ((response["x-cdn-enabled"] || "").downcase == "true") ? true : false
|
64
|
+
@cdn_ttl = @cdn_enable ? response["x-ttl"] : false
|
65
|
+
@cdn_url = @cdn_enable ? response["x-cdn-uri"] : false
|
66
|
+
|
71
67
|
true
|
72
68
|
end
|
73
69
|
alias :refresh :populate
|
@@ -113,7 +109,7 @@ module CloudFiles
|
|
113
109
|
response = self.connection.cfreq("GET",@storagehost,"#{@storagepath}?#{paramstr}")
|
114
110
|
return [] if (response.code == "204")
|
115
111
|
raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code == "200")
|
116
|
-
return response.body
|
112
|
+
return CloudFiles.lines(response.body)
|
117
113
|
end
|
118
114
|
alias :list_objects :objects
|
119
115
|
|
@@ -218,13 +214,16 @@ module CloudFiles
|
|
218
214
|
# Makes a container publicly available via the Cloud Files CDN and returns true upon success. Throws NoSuchContainerException
|
219
215
|
# if the container doesn't exist or if the request fails.
|
220
216
|
#
|
221
|
-
# Takes an optional argument, which is the CDN cache TTL in seconds (default 86400 seconds or 1 day)
|
217
|
+
# Takes an optional argument, which is the CDN cache TTL in seconds (default 86400 seconds or 1 day, maximum 259200 or 3 days)
|
222
218
|
#
|
223
219
|
# container.make_public(432000)
|
224
220
|
# => true
|
225
221
|
def make_public(ttl = 86400)
|
226
|
-
|
227
|
-
response
|
222
|
+
response = self.connection.cfreq("PUT",@cdnmgmthost,@cdnmgmtpath)
|
223
|
+
raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
|
224
|
+
|
225
|
+
headers = { "X-TTL" => ttl.to_s }
|
226
|
+
response = self.connection.cfreq("POST",@cdnmgmthost,@cdnmgmtpath,headers)
|
228
227
|
raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
|
229
228
|
true
|
230
229
|
end
|
@@ -238,7 +237,7 @@ module CloudFiles
|
|
238
237
|
# => true
|
239
238
|
def make_private
|
240
239
|
headers = { "X-CDN-Enabled" => "False" }
|
241
|
-
response = self.connection.cfreq("
|
240
|
+
response = self.connection.cfreq("POST",@cdnmgmthost,@cdnmgmtpath,headers)
|
242
241
|
raise NoSuchContainerException, "Container #{@name} does not exist" unless (response.code == "201" || response.code == "202")
|
243
242
|
true
|
244
243
|
end
|
@@ -249,4 +248,4 @@ module CloudFiles
|
|
249
248
|
|
250
249
|
end
|
251
250
|
|
252
|
-
end
|
251
|
+
end
|
@@ -71,7 +71,6 @@ module CloudFiles
|
|
71
71
|
headers['Range'] = range
|
72
72
|
end
|
73
73
|
response = self.container.connection.cfreq("GET",@storagehost,@storagepath,headers)
|
74
|
-
print "DEBUG: Code is #{response.code}\n"
|
75
74
|
raise NoSuchObjectException, "Object #{@name} does not exist" unless (response.code =~ /^20/)
|
76
75
|
response.body.chomp
|
77
76
|
end
|
@@ -252,4 +251,4 @@ module CloudFiles
|
|
252
251
|
|
253
252
|
end
|
254
253
|
|
255
|
-
end
|
254
|
+
end
|
@@ -10,7 +10,7 @@ class CloudfilesContainerTest < Test::Unit::TestCase
|
|
10
10
|
@container = CloudFiles::Container.new(connection, 'test_container')
|
11
11
|
assert_equal @container.name, 'test_container'
|
12
12
|
assert_equal @container.class, CloudFiles::Container
|
13
|
-
assert_equal @container.public?,
|
13
|
+
assert_equal @container.public?, false
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_object_creation_no_such_container
|
@@ -23,15 +23,15 @@ class CloudfilesContainerTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def test_object_creation_with_cdn
|
27
27
|
connection = mock(:storagehost => 'test.storage.example', :storagepath => '/dummy/path', :cdnmgmthost => 'cdm.test.example', :cdnmgmtpath => '/dummy/path')
|
28
|
-
response = {'x-container-bytes-used' => '42', 'x-container-object-count' => '5'}
|
29
|
-
response.stubs(:code).returns('204')
|
28
|
+
response = {'x-container-bytes-used' => '42', 'x-container-object-count' => '5', 'x-cdn-enabled' => 'True'}
|
29
|
+
response.stubs(:code).returns('204')
|
30
30
|
connection.stubs(:cfreq => response)
|
31
31
|
@container = CloudFiles::Container.new(connection, 'test_container')
|
32
32
|
assert_equal @container.name, 'test_container'
|
33
|
-
assert_equal @container.cdn_enabled,
|
34
|
-
assert_equal @container.public?,
|
33
|
+
assert_equal @container.cdn_enabled, true
|
34
|
+
assert_equal @container.public?, true
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackspace-cloudfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- H. Wade Minter, Rackspace Hosting
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,16 +22,6 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "1.0"
|
24
24
|
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: echoe
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
25
|
description: A Ruby version of the Mosso Cloud Files API.
|
36
26
|
email: wade.minter@rackspace.com
|
37
27
|
executables: []
|
@@ -65,6 +55,7 @@ files:
|
|
65
55
|
- TODO
|
66
56
|
has_rdoc: true
|
67
57
|
homepage: http://www.mosso.com/cloudfiles.jsp
|
58
|
+
licenses:
|
68
59
|
post_install_message:
|
69
60
|
rdoc_options:
|
70
61
|
- --line-numbers
|
@@ -90,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
81
|
requirements: []
|
91
82
|
|
92
83
|
rubyforge_project: cloudfiles
|
93
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.3.5
|
94
85
|
signing_key:
|
95
86
|
specification_version: 2
|
96
87
|
summary: A Ruby API into Mosso Cloud Files
|