Class: BuildCloud::S3Bucket

Inherits:
Object
  • Object
show all
Includes:
Component
Defined in:
lib/build-cloud/s3bucket.rb

Constant Summary collapse

@@objects =
[]

Instance Method Summary collapse

Methods included from Component

included

Constructor Details

#initialize(fog_interfaces, log, options = {}) ⇒ S3Bucket

Returns a new instance of S3Bucket.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/build-cloud/s3bucket.rb', line 7

def initialize ( fog_interfaces, log, options = {} )

    @s3      = fog_interfaces[:s3]
    @log     = log
    @options = options

    @log.debug( options.inspect )

    required_options(:key, :location)

end

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/build-cloud/s3bucket.rb', line 19

def create
    
    return if exists?

    @log.info( "Creating new S3 bucket #{@options[:key]}" )

    bucket = @s3.directories.new( @options )
    bucket.save

    @log.debug( bucket.inspect )

end

#deleteObject



38
39
40
41
42
43
44
45
46
# File 'lib/build-cloud/s3bucket.rb', line 38

def delete

    return unless exists?

    @log.info( "Deleting S3 bucket #{@options[:key]}" )

    fog_object.destroy

end

#readObject Also known as: fog_object



32
33
34
# File 'lib/build-cloud/s3bucket.rb', line 32

def read
    @s3.directories.select { |d| d.key == @options[:key] }.first
end