Sha256: 9d8db9425e8e9fe7bfb903187abde05f93d89fdbc417acc013ecbc7f3fd62262

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 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)

        queue_name = opts[:sqs_queue_url] and recreate_sqs queue_name
        bucket     = opts[:bucket_id]     and recreate_s3 bucket

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

        #recreate_sqs queue_name

        #recreate_s3 bucket

        #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

3 entries across 3 versions & 1 rubygems

Version Path
alephant-harness-0.1.2 lib/alephant/harness/setup.rb
alephant-harness-0.1.1 lib/alephant/harness/setup.rb
alephant-harness-0.1.0 lib/alephant/harness/setup.rb