lib/storage/strategies/file_system.rb in storage-0.1.1 vs lib/storage/strategies/file_system.rb in storage-0.1.2
- old
+ new
@@ -1,29 +1,32 @@
module Storage
module Strategies
module FileSystem
extend self
- def self.prepare!
+ def prepare!
FileUtils.mkdir_p File.expand_path(Storage::Config.path)
end
def fullpath(file)
- File.expand_path(File.join(Storage::Config.path, file))
+ File.expand_path File.join(Storage::Config.path, file)
end
- def get(file)
+ def get(file, *noop)
+ prepare!
path = fullpath(file)
raise Storage::MissingFileError unless File.file?(path)
path
end
- def remove(file)
+ def remove(file, *noop)
+ prepare!
path = get(file)
File.unlink(path)
end
def store(file, options = {})
+ prepare!
file = File.open(file, "rb") unless file.respond_to?(:read) && !file.kind_of?(Pathname)
path = fullpath(options[:name])
raise Storage::FileAlreadyExistsError if File.file?(path)