Module: Sprockets::Compressing

### Home Classes Methods

### In Files

- lib/sprockets/compressing.rb

### Methods

- #compressors
- #css_compressor
- #css_compressor=
- #js_compressor
- #js_compressor=
- #register_compressor

### Included Modules

- Sprockets::Utils

### Class/Module Index

Quicksearch

- Sprockets
- Sprockets::ArgumentError
- Sprockets::Asset
- Sprockets::Autoload
- Sprockets::Base
- Sprockets::Bower
- Sprockets::Bundle
- Sprockets::Cache
- Sprockets::Cache::FileStore
- Sprockets::Cache::GetWrapper
- Sprockets::Cache::HashWrapper
- Sprockets::Cache::MemoryStore
- Sprockets::Cache::NullStore
- Sprockets::Cache::ReadWriteWrapper
- Sprockets::Cache::Wrapper
- Sprockets::CachedEnvironment
- Sprockets::ClosureCompressor
- Sprockets::CoffeeScriptProcessor
- Sprockets::CoffeeScriptTemplate
- Sprockets::Compressing
- Sprockets::Configuration
- Sprockets::ContentTypeMismatch
- Sprockets::Context
- Sprockets::ConversionError
- Sprockets::Dependencies
- Sprockets::DigestUtils
- Sprockets::DirectiveProcessor
- Sprockets::ERBProcessor
- Sprockets::ERBTemplate
- Sprockets::EcoProcessor
- Sprockets::EcoTemplate
- Sprockets::EjsProcessor
- Sprockets::EjsTemplate
- Sprockets::EncodingUtils
- Sprockets::Engines
- Sprockets::Environment
- Sprockets::Error
- Sprockets::FileNotFound
- Sprockets::FileOutsidePaths
- Sprockets::FileReader
- Sprockets::HTTPUtils
- Sprockets::Index
- Sprockets::JstProcessor
- Sprockets::LegacyProcProcessor
- Sprockets::LegacyTiltProcessor
- Sprockets::Loader
- Sprockets::Manifest
- Sprockets::ManifestUtils
- Sprockets::Mime
- Sprockets::NotFound
- Sprockets::NotImplementedError
- Sprockets::PathDependencyUtils
- Sprockets::PathDigestUtils
- Sprockets::PathUtils
- Sprockets::Paths
- Sprockets::Processing
- Sprockets::ProcessorUtils
- Sprockets::Resolve
- Sprockets::SassCompressor
- Sprockets::SassProcessor
- Sprockets::SassProcessor::CacheStore
- Sprockets::SassProcessor::Functions
- Sprockets::SassTemplate
- Sprockets::ScssProcessor
- Sprockets::ScssTemplate
- Sprockets::Server
- Sprockets::Transformers
- Sprockets::URITar
- Sprockets::URIUtils
- Sprockets::UglifierCompressor
- Sprockets::UnloadedAsset
- Sprockets::Utils
- Sprockets::YUICompressor
- Rake
- Rake::SprocketsTask

No matching classes.

# Sprockets::Compressing

`Compressing` is an internal mixin whose public methods are exposed on the `Environment` and `CachedEnvironment` classes.

### Public Instance Methods

compressors() click to toggle source

    # File lib/sprockets/compressing.rb, line 9
    def compressors
      config[:compressors]
    end

css_compressor() click to toggle source

Return CSS compressor or nil if none is set

    # File lib/sprockets/compressing.rb, line 21
    def css_compressor
      if defined? @css_compressor
        @css_compressor
      end
    end

css_compressor=(compressor) click to toggle source

Assign a compressor to run on `text/css` assets.

The compressor object must respond to `compress`.

    # File lib/sprockets/compressing.rb, line 30
    def css_compressor=(compressor)
      unregister_bundle_processor 'text/css', @css_compressor if defined? @css_compressor
      @css_compressor = nil
      return unless compressor

      if compressor.is_a?(Symbol)
        @css_compressor = klass = config[:compressors]['text/css'][compressor] || raise(Error, "unknown compressor: #{compressor}")
      elsif compressor.respond_to?(:compress)
        klass = LegacyProcProcessor.new(:css_compressor, proc { |context, data| compressor.compress(data) })
        @css_compressor = :css_compressor
      else
        @css_compressor = klass = compressor
      end

      register_bundle_processor 'text/css', klass
    end

js_compressor() click to toggle source

Return JS compressor or nil if none is set

    # File lib/sprockets/compressing.rb, line 48
    def js_compressor
      if defined? @js_compressor
        @js_compressor
      end
    end

js_compressor=(compressor) click to toggle source

Assign a compressor to run on `application/javascript` assets.

The compressor object must respond to `compress`.

    # File lib/sprockets/compressing.rb, line 57
    def js_compressor=(compressor)
      unregister_bundle_processor 'application/javascript', @js_compressor if defined? @js_compressor
      @js_compressor = nil
      return unless compressor

      if compressor.is_a?(Symbol)
        @js_compressor = klass = config[:compressors]['application/javascript'][compressor] || raise(Error, "unknown compressor: #{compressor}")
      elsif compressor.respond_to?(:compress)
        klass = LegacyProcProcessor.new(:js_compressor, proc { |context, data| compressor.compress(data) })
        @js_compressor = :js_compressor
      else
        @js_compressor = klass = compressor
      end

      register_bundle_processor 'application/javascript', klass
    end

register_compressor(mime_type, sym, klass) click to toggle source

    # File lib/sprockets/compressing.rb, line 13
    def register_compressor(mime_type, sym, klass)
      self.config = hash_reassoc(config, :compressors, mime_type) do |compressors|
        compressors[sym] = klass
        compressors
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.