Class: AwsS3FauxBucket
- Inherits:
-
Object
- Object
- AwsS3FauxBucket
- Defined in:
- lib/spec_support/aws_s3_faux_bucket.rb
Overview
This class is very rudimentary implementation of a bucket. It conforms to the necessary interface for downloading and uploading and filter on prefix.
It is provided as a lib/spec/support so that downstream implementations can leverage a fake S3 bucket.
Defined Under Namespace
Classes: Storage
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#initialize ⇒ AwsS3FauxBucket
constructor
A new instance of AwsS3FauxBucket.
- #object(path) ⇒ Object
- #objects(prefix:) ⇒ Object
Constructor Details
#initialize ⇒ AwsS3FauxBucket
Returns a new instance of AwsS3FauxBucket.
12 13 14 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 12 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
15 16 17 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 15 def storage @storage end |
Instance Method Details
#object(path) ⇒ Object
16 17 18 19 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 16 def object(path) # Yup, we've got nested buckets @storage[path] ||= Storage.new(key: path) end |
#objects(prefix:) ⇒ Object
21 22 23 24 25 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 21 def objects(prefix:) @storage.each_with_object([]) do |(path, obj), accumulator| accumulator << obj if path.start_with?(prefix) end end |