Class: Filezor::Server

Inherits:
Sinatra::Base
  • Object
show all
Extended by:
ClassMethods
Includes:
FileUtils, Util
Defined in:
lib/filezor/server.rb

Defined Under Namespace

Modules: ClassMethods Classes: BadRequest

Constant Summary collapse

PATH_ROUTE =
%r[/file(/.+)]
PATH_ROUTE_ROOT =
%r[/file/?]
CACHED =
%r[/cached/?]
PASSWORD =
%r[/auth/?]
INFO =
%r[/info/?]
PING =
%r[/ping/?]

Constants included from Util

Util::BUFFER_SIZE

Instance Method Summary collapse

Methods included from ClassMethods

authenticate, caching, caching=, password, password=, password_file, start_embedded!

Methods included from Util

#files_from_map, #md5

Instance Method Details

#cacheObject



136
137
138
# File 'lib/filezor/server.rb', line 136

def cache
  File.join(root, ".cache")
end

#caching?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/filezor/server.rb', line 140

def caching?
  self.class.caching
end

#path_of(relative, chroot = nil) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/filezor/server.rb', line 123

def path_of(relative, chroot = nil)
  new_root = case chroot
               when nil;   root
               when /^\//; chroot
               else;       File.join(root, chroot)
             end
  new_path = File.expand_path(File.join(new_root, CGI::unescape(relative)))
  unless new_path[0, root.length] == root
    raise "Can't leave root"
  end
  new_path
end

#rootObject



144
145
146
# File 'lib/filezor/server.rb', line 144

def root
  self.class.root
end