module OmniStore::Storage::Local
Public Instance Methods
delete(path, mp = mountpoint)
click to toggle source
# File lib/omnistore/storage/local.rb, line 36 def delete(path, mp = mountpoint) mp.delete(path) end
each() { |new_mountpoint(key)| ... }
click to toggle source
# File lib/omnistore/storage/local.rb, line 48 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)
click to toggle source
# File lib/omnistore/storage/local.rb, line 32 def exist?(path, mp = mountpoint) mp.exist?(path) end
mount!()
click to toggle source
# File lib/omnistore/storage/local.rb, line 8 def mount! @@keys = {} case mountpoint = OmniStore::Config.mountpoint when Array mountpoint.each do |m| validate(m) @@keys[m] = {:name => File.basename(m), :dir => m} end when Hash mountpoint.each do |k,v| validate(v) @@keys[k] = {:name => k, :dir => v} end else m = mountpoint.to_s validate(m) @@keys[m] = {:name => File.basename(m), :dir => m} end end
mountpoint(key = @@keys.keys.first)
click to toggle source
# File lib/omnistore/storage/local.rb, line 28 def mountpoint(key = @@keys.keys.first) new_mountpoint(key) end
read(path, options = {}, mp = mountpoint, &block)
click to toggle source
# File lib/omnistore/storage/local.rb, line 40 def read(path, options = {}, mp = mountpoint, &block) mp.read(path, options, &block) end
write(path, options_or_data = nil, options = {}, mp = mountpoint)
click to toggle source
# File lib/omnistore/storage/local.rb, line 44 def write(path, options_or_data = nil, options = {}, mp = mountpoint) mp.write(path, options_or_data, options) end
Private Instance Methods
new_mountpoint(key)
click to toggle source
# File lib/omnistore/storage/local.rb, line 62 def new_mountpoint(key) return nil unless @@keys.key?(key) Mountpoint.new(@@keys[key][:name], @@keys[key][:dir]) end
validate(mountpoint)
click to toggle source
# File lib/omnistore/storage/local.rb, line 58 def validate(mountpoint) raise OmniStore::Errors::InvalidMountpoint unless File.exist?(mountpoint) && File.directory?(mountpoint) end