Module: Sprockets::Mime

### Home Classes Methods

### In Files

- lib/sprockets/mime.rb

### Methods

- #encoding_for_mime_type
- #extension_for_mime_type
- #mime_types
- #register_mime_type
- #registered_mime_types

### Class/Module Index

Quicksearch

- Sprockets
- Sprockets::ArgumentError
- Sprockets::Asset
- Sprockets::AssetAttributes
- Sprockets::Base
- Sprockets::BundledAsset
- Sprockets::Cache
- Sprockets::Cache::FileStore
- Sprockets::Caching
- Sprockets::CharsetNormalizer
- Sprockets::CircularDependencyError
- Sprockets::ClosureCompressor
- Sprockets::Compressing
- Sprockets::ContentTypeMismatch
- Sprockets::Context
- Sprockets::DirectiveProcessor
- Sprockets::EcoTemplate
- Sprockets::EjsTemplate
- Sprockets::EncodingError
- Sprockets::EngineError
- Sprockets::Engines
- Sprockets::Environment
- Sprockets::Error
- Sprockets::FileNotFound
- Sprockets::FileOutsidePaths
- Sprockets::Index
- Sprockets::JstProcessor
- Sprockets::Manifest
- Sprockets::Mime
- Sprockets::NotImplementedError
- Sprockets::Paths
- Sprockets::ProcessedAsset
- Sprockets::ProcessedAsset::DependencyFile
- Sprockets::Processing
- Sprockets::Processor
- Sprockets::SafetyColons
- Sprockets::SassCacheStore
- Sprockets::SassCompressor
- Sprockets::SassFunctions
- Sprockets::SassImporter
- Sprockets::SassTemplate
- Sprockets::ScssTemplate
- Sprockets::Server
- Sprockets::StaticAsset
- Sprockets::UglifierCompressor
- Sprockets::UnserializeError
- Sprockets::Utils
- Sprockets::YUICompressor
- Rake
- Rake::SprocketsTask

No matching classes.

# 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 42
    def encoding_for_mime_type(type)
      encoding = Encoding::BINARY if type =~ %{^(image|audio|video)/}
      encoding ||= default_external_encoding if respond_to?(:default_external_encoding)
      encoding
    end

extension_for_mime_type(type) click to toggle source

    # File lib/sprockets/mime.rb, line 24
    def extension_for_mime_type(type)
      mime_types.key(type)
    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
    def mime_types(ext = nil)
      if ext.nil?
        Rack::Mime::MIME_TYPES.merge(@mime_types)
      else
        ext = Sprockets::Utils.normalize_extension(ext)
        @mime_types[ext] || Rack::Mime::MIME_TYPES[ext]
      end
    end

register_mime_type(mime_type, ext) click to toggle source

Register a new mime type.

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

registered_mime_types() click to toggle source

Returns a `Hash` of explicitly registered mime types.

    # File lib/sprockets/mime.rb, line 19
    def registered_mime_types
      @mime_types.dup
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.