Created
August 1, 2011 19:13
-
-
Save anonymous/1118796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Watch the site and regenerate when it changes" | |
task :watch do | |
require 'fssm' | |
puts "Watching for Changes " | |
FSSM.monitor(File.join(File.dirname(__FILE__), 'content'), '**/*') do | |
update {|base, relative| rebuild_site(relative)} | |
delete {|base, relative| rebuild_site(relative)} | |
create {|base, relative| rebuild_site(relative)} | |
end | |
end | |
def rebuild_site(x) | |
case x.split('.') | |
when 'sass' | |
puts "Compiling #{x.inspect} to CSS" | |
system("sass content/#{x} public/#{x.gsub('.sass', '.css')}") | |
when 'haml' | |
puts "Compiling #{x.inspect} to XHTML" | |
system("haml content/#{x} public/#{x.gsub('.haml', '.html')}") | |
when 'js' | |
return if x.include?('.min') | |
puts "Minify #{x.inspect}" | |
system("java -jar /Users/joona/tmp/yuicompressor-2.4.6.jar -o public/#{x.gsub('.js', '.min.js')} --line-break 400 content/#{x}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment