Sha256: ca15c09b175496ccaaf325ce79b6c93d639bb838b0d783a65c2607df4531886f
Contents?: true
Size: 876 Bytes
Versions: 5
Compression:
Stored size: 876 Bytes
Contents
module JsTestCore module Resources class File MIME_TYPES = { '.js' => 'text/javascript', '.css' => 'text/css', '.png' => 'image/png', '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', } attr_reader :absolute_path, :relative_path def initialize(absolute_path, relative_path) @absolute_path = absolute_path @relative_path = relative_path end def get(request, response) extension = ::File.extname(absolute_path) response.headers['Content-Type'] = MIME_TYPES[extension] || 'text/html' response.body = ::File.read(absolute_path) end def ==(other) return false unless other.class == self.class absolute_path == other.absolute_path && relative_path == other.relative_path end end end end
Version data entries
5 entries across 5 versions & 4 rubygems