Class: Microstatic::S3BucketCreator

Inherits:
Object
  • Object
show all
Includes:
UsesFog
Defined in:
lib/microstatic/s3_bucket_creator.rb

Instance Method Summary collapse

Methods included from UsesFog

#check_and_store_aws_creds, #connection, #dns

Constructor Details

#initialize(aws_creds) ⇒ S3BucketCreator

Returns a new instance of S3BucketCreator.



6
7
8
# File 'lib/microstatic/s3_bucket_creator.rb', line 6

def initialize( aws_creds )
  check_and_store_aws_creds(aws_creds)
end

Instance Method Details

#create(bucket_name) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/microstatic/s3_bucket_creator.rb', line 10

def create( bucket_name )
  # TODO: can we create a new directory without eagerly fetch the list of all dirs?
  directory = connection.directories.create( :key => bucket_name, :public => true )
  # TODO: can I do this by calling a method on directory? 
  connection.put_bucket_website( directory.key, 'index.html', :key => '404.html' )

  directory
end