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



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

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

#each(&block) ⇒ Object



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

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)


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

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

#mount!Object



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

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



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

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

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



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

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

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



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

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