Sha256: 4dd1471ab93210e9c53a51d2ffe1a4a86d9b835094674fb89018adbdb297db76
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 'builder' require 'time' module Shuck class XmlAdapter def self.buckets(bucket_objects) output = "" xml = Builder::XmlMarkup.new(:target => output) xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml.ListAllMyBucketsResult(:xmlns => "http://s3.amazonaws.com/doc/2006-03-01/") { |lam| lam.Owner { |owner| owner.ID("123") owner.DisplayName("Shuck") } lam.Buckets { |buckets| bucket_objects.each do |bucket| buckets.Bucket do |b| b.Name(bucket.name) b.CreationDate(bucket.creation_date.strftime("%Y-%m-%dT%H:%M:%S.000Z")) end end } } output end # <?xml version="1.0" encoding="UTF-8"?> #<Error> # <Code>NoSuchKey</Code> # <Message>The resource you requested does not exist</Message> # <Resource>/mybucket/myfoto.jpg</Resource> # <RequestId>4442587FB7D0A2F9</RequestId> #</Error> def self.error_no_such_bucket(name) output = "" xml = Builder::XmlMarkup.new(:target => output) xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml.Error { |err| err.Code("NoSuchBucket") err.Message("The resource you requested does not exist") err.Resource(name) err.RequestId(1) } output end def self.bucket(bucket) output = "" xml = Builder::XmlMarkup.new(:target => output) xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml.ListBucketResult(:xmlns => "http://s3.amazonaws.com/doc/2006-03-01/") { |lbr| lbr.Name(bucket.name) lbr.Prefix lbr.Marker lbr.MaxKeys("1000") lbr.IsTruncated("false") } output end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shuck-0.0.8 | lib/shuck/xml_adapter.rb |