Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Code Climate](https://codeclimate.com/github/jubos/fake-s3/badges/gpa.svg)](https://codeclimate.com/github/jubos/fake-s3)

## Introduction
FakeS3 is a lightweight server that responds to the same calls Amazon S3 responds to.
It is extremely useful for testing of S3 in a sandbox environment without actually
Expand Down
35 changes: 15 additions & 20 deletions lib/fakes3/xml_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'builder'
require 'time'
require 'ostruct'

module FakeS3
class XmlAdapter
Expand Down Expand Up @@ -46,29 +47,19 @@ def self.error(error)
#</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
self.error(
make_error("NoSuchBucket",
"The resource you requested does not exist",
name)
)
end

def self.error_bucket_not_empty(name)
output = ""
xml = Builder::XmlMarkup.new(:target => output)
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
xml.Error { |err|
err.Code("BucketNotEmpty")
err.Message("The bucket you tried to delete is not empty.")
err.Resource(name)
err.RequestId(1)
}
output
self.error(
make_error("BucketNotEmpty",
"The bucket you tried to delete is not empty.",
name)
)
end

def self.error_no_such_key(name)
Expand Down Expand Up @@ -218,5 +209,9 @@ def self.complete_multipart_result(object)
}
output
end

def self.make_error(error, message, name)
OpenStruct.new(error: error, message: message, name: name)
end
end
end