Class: Iceberg::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/ibg/storage.rb

Instance Method Summary collapse

Constructor Details

#initializeStorage

Returns a new instance of Storage.



8
9
10
11
12
13
14
# File 'lib/ibg/storage.rb', line 8

def initialize
  @bucketname = SETTING['local']['s3bucket']
  if @bucketname
    s3 = AWS::S3.new
    @bucket = s3.buckets[@bucketname]
  end
end

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
# File 'lib/ibg/storage.rb', line 34

def create
  if @bucketname
    s3 = AWS::S3.new
    @bucket = s3.buckets.create(@bucketname)
  else
    path = SETTING['local']['download']
    FileUtils.mkdir_p(path)
  end
end

#dirObject



24
25
26
27
28
29
30
31
32
# File 'lib/ibg/storage.rb', line 24

def dir
  if @bucketname
    s3 = AWS::S3.new
    s3.buckets
  else
    path = SETTING['local']['download']
    File.directory?(path) ? Dir.new(SETTING['local']['download']) : []
  end
end

#getobject(name) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ibg/storage.rb', line 16

def getobject(name)
  if @bucketname
    @bucket.objects['iceberg/' + name]
  else
    FileObject.new(name)
  end
end