fixes around collections

This commit is contained in:
Wesley Beary 2009-08-17 18:34:44 -07:00
parent ff2f32d342
commit 1f41499e64
5 changed files with 16 additions and 10 deletions

View File

@ -11,7 +11,7 @@ module Fog
def all
data = connection.get_service.body
owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection))
buckets = []
buckets = Fog::AWS::S3::Buckets.new
data['Buckets'].each do |bucket|
buckets << Fog::AWS::S3::Bucket.new({
:connection => connection,

View File

@ -122,7 +122,7 @@ DATA
canonical_resource << "#{subdomain}/"
end
canonical_resource << "#{params[:path]}"
if ['acl', 'location', 'logging', 'torrent'].include?(params[:query])
if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
canonical_resource << "?#{params[:query]}"
end
string_to_sign << "#{canonical_resource}"

View File

@ -1,5 +1,5 @@
module Fog
class Collection
class Collection < Array
def initialize(attributes = {})
update_attributes(attributes)
@ -10,11 +10,11 @@ module Fog
for attribute in (self.instance_variables - ['@connection'])
data << " #{attribute}=#{send(attribute[1..-1].to_sym).inspect}"
end
data << "["
self.each do |element|
data << "#{element.inspect}, "
data << " ["
for item in self
data << "#{item.inspect},"
end
data = data[0..-3]
data.chomp!
data << "]>"
end
@ -22,6 +22,7 @@ module Fog
for key, value in attributes
send(:"#{key}=", value)
end
self
end
private
@ -34,9 +35,13 @@ module Fog
@connection
end
def new_record?
!defined?(@new_record) || @new_record
end
def remap_attributes(attributes, mapping)
for key, value in mapping
if attributes[key]
if attributes.key?(key)
attributes[value] = attributes.delete(key)
end
end

View File

@ -36,7 +36,7 @@ module Fog
def remap_attributes(attributes, mapping)
for key, value in mapping
if mapping[key]
if attributes.key?(key)
attributes[value] = attributes.delete(key)
end
end

View File

@ -23,8 +23,9 @@ describe 'S3.buckets' do
end
it "should push bucket down into objects" do
p @bucket = @s3.buckets.create(:name => 'fogbucketspaymenttest')
p @bucket = @s3.buckets.create(:name => 'fogbucketsobjectstest')
p @bucket.objects.new(:key => 'object')
p @bucket.objects.all
p @bucket.delete
end