Sha256: 2921fa47c92c20f76ff590d66a7a06bace941aeddd3d27436b5615ee5c847c6c

Contents?: true

Size: 727 Bytes

Versions: 2

Compression:

Stored size: 727 Bytes

Contents

require "dependence/colors"

class JsCompressor
  def initialize(source_file, output_file = nil)
    output_file = source_file.gsub(".js", ".min.js") unless output_file
    @source = source_file
    @output = output_file
  end

  def compress
    @cmd = cmd_prefix
    puts Colors.green("Compressing: #{@source}")
    puts Colors.red "Compressor Output:"
    execute_compile
  end

  private
  def execute_compile
    @cmd += " --js #{@source} --js_output_file #{@output}"
    `#{@cmd}`
    puts Colors.green("compressed #{@source} to #{@output}")
  end

  def cmd_prefix
    path = File.join(File.dirname(__FILE__), "../", "../", "compiler", "compiler.jar")
    "java -jar #{path}"
    # --create_source_map js_map
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dependence-0.0.97 lib/dependence/js_compressor.rb
dependence-0.0.96 lib/dependence/js_compressor.rb