class Tumugi::Plugin::LocalFileSystem
Public Instance Methods
directory?(path)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 43 def directory?(path) File.directory?(path) end
entries(path)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 47 def entries(path) if directory?(path) Dir.glob(File.join(path, '*')) else raise NotADirectoryError end end
exist?(path)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 8 def exist?(path) File.exist?(path) end
mkdir(path, parents: true, raise_if_exist: false)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 20 def mkdir(path, parents: true, raise_if_exist: false) if File.exist?(path) if raise_if_exist raise FileAlreadyExistError.new("Path #{path} is already exist") elsif !directory?(path) raise NotADirectoryError.new("Path #{path} is not a directory") else return end end if parents FileUtils.mkdir_p(path) else parent_path = File.expand_path("..", path) if File.exist?(parent_path) FileUtils.mkdir(path) else raise MissingParentDirectoryError.new("Parent path #{parent_path} is not exist") end end end
move(src, dest, raise_if_exist: false)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 55 def move(src, dest, raise_if_exist: false) if File.exist?(dest) && raise_if_exist raise FileAlreadyExistError end FileUtils.mv(src, dest, force: true) end
remove(path, recursive: true)
click to toggle source
# File lib/tumugi/plugin/local_file_system.rb, line 12 def remove(path, recursive: true) if recursive && directory?(path) FileUtils.rm_r(path) else FileUtils.remove_file(path) end end