Sha256: af470ddf174a77cc247922719b430eb9bae3f87c24ab8c8603b41b2549a0a341
Contents?: true
Size: 959 Bytes
Versions: 3
Compression:
Stored size: 959 Bytes
Contents
module Storage module Strategies module FileSystem extend self def prepare! FileUtils.mkdir_p File.expand_path(Storage::Config.path) end def fullpath(file) File.expand_path File.join(Storage::Config.path, file) end def get(file, *noop) prepare! path = fullpath(file) raise Storage::MissingFileError unless File.file?(path) path end 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) File.open(path, "wb") do |handler| while line = file.gets handler.write line end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
storage-0.1.5 | lib/storage/strategies/file_system.rb |
storage-0.1.3 | lib/storage/strategies/file_system.rb |
storage-0.1.2 | lib/storage/strategies/file_system.rb |