Harbor::FileStore::Local
Attributes
Public Class Methods
file_mask()
# File lib/harbor/file_store/local.rb, line 8 8: def self.file_mask 9: @@file_mask 10: end
Public Instance Methods
delete(path)
# File lib/harbor/file_store/local.rb, line 44 44: def delete(path) 45: path = strip_leading_slash(path) 46: ::FileUtils.rm(@root + path) 47: Harbor::File.rmdir_p((@root + path).parent.to_s) 48: end
exists?(path)
# File lib/harbor/file_store/local.rb, line 50 50: def exists?(path) 51: path = strip_leading_slash(path) 52: (@root + path).exist? 53: end
get(path)
# File lib/harbor/file_store/local.rb, line 25 25: def get(path) 26: path = strip_leading_slash(path) 27: Harbor::FileStore::File.new(self, path) 28: end
open(path, mode = "r", &block)
# File lib/harbor/file_store/local.rb, line 55 55: def open(path, mode = "r", &block) 56: path = strip_leading_slash(path) 57: ::FileUtils.mkdir_p((@root + path).parent.to_s) unless (@root + path).parent.exist? 58: ::File.open(@root + path, mode, &block) 59: end
put(path, absolute_path)
# File lib/harbor/file_store/local.rb, line 30 30: def put(path, absolute_path) 31: raise ArgumentError.new("Harbor::FileStore::Local#put[absolute_path] should be a path but was an IO") if absolute_path.is_a?(IO) 32: path = strip_leading_slash(path) 33: file = Harbor::FileStore::File.new(self, path) 34: 35: unless (@root + path).parent.exist? 36: ::FileUtils.mkdir_p((@root + path).parent.to_s) 37: end 38: 39: ::FileUtils::cp(absolute_path, file.absolute_path) 40: ::FileUtils::chmod(Harbor::FileStore::Local.file_mask, file.absolute_path) 41: file 42: end