Skip to content

Commit

Permalink
rake task to compile coffee to js
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Mar 24, 2011
1 parent ba4e12e commit a2ae954
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end

# coffee-script tasks
require 'coffee-script'

namespace :js do
desc "compile coffee-scripts from ./src to ./public/js"
task :compile do
source = "#{File.dirname(__FILE__)}/src/"
javascripts = "#{File.dirname(__FILE__)}/public/js/"

Dir.foreach(source) do |cf|
unless cf == '.' || cf == '..'
js = CoffeeScript.compile File.read("#{source}#{cf}")
open "#{javascripts}#{cf.gsub('.coffee', '.js')}", 'w' do |f|
f.puts js
end
end
end
end
end

# Bring in Rocco tasks
require 'rocco/tasks'
Rocco::make 'docs/', ["*.rb", "models/*.rb", "Rakefile"]
Expand Down

0 comments on commit a2ae954

Please sign in to comment.