s3 0.2.8 → 0.3.0.beta
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/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/s3.rb +3 -3
- data/lib/s3/bucket.rb +14 -52
- data/lib/s3/buckets_extension.rb +27 -0
- data/lib/s3/connection.rb +3 -1
- data/lib/s3/object.rb +12 -1
- data/lib/s3/objects_extension.rb +37 -0
- data/lib/s3/service.rb +3 -40
- data/s3.gemspec +8 -5
- data/test/bucket_test.rb +2 -20
- data/test/connection_test.rb +5 -4
- data/test/object_test.rb +2 -2
- data/test/service_test.rb +2 -20
- data/test/signature_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +29 -14
- data/lib/s3/roxy/moxie.rb +0 -58
- data/lib/s3/roxy/proxy.rb +0 -72
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
gem.homepage = "http://jah.pl/projects/s3.html"
|
14
14
|
gem.authors = ["Jakub Kuźma", "Mirosław Boruta"]
|
15
15
|
gem.add_dependency "trollop", ">=1.14"
|
16
|
+
gem.add_dependency "proxies"
|
16
17
|
gem.add_development_dependency "test-unit", ">= 2.0"
|
17
18
|
gem.add_development_dependency "mocha"
|
18
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0.beta
|
data/lib/s3.rb
CHANGED
@@ -8,9 +8,9 @@ require "openssl"
|
|
8
8
|
require "rexml/document"
|
9
9
|
require "time"
|
10
10
|
|
11
|
-
require "
|
12
|
-
require "s3/
|
13
|
-
|
11
|
+
require "proxies"
|
12
|
+
require "s3/objects_extension"
|
13
|
+
require "s3/buckets_extension"
|
14
14
|
require "s3/parser"
|
15
15
|
require "s3/bucket"
|
16
16
|
require "s3/connection"
|
data/lib/s3/bucket.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module S3
|
2
2
|
class Bucket
|
3
3
|
include Parser
|
4
|
-
|
4
|
+
include Proxies
|
5
5
|
extend Forwardable
|
6
6
|
|
7
7
|
attr_reader :name, :service
|
@@ -13,7 +13,7 @@ module S3
|
|
13
13
|
# S3::Error exception if the bucket doesn't exist or you don't
|
14
14
|
# have access to it, etc.
|
15
15
|
def retrieve
|
16
|
-
|
16
|
+
bucket_headers
|
17
17
|
self
|
18
18
|
end
|
19
19
|
|
@@ -84,56 +84,8 @@ module S3
|
|
84
84
|
|
85
85
|
# Returns the objects in the bucket and caches the result (see
|
86
86
|
# #reload method).
|
87
|
-
def objects
|
88
|
-
|
89
|
-
@objects = list_bucket
|
90
|
-
else
|
91
|
-
@objects
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
proxy :objects do
|
96
|
-
|
97
|
-
# Builds the object in the bucket with given key
|
98
|
-
def build(key)
|
99
|
-
Object.send(:new, proxy_owner, :key => key)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Finds first object with given name or raises the exception if
|
103
|
-
# not found
|
104
|
-
def find_first(name)
|
105
|
-
object = build(name)
|
106
|
-
object.retrieve
|
107
|
-
end
|
108
|
-
alias :find :find_first
|
109
|
-
|
110
|
-
# Finds the objects in the bucket.
|
111
|
-
#
|
112
|
-
# ==== Options
|
113
|
-
# * <tt>:prefix</tt> - Limits the response to keys which begin
|
114
|
-
# with the indicated prefix
|
115
|
-
# * <tt>:marker</tt> - Indicates where in the bucket to begin
|
116
|
-
# listing
|
117
|
-
# * <tt>:max_keys</tt> - The maximum number of keys you'd like
|
118
|
-
# to see
|
119
|
-
# * <tt>:delimiter</tt> - Causes keys that contain the same
|
120
|
-
# string between the prefix and the first occurrence of the
|
121
|
-
# delimiter to be rolled up into a single result element
|
122
|
-
def find_all(options = {})
|
123
|
-
proxy_owner.send(:list_bucket, options)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Reloads the object list (clears the cache)
|
127
|
-
def reload
|
128
|
-
proxy_owner.objects(true)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Destroys all keys in the bucket
|
132
|
-
def destroy_all
|
133
|
-
proxy_target.each do |object|
|
134
|
-
object.destroy
|
135
|
-
end
|
136
|
-
end
|
87
|
+
def objects
|
88
|
+
MethodProxy.new(self, :list_bucket, :extend => ObjectsExtension)
|
137
89
|
end
|
138
90
|
|
139
91
|
def inspect #:nodoc:
|
@@ -155,6 +107,16 @@ module S3
|
|
155
107
|
objects_attributes.map { |object_attributes| Object.send(:new, self, object_attributes) }
|
156
108
|
end
|
157
109
|
|
110
|
+
def bucket_headers(options = {})
|
111
|
+
response = bucket_request(:head, :params => options)
|
112
|
+
rescue Error::ResponseError => e
|
113
|
+
if e.response.code.to_i == 404
|
114
|
+
raise Error::ResponseError.exception("NoSuchBucket").new("The specified bucket does not exist.", nil)
|
115
|
+
else
|
116
|
+
raise e
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
158
120
|
def create_bucket_configuration(location = nil)
|
159
121
|
location = location.to_s.upcase if location
|
160
122
|
options = { :headers => {} }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module S3
|
2
|
+
module BucketsExtension
|
3
|
+
# Builds new bucket with given name
|
4
|
+
def build(name)
|
5
|
+
Bucket.send(:new, proxy_owner, name)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Finds the bucket with given name
|
9
|
+
def find_first(name)
|
10
|
+
bucket = build(name)
|
11
|
+
bucket.retrieve
|
12
|
+
end
|
13
|
+
alias :find :find_first
|
14
|
+
|
15
|
+
# Find all buckets in the service
|
16
|
+
def find_all
|
17
|
+
proxy_target
|
18
|
+
end
|
19
|
+
|
20
|
+
# Destroy all buckets in the service. Doesn't destroy non-empty
|
21
|
+
# buckets by default, pass true to force destroy (USE WITH
|
22
|
+
# CARE!).
|
23
|
+
def destroy_all(force = false)
|
24
|
+
proxy_target.each { |bucket| bucket.destroy(force) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/s3/connection.rb
CHANGED
@@ -144,6 +144,8 @@ module S3
|
|
144
144
|
case method
|
145
145
|
when :get
|
146
146
|
request_class = Net::HTTP::Get
|
147
|
+
when :head
|
148
|
+
request_class = Net::HTTP::Head
|
147
149
|
when :put
|
148
150
|
request_class = Net::HTTP::Put
|
149
151
|
when :delete
|
@@ -172,7 +174,7 @@ module S3
|
|
172
174
|
|
173
175
|
if request.body
|
174
176
|
request["Content-Type"] ||= "application/octet-stream"
|
175
|
-
request["Content-MD5"] = Base64.encode64(Digest::MD5.digest(request.body)).chomp
|
177
|
+
request["Content-MD5"] = Base64.encode64(Digest::MD5.digest(request.body)).chomp unless request.body.empty?
|
176
178
|
end
|
177
179
|
|
178
180
|
request["Authorization"] = Signature.generate(:host => host,
|
data/lib/s3/object.rb
CHANGED
@@ -46,7 +46,7 @@ module S3
|
|
46
46
|
# NOT download the content of the object (use the #content method
|
47
47
|
# to do it).
|
48
48
|
def retrieve
|
49
|
-
|
49
|
+
object_headers
|
50
50
|
self
|
51
51
|
end
|
52
52
|
|
@@ -163,6 +163,17 @@ module S3
|
|
163
163
|
parse_headers(response)
|
164
164
|
end
|
165
165
|
|
166
|
+
def object_headers(options = {})
|
167
|
+
response = object_request(:head, options)
|
168
|
+
parse_headers(response)
|
169
|
+
rescue Error::ResponseError => e
|
170
|
+
if e.response.code.to_i == 404
|
171
|
+
raise Error::ResponseError.exception("NoSuchKey").new("The specified key does not exist.", nil)
|
172
|
+
else
|
173
|
+
raise e
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
166
177
|
def put_object
|
167
178
|
body = content.is_a?(IO) ? content.read : content
|
168
179
|
response = object_request(:put, :body => body, :headers => dump_headers)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module S3
|
2
|
+
module ObjectsExtension
|
3
|
+
# Builds the object in the bucket with given key
|
4
|
+
def build(key)
|
5
|
+
Object.send(:new, proxy_owner, :key => key)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Finds first object with given name or raises the exception if
|
9
|
+
# not found
|
10
|
+
def find_first(name)
|
11
|
+
object = build(name)
|
12
|
+
object.retrieve
|
13
|
+
end
|
14
|
+
alias :find :find_first
|
15
|
+
|
16
|
+
# Finds the objects in the bucket.
|
17
|
+
#
|
18
|
+
# ==== Options
|
19
|
+
# * <tt>:prefix</tt> - Limits the response to keys which begin
|
20
|
+
# with the indicated prefix
|
21
|
+
# * <tt>:marker</tt> - Indicates where in the bucket to begin
|
22
|
+
# listing
|
23
|
+
# * <tt>:max_keys</tt> - The maximum number of keys you'd like
|
24
|
+
# to see
|
25
|
+
# * <tt>:delimiter</tt> - Causes keys that contain the same
|
26
|
+
# string between the prefix and the first occurrence of the
|
27
|
+
# delimiter to be rolled up into a single result element
|
28
|
+
def find_all(options = {})
|
29
|
+
proxy_owner.send(:list_bucket, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Destroys all keys in the bucket
|
33
|
+
def destroy_all
|
34
|
+
proxy_target.each { |object| object.destroy }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/s3/service.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module S3
|
2
2
|
class Service
|
3
3
|
include Parser
|
4
|
-
|
4
|
+
include Proxies
|
5
5
|
|
6
6
|
attr_reader :access_key_id, :secret_access_key, :use_ssl
|
7
7
|
|
@@ -32,12 +32,8 @@ module S3
|
|
32
32
|
|
33
33
|
# Returns all buckets in the service and caches the result (see
|
34
34
|
# +reload+)
|
35
|
-
def buckets
|
36
|
-
|
37
|
-
@buckets = list_all_my_buckets
|
38
|
-
else
|
39
|
-
@buckets
|
40
|
-
end
|
35
|
+
def buckets
|
36
|
+
MethodProxy.new(self, :list_all_my_buckets, :extend => BucketsExtension)
|
41
37
|
end
|
42
38
|
|
43
39
|
# Returns "http://" or "https://", depends on <tt>:use_ssl</tt>
|
@@ -52,39 +48,6 @@ module S3
|
|
52
48
|
use_ssl ? 443 : 80
|
53
49
|
end
|
54
50
|
|
55
|
-
proxy :buckets do
|
56
|
-
# Builds new bucket with given name
|
57
|
-
def build(name)
|
58
|
-
Bucket.send(:new, proxy_owner, name)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Finds the bucket with given name
|
62
|
-
def find_first(name)
|
63
|
-
bucket = build(name)
|
64
|
-
bucket.retrieve
|
65
|
-
end
|
66
|
-
alias :find :find_first
|
67
|
-
|
68
|
-
# Find all buckets in the service
|
69
|
-
def find_all
|
70
|
-
proxy_target
|
71
|
-
end
|
72
|
-
|
73
|
-
# Reloads the bucket list (clears the cache)
|
74
|
-
def reload
|
75
|
-
proxy_owner.buckets(true)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Destroy all buckets in the service. Doesn't destroy non-empty
|
79
|
-
# buckets by default, pass true to force destroy (USE WITH
|
80
|
-
# CARE!).
|
81
|
-
def destroy_all(force = false)
|
82
|
-
proxy_target.each do |bucket|
|
83
|
-
bucket.destroy(force)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
51
|
def inspect #:nodoc:
|
89
52
|
"#<#{self.class}:#@access_key_id>"
|
90
53
|
end
|
data/s3.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{s3}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0.beta"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jakub Kuźma", "Mirosław Boruta"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-01}
|
13
13
|
s.default_executable = %q{s3}
|
14
14
|
s.description = %q{S3 library provides access to Amazon's Simple Storage Service. It supports both: European and US buckets through REST API.}
|
15
15
|
s.email = %q{qoobaa@gmail.com}
|
@@ -30,12 +30,12 @@ Gem::Specification.new do |s|
|
|
30
30
|
"extra/s3_paperclip.rb",
|
31
31
|
"lib/s3.rb",
|
32
32
|
"lib/s3/bucket.rb",
|
33
|
+
"lib/s3/buckets_extension.rb",
|
33
34
|
"lib/s3/connection.rb",
|
34
35
|
"lib/s3/exceptions.rb",
|
35
36
|
"lib/s3/object.rb",
|
37
|
+
"lib/s3/objects_extension.rb",
|
36
38
|
"lib/s3/parser.rb",
|
37
|
-
"lib/s3/roxy/moxie.rb",
|
38
|
-
"lib/s3/roxy/proxy.rb",
|
39
39
|
"lib/s3/service.rb",
|
40
40
|
"lib/s3/signature.rb",
|
41
41
|
"s3.gemspec",
|
@@ -66,15 +66,18 @@ Gem::Specification.new do |s|
|
|
66
66
|
|
67
67
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
68
68
|
s.add_runtime_dependency(%q<trollop>, [">= 1.14"])
|
69
|
+
s.add_runtime_dependency(%q<proxies>, [">= 0"])
|
69
70
|
s.add_development_dependency(%q<test-unit>, [">= 2.0"])
|
70
71
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
71
72
|
else
|
72
73
|
s.add_dependency(%q<trollop>, [">= 1.14"])
|
74
|
+
s.add_dependency(%q<proxies>, [">= 0"])
|
73
75
|
s.add_dependency(%q<test-unit>, [">= 2.0"])
|
74
76
|
s.add_dependency(%q<mocha>, [">= 0"])
|
75
77
|
end
|
76
78
|
else
|
77
79
|
s.add_dependency(%q<trollop>, [">= 1.14"])
|
80
|
+
s.add_dependency(%q<proxies>, [">= 0"])
|
78
81
|
s.add_dependency(%q<test-unit>, [">= 2.0"])
|
79
82
|
s.add_dependency(%q<mocha>, [">= 0"])
|
80
83
|
end
|
data/test/bucket_test.rb
CHANGED
@@ -134,14 +134,14 @@ class BucketTest < Test::Unit::TestCase
|
|
134
134
|
actual = @bucket.objects
|
135
135
|
assert_equal expected, actual
|
136
136
|
|
137
|
-
@bucket.stubs(:list_bucket)
|
137
|
+
@bucket.stubs(:list_bucket).returns(@objects_list_empty)
|
138
138
|
actual = @bucket.objects
|
139
139
|
assert_equal expected, actual
|
140
140
|
|
141
141
|
@bucket.stubs(:list_bucket).returns(@objects_list)
|
142
142
|
|
143
143
|
expected = @objects_list
|
144
|
-
actual = @bucket.objects
|
144
|
+
actual = @bucket.objects
|
145
145
|
assert_equal expected, actual
|
146
146
|
end
|
147
147
|
|
@@ -205,24 +205,6 @@ class BucketTest < Test::Unit::TestCase
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
-
test "objects reload" do
|
209
|
-
@bucket.stubs(:list_bucket).returns(@objects_list_empty)
|
210
|
-
expected = @objects_list_empty
|
211
|
-
actual = @bucket.objects
|
212
|
-
assert_equal expected, actual
|
213
|
-
|
214
|
-
@bucket.stubs(:list_bucket).returns(@objects_list)
|
215
|
-
expected = @objects_list_empty
|
216
|
-
actual = @bucket.objects
|
217
|
-
assert_equal expected, actual
|
218
|
-
|
219
|
-
assert @bucket.objects.reload
|
220
|
-
|
221
|
-
expected = @objects_list
|
222
|
-
actual = @bucket.objects(true)
|
223
|
-
assert_equal expected, actual
|
224
|
-
end
|
225
|
-
|
226
208
|
test "objects destroy all" do
|
227
209
|
@bucket.stubs(:list_bucket).returns(@objects_list)
|
228
210
|
@bucket.objects.each do |obj|
|
data/test/connection_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class ConnectionTest < Test::Unit::TestCase
|
4
4
|
def setup
|
@@ -9,6 +9,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
9
9
|
@http_request = Net::HTTP.new("")
|
10
10
|
@response_ok = Net::HTTPOK.new("1.1", "200", "OK")
|
11
11
|
@response_not_found = Net::HTTPNotFound.new("1.1", "404", "Not Found")
|
12
|
+
@response_error = Net::HTTPInternalServerError.new("1.1", "500", "Internal Server Error")
|
12
13
|
@connection.stubs(:http).returns(@http_request)
|
13
14
|
|
14
15
|
@http_request.stubs(:start).returns(@response_ok)
|
@@ -47,8 +48,8 @@ class ConnectionTest < Test::Unit::TestCase
|
|
47
48
|
end
|
48
49
|
|
49
50
|
test "handle response throws standard exception when error" do
|
50
|
-
@http_request.stubs(:start).returns(@
|
51
|
-
@
|
51
|
+
@http_request.stubs(:start).returns(@response_error)
|
52
|
+
@response_error.stubs(:body)
|
52
53
|
assert_raise S3::Error::ResponseError do
|
53
54
|
response = @connection.request(
|
54
55
|
:get,
|
@@ -57,7 +58,7 @@ class ConnectionTest < Test::Unit::TestCase
|
|
57
58
|
)
|
58
59
|
end
|
59
60
|
|
60
|
-
@
|
61
|
+
@response_error.stubs(:body).returns("")
|
61
62
|
assert_raise S3::Error::ResponseError do
|
62
63
|
response = @connection.request(
|
63
64
|
:get,
|
data/test/object_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
2
|
+
require "test_helper"
|
3
3
|
|
4
4
|
class ObjectTest < Test::Unit::TestCase
|
5
5
|
def setup
|
@@ -114,7 +114,7 @@ class ObjectTest < Test::Unit::TestCase
|
|
114
114
|
end
|
115
115
|
|
116
116
|
test "retrieve" do
|
117
|
-
@object_lena.expects(:object_request).with(:
|
117
|
+
@object_lena.expects(:object_request).with(:head, {}).returns(@response_binary)
|
118
118
|
assert @object_lena.retrieve
|
119
119
|
end
|
120
120
|
|
data/test/service_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class ServiceTest < Test::Unit::TestCase
|
4
4
|
def setup
|
@@ -67,28 +67,10 @@ class ServiceTest < Test::Unit::TestCase
|
|
67
67
|
test "buckets and parse buckets" do
|
68
68
|
expected = @buckets_list
|
69
69
|
# ugly hack
|
70
|
-
actual = @service_buckets_list.buckets
|
70
|
+
actual = @service_buckets_list.buckets.map { |obj| obj }
|
71
71
|
assert_equal expected, actual
|
72
72
|
end
|
73
73
|
|
74
|
-
test "buckets reload" do
|
75
|
-
@service = @service_empty_buckets_list
|
76
|
-
|
77
|
-
expected = @buckets_empty_list
|
78
|
-
assert @service.buckets, "retrive buckets"
|
79
|
-
actual = @service.buckets
|
80
|
-
assert_equal expected.length, actual.length, "deliver from cache"
|
81
|
-
|
82
|
-
@service.stubs(:service_request).returns(@response_buckets_list)
|
83
|
-
expected = @buckets_empty_list
|
84
|
-
actual = @service.buckets
|
85
|
-
assert_equal expected.length, actual.length, "deliver from cache"
|
86
|
-
|
87
|
-
expected = @buckets_list
|
88
|
-
actual = @service.buckets(true)
|
89
|
-
assert_equal expected.length, actual.length
|
90
|
-
end
|
91
|
-
|
92
74
|
test "buckets build" do
|
93
75
|
@service_empty_buckets_list.stubs(:service_request)
|
94
76
|
|
data/test/signature_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- beta
|
10
|
+
version: 0.3.0.beta
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- "Jakub Ku\xC5\xBAma"
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-04-01 00:00:00 +02:00
|
19
20
|
default_executable: s3
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -32,9 +33,21 @@ dependencies:
|
|
32
33
|
type: :runtime
|
33
34
|
version_requirements: *id001
|
34
35
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
36
|
+
name: proxies
|
36
37
|
prerelease: false
|
37
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: test-unit
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
38
51
|
requirements:
|
39
52
|
- - ">="
|
40
53
|
- !ruby/object:Gem::Version
|
@@ -43,11 +56,11 @@ dependencies:
|
|
43
56
|
- 0
|
44
57
|
version: "2.0"
|
45
58
|
type: :development
|
46
|
-
version_requirements: *
|
59
|
+
version_requirements: *id003
|
47
60
|
- !ruby/object:Gem::Dependency
|
48
61
|
name: mocha
|
49
62
|
prerelease: false
|
50
|
-
requirement: &
|
63
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
64
|
requirements:
|
52
65
|
- - ">="
|
53
66
|
- !ruby/object:Gem::Version
|
@@ -55,7 +68,7 @@ dependencies:
|
|
55
68
|
- 0
|
56
69
|
version: "0"
|
57
70
|
type: :development
|
58
|
-
version_requirements: *
|
71
|
+
version_requirements: *id004
|
59
72
|
description: "S3 library provides access to Amazon's Simple Storage Service. It supports both: European and US buckets through REST API."
|
60
73
|
email: qoobaa@gmail.com
|
61
74
|
executables:
|
@@ -77,12 +90,12 @@ files:
|
|
77
90
|
- extra/s3_paperclip.rb
|
78
91
|
- lib/s3.rb
|
79
92
|
- lib/s3/bucket.rb
|
93
|
+
- lib/s3/buckets_extension.rb
|
80
94
|
- lib/s3/connection.rb
|
81
95
|
- lib/s3/exceptions.rb
|
82
96
|
- lib/s3/object.rb
|
97
|
+
- lib/s3/objects_extension.rb
|
83
98
|
- lib/s3/parser.rb
|
84
|
-
- lib/s3/roxy/moxie.rb
|
85
|
-
- lib/s3/roxy/proxy.rb
|
86
99
|
- lib/s3/service.rb
|
87
100
|
- lib/s3/signature.rb
|
88
101
|
- s3.gemspec
|
@@ -110,11 +123,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
123
|
version: "0"
|
111
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
125
|
requirements:
|
113
|
-
- - "
|
126
|
+
- - ">"
|
114
127
|
- !ruby/object:Gem::Version
|
115
128
|
segments:
|
116
|
-
-
|
117
|
-
|
129
|
+
- 1
|
130
|
+
- 3
|
131
|
+
- 1
|
132
|
+
version: 1.3.1
|
118
133
|
requirements: []
|
119
134
|
|
120
135
|
rubyforge_project:
|
data/lib/s3/roxy/moxie.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Ryan Daigle
|
2
|
-
|
3
|
-
# Permission is hereby granted, free of charge, to any person
|
4
|
-
# obtaining a copy of this software and associated documentation files
|
5
|
-
# (the "Software"), to deal in the Software without restriction,
|
6
|
-
# including without limitation the rights to use, copy, modify, merge,
|
7
|
-
# publish, distribute, sublicense, and/or sell copies of the Software,
|
8
|
-
# and to permit persons to whom the Software is furnished to do so,
|
9
|
-
# subject to the following conditions:
|
10
|
-
|
11
|
-
# The above copyright notice and this permission notice shall be
|
12
|
-
# included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
18
|
-
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19
|
-
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
22
|
-
|
23
|
-
module S3
|
24
|
-
module Roxy # :nodoc:all
|
25
|
-
module Moxie
|
26
|
-
# Set up this class to proxy on the given name
|
27
|
-
def proxy(name, options = {}, &block)
|
28
|
-
|
29
|
-
# Make sure args are OK
|
30
|
-
original_method = method_defined?(name) ? instance_method(name) : nil
|
31
|
-
raise "Cannot proxy an existing method, \"#{name}\", and also have a :to option. Please use one or the other." if
|
32
|
-
original_method and options[:to]
|
33
|
-
|
34
|
-
# If we're proxying an existing method, we need to store
|
35
|
-
# the original method and move it out of the way so
|
36
|
-
# we can take over
|
37
|
-
if original_method
|
38
|
-
new_method = "proxied_#{name}"
|
39
|
-
alias_method new_method, "#{name}"
|
40
|
-
options[:to] = original_method
|
41
|
-
end
|
42
|
-
|
43
|
-
# Thanks to Jerry for this simplification of my original class_eval approach
|
44
|
-
# http://ryandaigle.com/articles/2008/11/10/implement-ruby-proxy-objects-with-roxy/comments/8059#comment-8059
|
45
|
-
if !original_method or original_method.arity == 0
|
46
|
-
define_method name do
|
47
|
-
@proxy_for ||= {}
|
48
|
-
@proxy_for[name] ||= Proxy.new(self, options, nil, &block)
|
49
|
-
end
|
50
|
-
else
|
51
|
-
define_method name do |*args|
|
52
|
-
Proxy.new(self, options, args, &block)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/s3/roxy/proxy.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Ryan Daigle
|
2
|
-
|
3
|
-
# Permission is hereby granted, free of charge, to any person
|
4
|
-
# obtaining a copy of this software and associated documentation files
|
5
|
-
# (the "Software"), to deal in the Software without restriction,
|
6
|
-
# including without limitation the rights to use, copy, modify, merge,
|
7
|
-
# publish, distribute, sublicense, and/or sell copies of the Software,
|
8
|
-
# and to permit persons to whom the Software is furnished to do so,
|
9
|
-
# subject to the following conditions:
|
10
|
-
|
11
|
-
# The above copyright notice and this permission notice shall be
|
12
|
-
# included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
18
|
-
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19
|
-
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
22
|
-
|
23
|
-
module S3
|
24
|
-
module Roxy # :nodoc:all
|
25
|
-
# The very simple proxy class that provides a basic pass-through
|
26
|
-
# mechanism between the proxy owner and the proxy target.
|
27
|
-
class Proxy
|
28
|
-
|
29
|
-
alias :proxy_instance_eval :instance_eval
|
30
|
-
alias :proxy_extend :extend
|
31
|
-
|
32
|
-
# Make sure the proxy is as dumb as it can be.
|
33
|
-
# Blatanly taken from Jim Wierich's BlankSlate post:
|
34
|
-
# http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc
|
35
|
-
instance_methods.each { |m| undef_method m unless m =~ /(^__|^proxy_|^object_id)/ }
|
36
|
-
|
37
|
-
def initialize(owner, options, args, &block)
|
38
|
-
@owner = owner
|
39
|
-
@target = options[:to]
|
40
|
-
@args = args
|
41
|
-
|
42
|
-
# Adorn with user-provided proxy methods
|
43
|
-
[options[:extend]].flatten.each { |ext| proxy_extend(ext) } if options[:extend]
|
44
|
-
proxy_instance_eval &block if block_given?
|
45
|
-
end
|
46
|
-
|
47
|
-
def proxy_owner
|
48
|
-
@owner
|
49
|
-
end
|
50
|
-
|
51
|
-
def proxy_target
|
52
|
-
if @target.is_a?(Proc)
|
53
|
-
@target.call(@owner)
|
54
|
-
elsif @target.is_a?(UnboundMethod)
|
55
|
-
bound_method = @target.bind(proxy_owner)
|
56
|
-
bound_method.arity == 0 ? bound_method.call : bound_method.call(*@args)
|
57
|
-
else
|
58
|
-
@target
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# def inspect
|
63
|
-
# "#<S3::Roxy::Proxy:0x#{object_id.to_s(16)}>"
|
64
|
-
# end
|
65
|
-
|
66
|
-
# Delegate all method calls we don't know about to target object
|
67
|
-
def method_missing(sym, *args, &block)
|
68
|
-
proxy_target.__send__(sym, *args, &block)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|