module Alephant::Harness::Service::S3

Public Class Methods

add_object(id, object_id, data) click to toggle source
# File lib/alephant/harness/service/s3.rb, line 16
def self.add_object(id, object_id, data)
  client.put_object(
    body: data,
    bucket: id,
    key: object_id
  )
end
bucket_exists?(bucket_id) { || ... } click to toggle source
# File lib/alephant/harness/service/s3.rb, line 31
def self.bucket_exists?(bucket_id)
  begin
    client.head_bucket(
      bucket: bucket_id
    )
    yield if block_given?
    true
  rescue => e
    false
  end
end
create(id) click to toggle source
# File lib/alephant/harness/service/s3.rb, line 7
def self.create(id)
  client.create_bucket(bucket: id)
end
delete(id) click to toggle source
# File lib/alephant/harness/service/s3.rb, line 11
def self.delete(id)
  s3 = Aws::S3::Resource.new(client: client)
  s3.bucket(id).delete
end
get_object(id, object_id) click to toggle source
# File lib/alephant/harness/service/s3.rb, line 24
def self.get_object(id, object_id)
  client.get_object(
    bucket: id,
    key: object_id
  )
end

Private Class Methods

client() click to toggle source
# File lib/alephant/harness/service/s3.rb, line 45
def self.client
  @client ||= ::Aws::S3::Client.new(AWS.s3_config)
end