2010-11-21 22:33:27 -05:00
|
|
|
require 'rubygems'
|
2009-12-18 09:55:31 -05:00
|
|
|
require 'erb'
|
2009-12-18 06:59:06 -05:00
|
|
|
require 'fileutils'
|
|
|
|
require 'rake/testtask'
|
2010-11-21 22:33:27 -05:00
|
|
|
require 'json'
|
2010-06-01 22:09:00 -04:00
|
|
|
|
2009-12-18 09:55:31 -05:00
|
|
|
desc "Build the documentation page"
|
|
|
|
task :doc do
|
2009-12-19 22:55:58 -05:00
|
|
|
source = 'documentation/index.html.erb'
|
2010-10-13 15:09:56 -04:00
|
|
|
child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
|
2009-12-21 12:15:13 -05:00
|
|
|
at_exit { Process.kill("INT", child) }
|
|
|
|
Signal.trap("INT") { exit }
|
2009-12-19 22:55:58 -05: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 09:55:31 -05:00
|
|
|
end
|
2010-02-24 19:57:29 -05:00
|
|
|
|
2010-11-21 21:42:15 -05:00
|
|
|
desc "Build coffee-script-source gem"
|
|
|
|
task :gem do
|
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
|
|
|
|
gemspec = Gem::Specification.new do |s|
|
|
|
|
s.name = 'coffee-script-source'
|
2010-11-21 22:33:27 -05:00
|
|
|
s.version = JSON.parse(File.read('package.json'))["version"]
|
|
|
|
s.date = Time.now.strftime("%Y-%m-%d")
|
2010-11-21 21:42:15 -05:00
|
|
|
|
|
|
|
s.homepage = "http://jashkenas.github.com/coffee-script/"
|
|
|
|
s.summary = "The CoffeeScript Compiler"
|
|
|
|
s.description = <<-EOS
|
|
|
|
CoffeeScript is a little language that compiles into JavaScript.
|
|
|
|
Underneath all of those embarrassing braces and semicolons,
|
|
|
|
JavaScript has always had a gorgeous object model at its heart.
|
|
|
|
CoffeeScript is an attempt to expose the good parts of JavaScript
|
|
|
|
in a simple way.
|
|
|
|
EOS
|
|
|
|
|
|
|
|
s.files = [
|
|
|
|
'lib/coffee_script/coffee-script.js',
|
|
|
|
'lib/coffee_script/source.rb'
|
|
|
|
]
|
|
|
|
|
|
|
|
s.authors = ['Jeremy Ashkenas']
|
|
|
|
s.email = 'jashkenas@gmail.com'
|
|
|
|
s.rubyforge_project = 'coffee-script-source'
|
|
|
|
end
|
|
|
|
|
|
|
|
file = File.open("coffee-script-source.gem", "w")
|
|
|
|
Gem::Package.open(file, 'w') do |pkg|
|
|
|
|
pkg.metadata = gemspec.to_yaml
|
|
|
|
|
|
|
|
path = "lib/coffee_script/source.rb"
|
|
|
|
contents = <<-ERUBY
|
|
|
|
module CoffeeScript
|
|
|
|
module Source
|
|
|
|
def self.bundled_path
|
|
|
|
File.expand_path("../coffee-script.js", __FILE__)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ERUBY
|
|
|
|
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
|
|
|
|
tar_io.write(contents)
|
|
|
|
end
|
|
|
|
|
|
|
|
contents = File.read("extras/coffee-script.js")
|
|
|
|
path = "lib/coffee_script/coffee-script.js"
|
|
|
|
pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
|
|
|
|
tar_io.write(contents)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|