Class: Csso::JsLib

Inherits:
Object
  • Object
show all
Defined in:
lib/csso/js_lib.rb

Instance Method Summary collapse

Constructor Details

#initializeJsLib

Returns a new instance of JsLib.



6
7
8
9
10
11
12
13
14
15
# File 'lib/csso/js_lib.rb', line 6

def initialize
  if ExecJS.runtime.is_a?(ExecJS::ExternalRuntime)
    warn "You're using ExecJS::ExternalRuntime, did you forget to add therubyracer or other execjs runtime to gemfile?"
  end

  lib = File.read(File.expand_path('../../' + CSSO_JS_LIB, File.dirname(__FILE__)))
  unless @csso = ExecJS.runtime.compile(lib)
    raise 'cannot compile or what?'
  end
end

Instance Method Details

#compress(css, structural_optimization = true) ⇒ Object



17
18
19
# File 'lib/csso/js_lib.rb', line 17

def compress css, structural_optimization=true
  @csso.call("do_compression", css, structural_optimization)
end

#compress_with_sourcemap(css, filename, structural_optimization = true) ⇒ Object



21
22
23
# File 'lib/csso/js_lib.rb', line 21

def compress_with_sourcemap css, filename, structural_optimization=true
  @csso.call("do_compression_with_map", css, filename, structural_optimization)
end