Sha256: 05f6a908468cecb3f55abe6f2674a27374d8140e035a991d07cf2ff00258e444
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
module FakeDropbox module Utils DATE_FORMAT = '%a, %d %b %Y %H:%M:%S %z' def metadata(path, list=false) full_path = File.join(@dropbox_dir, path) path.insert(0, '/') if path[0] != '/' bytes = File.directory?(path) ? 0 : File.size(full_path) metadata = { thumb_exists: false, bytes: bytes, modified: File.mtime(full_path).strftime(DATE_FORMAT), path: path, is_dir: File.directory?(full_path), size: "#{bytes} bytes", root: "dropbox" } if File.directory?(full_path) metadata[:icon] = "folder" if list entries = Dir.entries(full_path).reject { |x| ['.', '..'].include? x } metadata[:contents] = entries.map do |entry| metadata(File.join(path, entry)) end end else metadata[:icon] = "page_white" end metadata end def safe_path(path) path.gsub(/(\.\.\/|\/\.\.)/, '') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fake_dropbox-0.1.0 | lib/fake_dropbox/utils.rb |