2009-12-18 14:55:31 +00:00
|
|
|
require 'erb'
|
2009-12-18 11:59:06 +00:00
|
|
|
require 'fileutils'
|
|
|
|
require 'rake/testtask'
|
2010-02-25 00:57:29 +00:00
|
|
|
require 'rubygems'
|
2010-02-25 01:41:56 +00:00
|
|
|
require 'yui/compressor'
|
2009-12-18 11:59:06 +00:00
|
|
|
|
2010-06-02 02:09:00 +00:00
|
|
|
HEADER = <<-EOS
|
|
|
|
/**
|
2010-06-28 04:19:58 +00:00
|
|
|
* CoffeeScript Compiler v0.7.0
|
2010-06-02 02:09:00 +00:00
|
|
|
* http://coffeescript.org
|
|
|
|
*
|
|
|
|
* Copyright 2010, Jeremy Ashkenas
|
|
|
|
* Released under the MIT License
|
|
|
|
*/
|
|
|
|
EOS
|
|
|
|
|
2009-12-18 14:55:31 +00:00
|
|
|
desc "Build the documentation page"
|
|
|
|
task :doc do
|
2009-12-20 03:55:58 +00:00
|
|
|
source = 'documentation/index.html.erb'
|
2010-02-27 07:21:26 +00:00
|
|
|
child = fork { exec "bin/coffee -c documentation/coffee/*.coffee -o documentation/js -w" }
|
2009-12-21 17:15:13 +00:00
|
|
|
at_exit { Process.kill("INT", child) }
|
|
|
|
Signal.trap("INT") { exit }
|
2009-12-20 03:55:58 +00:00
|
|
|
loop do
|
|
|
|
mtime = File.stat(source).mtime
|
|
|
|
if !@mtime || mtime > @mtime
|
|
|
|
rendered = ERB.new(File.read(source)).result(binding)
|
|
|
|
File.open('index.html', 'w+') {|f| f.write(rendered) }
|
|
|
|
end
|
|
|
|
@mtime = mtime
|
|
|
|
sleep 1
|
|
|
|
end
|
2009-12-18 14:55:31 +00:00
|
|
|
end
|
2010-02-25 00:57:29 +00:00
|
|
|
|
|
|
|
desc "Build the single concatenated and minified script for the browser"
|
|
|
|
task :browser do
|
2010-03-10 02:24:30 +00:00
|
|
|
sources = %w(helpers.js rewriter.js lexer.js parser.js scope.js nodes.js coffee-script.js)
|
2010-02-25 00:57:29 +00:00
|
|
|
code = sources.map {|s| File.read('lib/' + s) }.join('')
|
2010-06-28 04:19:58 +00:00
|
|
|
code = YUI::JavaScriptCompressor.new.compress(code)
|
2010-06-02 02:09:00 +00:00
|
|
|
File.open('extras/coffee-script.js', 'w+') {|f| f.write(HEADER + code) }
|
2010-02-25 00:57:29 +00:00
|
|
|
end
|
|
|
|
|