Class: AwsS3FauxBucket

Inherits:
Object
  • Object
show all
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.

See Also:

  • [DerivativeRodeo[DerivativeRodeo::StorageLocations[DerivativeRodeo::StorageLocations::S3Location]

Defined Under Namespace

Classes: Storage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAwsS3FauxBucket

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

#storageObject (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