Module: Sqwish

Defined in:
lib/sqwish.rb

Defined Under Namespace

Modules: Strict

Class Method Summary collapse

Class Method Details

.minify(src, options = {:strict => false}) ⇒ Object Also known as: compress



6
7
8
9
# File 'lib/sqwish.rb', line 6

def minify(src, options={:strict => false})
  is_strict = !! options[:strict]
  sqwish_js.call "sqwish", src, is_strict
end

.sqwish_jsObject



13
14
15
# File 'lib/sqwish.rb', line 13

def sqwish_js
  @squish_js ||= ExecJS.compile(sqwish_wrapper)
end

.sqwish_js_pathObject



30
31
32
# File 'lib/sqwish.rb', line 30

def sqwish_js_path
  File.expand_path '../../sqwish/src/index.js', __FILE__
end

.sqwish_srcObject



26
27
28
# File 'lib/sqwish.rb', line 26

def sqwish_src
  src = open(sqwish_js_path).read
end

.sqwish_wrapperObject



17
18
19
20
21
22
23
24
# File 'lib/sqwish.rb', line 17

def sqwish_wrapper
  # Since we're not using node, some things will have to be stubbed.
  %{
    var require = function() { return {}; };
    var module  = { exports: {} };
    #{sqwish_src}
  }
end

.versionObject



34
35
36
# File 'lib/sqwish.rb', line 34

def version
  "0.2.0.1"
end