Sha256: ae78a58136ab04105e6bebf8e2814ced31880415448ce214445be2531dacf578
Contents?: true
Size: 776 Bytes
Versions: 2
Compression:
Stored size: 776 Bytes
Contents
require 'rack' module Jeanine class Mimes MimeTypeNotFound = Class.new(StandardError) MIME_TYPES_INVERTED = ::Rack::Mime::MIME_TYPES.invert def self.load! register(:json, Rack::Mime::MIME_TYPES[".json"]) register(:html, Rack::Mime::MIME_TYPES[".html"]) register(:text, Rack::Mime::MIME_TYPES[".text"]) register(:plain, self.for(:text)) end def self.register(type, header) mime_types[type] = header end def self.for(type) mime_types.fetch(type) do raise(MimeTypeNotFound, "Mime #{type} not registered") end end def self.mime_types @mime_types ||= {} end private_class_method :mime_types def initialize(*) raise "Should not be initialiazed" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jeanine-0.4.0 | lib/jeanine/mimes.rb |
jeanine-0.3.0 | lib/jeanine/mimes.rb |