require 'rubygems' require_gem 'builder' require File.join(File.dirname(__FILE__), 'libxml_loader') module S33r # For manipulating logging directives on resources # (see http://docs.amazonwebservices.com/AmazonS3/2006-03-01/LoggingHowTo.html). # # Creating a LoggingResource instance using new and no arguments will generate a "blank" instance; # this can be put to the ?logging URL for a resource to remove logging from it. class LoggingResource attr_reader :log_target, :log_prefix def initialize(log_target=nil, log_prefix=nil) @log_target = log_target @log_prefix = log_prefix end # Generate a BucketLoggingStatus XML document for putting to the ?logging # URL for a resource. # #-- TODO: test generates correct XML def to_xml xml_str = "" xml = Builder::XmlMarkup.new(:target => xml_str, :indent => 0) xml.instruct! # BucketLoggingStatus XML. xml.BucketLoggingStatus({"xmlns" => RESPONSE_NAMESPACE_URI}) { unless @log_target.nil? and @log_prefix.nil? xml.LoggingEnabled { xml.TargetBucket @log_target xml.TargetPrefix @log_prefix } end } xml_str end end end