Sha256: 4a30011acda6c8e4296258e1d83ec97527b3ad105dc73b7beee32fdb3b5f4dea
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
module JsTestCore module Resources class File < ThinRest::Resource MIME_TYPES = { '.js' => 'text/javascript', '.css' => 'text/css', '.png' => 'image/png', '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', } property :absolute_path, :relative_path def get extension = ::File.extname(absolute_path) content_type = MIME_TYPES[extension] || 'text/html' connection.terminate_after_sending do connection.send_head( 200, 'Content-Type' => content_type, 'Last-Modified' => ::File.mtime(absolute_path).rfc822, 'Content-Length' => ::File.size(absolute_path) ) ::File.open(absolute_path) do |file| while !file.eof? connection.send_data(file.read(1024)) end end end def ==(other) return false unless other.class == self.class absolute_path == other.absolute_path && relative_path == other.relative_path end end end end end
Version data entries
4 entries across 4 versions & 3 rubygems