Module: OmniStore::Storage::S3

Extended by:
S3
Included in:
S3
Defined in:
lib/omnistore/storage/s3.rb,
lib/omnistore/storage/s3/mountpoint.rb

Defined Under Namespace

Classes: Mountpoint

Instance Method Summary collapse

Instance Method Details

#delete(path, options = {}, mp = mountpoint) ⇒ Object



39
40
41
# File 'lib/omnistore/storage/s3.rb', line 39

def delete(path, options = {}, mp = mountpoint)
  mp.delete(path, options)
end

#each(&block) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/omnistore/storage/s3.rb', line 51

def each(&block)
  if block_given?
    @@keys.each{|key| yield new_mountpoint(key) }
  else
    Enumerator.new(@@keys.map{|key| new_mountpoint(key)})
  end
end

#exist?(path, mp = mountpoint) ⇒ Boolean Also known as: find

Returns:

  • (Boolean)


34
35
36
# File 'lib/omnistore/storage/s3.rb', line 34

def exist?(path, mp = mountpoint)
  mp.exist?(path)
end

#mount!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/omnistore/storage/s3.rb', line 10

def mount!
  @@keys = {}
  case mountpoint = OmniStore::Config.mountpoint
  when Array
    mountpoint.each do |m|
      b = bucket(m)
      @@keys[m] = {:name => m, :bucket => b}
    end
  when Hash
    mountpoint.each do |k,v|
      b = bucket(v)
      @@keys[k] = {:name => k, :bucket => b}
    end
  else
    m = mountpoint.to_s
    b = bucket(m)
    @@keys[m] = {:name => m, :bucket => b}
  end
end

#mountpoint(key = @@keys.keys.first) ⇒ Object



30
31
32
# File 'lib/omnistore/storage/s3.rb', line 30

def mountpoint(key = @@keys.keys.first)
  new_mountpoint(key)
end

#read(path, options = {}, mp = mountpoint, &block) ⇒ Object



43
44
45
# File 'lib/omnistore/storage/s3.rb', line 43

def read(path, options = {}, mp = mountpoint, &block)
  mp.read(path, options, &block)
end

#write(path, options_or_data = nil, options = {}, mp = mountpoint) ⇒ Object



47
48
49
# File 'lib/omnistore/storage/s3.rb', line 47

def write(path, options_or_data = nil, options = {}, mp = mountpoint)
  mp.write(path, options_or_data, options)
end