Sha256: 81281dd22bad6b96607a922b0361462a627cc8eedc09c3db4282c39b4cfcd4c5
Contents?: true
Size: 1.72 KB
Versions: 6
Compression:
Stored size: 1.72 KB
Contents
require 'builder' require 'time' module Shuck class XmlAdapter def self.buckets(buckets) 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| @buckets.each do |bucket| buckets.Bucket do |b| b.Name(bucket.name) b.CreationDate(bucket.creation_date.xmlschema) 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
6 entries across 6 versions & 1 rubygems