Sha256: 218ba288feea85db3dae649100d5d66f74a0a9a0f22d6a9a6fb72b1623dacfe9

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require "alephant/harness/service/dynamo_db"
require "alephant/harness/service/s3"
require "alephant/harness/service/sqs"
require "alephant/harness/aws"

module Alephant
  module Harness
    module Setup

      def self.configure(opts = {}, env = nil)
        AWS.configure(env)

        opts[:queues].each do |queue_name|
          recreate_sqs queue_name
        end

        bucket = opts[:bucket_id] and recreate_s3 bucket

        tables = {
          :lookup    => opts[:lookup_table_name],
          :sequencer => opts[:sequencer_table_name],
        } and recreate_dynamo_db tables

      end

      def self.recreate_sqs(queue_name)
        Service::SQS.exists?(queue_name) do
          Service::SQS.delete(queue_name)
        end

        Service::SQS.create(queue_name)
      end

      def self.recreate_s3(bucket)
        Service::S3.exists?(bucket) do
          Service::S3.delete(bucket)
        end

        Service::S3.create(queue_name)
      end

      def self.recreate_dynamo_db(tables)
        Service::DynamoDB.remove(tables.values)

        tables.each do |schema_name, table_name|
          Service::DynamoDB.create(table_name, schema_name)
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-harness-0.1.3 lib/alephant/harness/setup.rb