Class: Dandelion::Backend::S3
- Inherits:
-
Base
- Object
- Base
- Dandelion::Backend::S3
show all
- Defined in:
- lib/dandelion/backend/s3.rb
Instance Method Summary
collapse
Methods inherited from Base
create, gem_list, gems, scheme
Constructor Details
#initialize(config) ⇒ S3
Returns a new instance of S3.
9
10
11
12
13
14
15
|
# File 'lib/dandelion/backend/s3.rb', line 9
def initialize(config)
require 'aws/s3'
@access_key_id = config['access_key_id']
@secret_access_key = config['secret_access_key']
@bucket_name = config['bucket_name']
@path = config['path']
end
|
Instance Method Details
#delete(file) ⇒ Object
28
29
30
31
|
# File 'lib/dandelion/backend/s3.rb', line 28
def delete(file)
s3connect!
AWS::S3::S3Object.delete(path(file), @bucket_name)
end
|
#read(file) ⇒ Object
17
18
19
20
21
|
# File 'lib/dandelion/backend/s3.rb', line 17
def read(file)
s3connect!
raise MissingFileError unless AWS::S3::S3Object.exists?(path(file), @bucket_name)
AWS::S3::S3Object.value(path(file), @bucket_name)
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/dandelion/backend/s3.rb', line 33
def to_s
"s3://#{@access_key_id}@#{@bucket_name}/#{@path}"
end
|
#write(file, data) ⇒ Object
23
24
25
26
|
# File 'lib/dandelion/backend/s3.rb', line 23
def write(file, data)
s3connect!
AWS::S3::S3Object.store(path(file), data, @bucket_name)
end
|