UNPKG

2.25 kBPlain TextView Raw
1require 'rubygems'
2require 'erb'
3require 'fileutils'
4require 'rake/testtask'
5require 'json'
6
7desc "Build the documentation page"
8task :doc do
9 source = 'documentation/index.html.erb'
10 child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
11 at_exit { Process.kill("INT", child) }
12 Signal.trap("INT") { exit }
13 loop do
14 mtime = File.stat(source).mtime
15 if !@mtime || mtime > @mtime
16 rendered = ERB.new(File.read(source)).result(binding)
17 File.open('index.html', 'w+') {|f| f.write(rendered) }
18 end
19 @mtime = mtime
20 sleep 1
21 end
22end
23
24desc "Build coffee-script-source gem"
25task :gem do
26 require 'rubygems'
27 require 'rubygems/package'
28
29 gemspec = Gem::Specification.new do |s|
30 s.name = 'coffee-script-source'
31 s.version = JSON.parse(File.read('package.json'))["version"]
32 s.date = Time.now.strftime("%Y-%m-%d")
33
34 s.homepage = "http://jashkenas.github.com/coffee-script/"
35 s.summary = "The CoffeeScript Compiler"
36 s.description = <<-EOS
37 CoffeeScript is a little language that compiles into JavaScript.
38 Underneath all of those embarrassing braces and semicolons,
39 JavaScript has always had a gorgeous object model at its heart.
40 CoffeeScript is an attempt to expose the good parts of JavaScript
41 in a simple way.
42 EOS
43
44 s.files = [
45 'lib/coffee_script/coffee-script.js',
46 'lib/coffee_script/source.rb'
47 ]
48
49 s.authors = ['Jeremy Ashkenas']
50 s.email = 'jashkenas@gmail.com'
51 s.rubyforge_project = 'coffee-script-source'
52 end
53
54 file = File.open("coffee-script-source.gem", "w")
55 Gem::Package.open(file, 'w') do |pkg|
56 pkg.metadata = gemspec.to_yaml
57
58 path = "lib/coffee_script/source.rb"
59 contents = <<-ERUBY
60module CoffeeScript
61 module Source
62 def self.bundled_path
63 File.expand_path("../coffee-script.js", __FILE__)
64 end
65 end
66end
67 ERUBY
68 pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
69 tar_io.write(contents)
70 end
71
72 contents = File.read("extras/coffee-script.js")
73 path = "lib/coffee_script/coffee-script.js"
74 pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
75 tar_io.write(contents)
76 end
77 end
78end