Sha256: e1d10dd07d5fd1fb1a3e8845f30f785cd2ea9edce17d03deb9c7575c08b4ba6f
Contents?: true
Size: 860 Bytes
Versions: 2
Compression:
Stored size: 860 Bytes
Contents
module JsSpec 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
js_spec-0.2.0 | lib/js_spec/resources/file.rb |
js_spec-0.2.1 | lib/js_spec/resources/file.rb |