Class: Lotus::Assets::Compressors::Javascript Private

Inherits:
Abstract
  • Object
show all
Defined in:
lib/lotus/assets/compressors/javascript.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base class for JavaScript compressors

Since:

  • 0.1.0

Class Method Summary collapse

Methods inherited from Abstract

#compress

Class Method Details

.for(engine_name) ⇒ Lotus::Assets::Compressors::Abstract

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Factory for Javascript compressors.

It loads a compressor for the given name.

Examples:

Basic Usage

require 'lotus/assets'
require 'lotus/assets/compressors/javascript'

Lotus::Assets::Compressors::Javascript.for(:closure)
  # => #<Lotus::Assets::Compressors::ClosureJavascript:0x007fa32a32e108 ...>

Null Compressor

require 'lotus/assets'
require 'lotus/assets/compressors/javascript'

Lotus::Assets::Compressors::Javascript.for(nil)
  # => #<Lotus::Assets::Compressors::NullCompressor:0x007fa32a314258>

Custom Compressor

require 'lotus/assets'
require 'lotus/assets/compressors/javascript'

class CustomJavascriptCompressor
  def compress(filename)
    # ...
  end
end

Lotus::Assets::Compressors::Javascript.for(CustomJavascriptCompressor.new)
  # => #<CustomJavascriptCompressor:0x007fa32a2cdf10>

Third Party Compressor

require 'lotus/assets'
require 'lotus/assets/compressors/javascript'
require 'lotus/foo/compressor' # third party gem

Lotus::Assets::Compressors::Javascript.for(:foo)
  # => #<Lotus::Assets::Compressors::FooJavascript:0x007fa3dd9ed968>

Unknown Engine

require 'lotus/assets'
require 'lotus/assets/compressors/javascript'

Lotus::Assets::Compressors::Javascript.for(:wat)
  # => Lotus::Assets::Compressors::UnknownCompressorError: Unknown Javascript compressor: :wat

Parameters:

  • engine_name (Symbol, String, NilClass, #compress)

    the name of the engine to load or an instance of an engine

Returns:

Raises:

See Also:

Since:

  • 0.1.0


71
72
73
# File 'lib/lotus/assets/compressors/javascript.rb', line 71

def self.for(engine_name)
  super
end