Module: Jsus::Util::Compressor

Defined in:
lib/jsus/util/compressor.rb

Class Method Summary collapse

Class Method Details

.compress(source, options = {}) ⇒ String

Compresses the javascript source with given compressor and returns the result.

Parameters:

  • source (String)

    javascript source code

  • options (Hash) (defaults to: {})
  • [Symbol] (Hash)

    a customizable set of options

Returns:

  • (String)

    compressed js code



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jsus/util/compressor.rb', line 14

def compress(source, options = {})
  method = options.fetch(:method, :yui)
  @result = case method.to_s
    when "uglifier" then compress_with_uglifier(source)
    when "frontcompiler" then compress_with_frontcompiler(source)
    when "closure" then compress_with_closure(source)
    when "yui" then compress_with_yui(source)
    else
      Jsus.logger.error "tried to use unavailable method #{method.inspect}"
      source
  end
end