Sprockets::Mime

Public Instance Methods

encoding_for_mime_type(type) click to toggle source

Returns the correct encoding for a given mime type, while falling back on the default external encoding, if it exists.

    # File lib/sprockets/mime.rb, line 37
37:       def encoding_for_mime_type(type)
38:         encoding = Encoding::BINARY if type =~ %{^(image|audio|video)/}
39:         encoding ||= default_external_encoding if respond_to?(:default_external_encoding)
40:         encoding
41:       end
extension_for_mime_type(type) click to toggle source
    # File lib/sprockets/mime.rb, line 19
19:       def extension_for_mime_type(type)
20:         mime_types.key(type)
21:       end
extension_for_mime_type(type) click to toggle source
    # File lib/sprockets/mime.rb, line 23
23:       def extension_for_mime_type(type)
24:         mime_types.index(type)
25:       end
mime_types(ext = nil) click to toggle source

Returns a `Hash` of registered mime types registered on the environment and those part of `Rack::Mime`.

If an `ext` is given, it will lookup the mime type for that extension.

    # File lib/sprockets/mime.rb, line 9
 9:     def mime_types(ext = nil)
10:       if ext.nil?
11:         Rack::Mime::MIME_TYPES.merge(@mime_types)
12:       else
13:         ext = Sprockets::Utils.normalize_extension(ext)
14:         @mime_types[ext] || Rack::Mime::MIME_TYPES[ext]
15:       end
16:     end
register_mime_type(mime_type, ext) click to toggle source

Register a new mime type.

    # File lib/sprockets/mime.rb, line 29
29:     def register_mime_type(mime_type, ext)
30:       ext = Sprockets::Utils.normalize_extension(ext)
31:       @mime_types[ext] = mime_type
32:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.