class Requeus::Adapter::Filesystem
Public Class Methods
new(opts)
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 6 def initialize opts @path = opts['path'] ensure_path end
Public Instance Methods
delete(uid)
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 23 def delete uid FileUtils.remove path_for(uid) true end
get(uid)
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 18 def get uid return nil unless File.exists?(path_for(uid)) File.new path_for(uid) end
put(file)
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 11 def put file uid = generate_id FileUtils.copy file.path, path_for(uid) FileUtils.chmod 0666, path_for(uid) uid end
Private Instance Methods
ensure_path()
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 34 def ensure_path FileUtils.mkdir_p(@path) unless File.exists?(@path) raise "Path '#{@path}' is not writable" unless File.writable?(@path) end
generate_id()
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 39 def generate_id UUIDTools::UUID.timestamp_create().to_s end
path_for(uid)
click to toggle source
# File lib/requeus/adapter/filesystem.rb, line 30 def path_for uid File.join @path, uid end