Class: AwsS3FauxBucket::Storage
- Inherits:
-
Object
- Object
- AwsS3FauxBucket::Storage
- Defined in:
- lib/spec_support/aws_s3_faux_bucket.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #download_file(path) ⇒ Object
-
#initialize(key:) ⇒ Storage
constructor
Because we’re now coping with the glob tail finder, we need to account for the bucket entry’s key.
- #upload_file(path) ⇒ Object
Constructor Details
#initialize(key:) ⇒ Storage
Because we’re now coping with the glob tail finder, we need to account for the bucket entry’s key.
30 31 32 33 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 30 def initialize(key:) @key = key @storage = {} end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
34 35 36 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 34 def key @key end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
34 35 36 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 34 def storage @storage end |
Instance Method Details
#download_file(path) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 40 def download_file(path) return false unless @storage.key?(:upload) content = @storage.fetch(:upload) File.open(path, 'wb') do |f| f.puts(content) end end |
#upload_file(path) ⇒ Object
36 37 38 |
# File 'lib/spec_support/aws_s3_faux_bucket.rb', line 36 def upload_file(path) @storage[:upload] = File.read(path) end |