Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 26 lines (21 sloc) 0.599 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
require "tempfile"
require "yui/compressor"
require "fileutils"

APP_PATH = File.expand_path("./public/application.js")

task :build do
  `sprocketize -I public/ public/juggernaut.js > #{APP_PATH}`
end

task :compress do
  tempfile = Tempfile.new("yui")
  compressor = YUI::JavaScriptCompressor.new(:munge => true)
  File.open(APP_PATH, "r") do |file|
    compressor.compress(file) do |compressed|
      while buffer = compressed.read(4096)
        tempfile.write(buffer)
      end
    end
  end
  
  tempfile.close
  FileUtils.mv(tempfile.path, APP_PATH)
end

task :default => [:build, :compress]
Something went wrong with that request. Please try again.