Sha256: effac2bda287e3c23af00ec1ee0cf82fa5fd6ff5ecebf096e13ab39710c27568

Contents?: true

Size: 779 Bytes

Versions: 4

Compression:

Stored size: 779 Bytes

Contents

require 'execjs'

module Csso
  class JsLib

    def initialize verbose=false
      if verbose && 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

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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
csso-rails-0.8.2 lib/csso/js_lib.rb
csso-rails-0.8.1 lib/csso/js_lib.rb
csso-rails-0.8.0 lib/csso/js_lib.rb
csso-rails-0.7.1 lib/csso/js_lib.rb