Module: Alephant::Harness::Setup
- Defined in:
- lib/alephant/harness/setup.rb
Class Method Summary collapse
- .configure(opts = {}, env = nil) ⇒ Object
- .logger ⇒ Object
- .recreate_dynamo_db(table_name, schema) ⇒ Object
- .recreate_s3(bucket) ⇒ Object
- .recreate_sqs(queue_name) ⇒ Object
Class Method Details
.configure(opts = {}, env = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/alephant/harness/setup.rb', line 15 def self.configure(opts = {}, env = nil) AWS.configure(env) unless opts[:queues].nil? logger.info "Adding #{opts[:queues].length} queue(s)" opts[:queues].each do |queue_name| recreate_sqs queue_name end end unless opts[:buckets].nil? logger.info "Adding #{opts[:buckets].length} bucket(s)" opts[:buckets].each do |bucket| recreate_s3 bucket end end unless opts[:tables].nil? logger.info "Adding #{opts[:tables].length} table(s)" opts[:tables].each do |data| recreate_dynamo_db(data[:name], data[:schema]) end end end |
.logger ⇒ Object
11 12 13 |
# File 'lib/alephant/harness/setup.rb', line 11 def self.logger @@logger ||= ::Logger.new(STDOUT) end |
.recreate_dynamo_db(table_name, schema) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/alephant/harness/setup.rb', line 60 def self.recreate_dynamo_db(table_name, schema) logger.info "Adding DynamoDB table #{table_name}" Service::DynamoDB.remove(table_name) schema = schema.is_a?(Hash) ? schema : Service::DynamoDB.load_schema(schema) Service::DynamoDB.create(table_name, schema) end |
.recreate_s3(bucket) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/alephant/harness/setup.rb', line 50 def self.recreate_s3(bucket) Service::S3.bucket_exists?(bucket) do logger.warn "S3 bucket #{bucket} exists, removing" Service::S3.delete(bucket) end logger.info "Adding S3 bucket #{bucket}" Service::S3.create(bucket) end |
.recreate_sqs(queue_name) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/alephant/harness/setup.rb', line 40 def self.recreate_sqs(queue_name) Service::SQS.exists?(queue_name) do logger.warn "SQS queue #{queue_name} exists, removing" Service::SQS.delete(queue_name) end logger.info "Adding SQS queue #{queue_name}" Service::SQS.create(queue_name) end |