Rakefile 2.2 KB

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