Created
March 18, 2011 11:36
-
-
Save royratcliffe/875920 to your computer and use it in GitHub Desktop.
This file contains 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
namespace :haml do | |
# Monitor the current directory looking for changes to Haml source files and | |
# compile on updates. Defaults to watching the current directory. You can | |
# override by specifying another directory in square brackets immediately | |
# after the watch target, e.g. | |
# | |
# rake haml:watch[/tmp] | |
# | |
# Note, you need the FSSM gem installing, i.e. gem install fssm. Of course, | |
# you also need Haml itself. | |
desc "Look for changes to Haml source files and compile on update" | |
task :watch, [:directory] do |t, args| | |
args.with_defaults(:directory => Dir.getwd) | |
puts "Watching #{args.directory}" | |
require 'fssm' | |
FSSM.monitor do | |
path args.directory do | |
glob '**/*.haml' | |
update do |base, relative| | |
relative_base = Pathname.new(base).relative_path_from(Pathname.new(Dir.getwd)).to_s | |
sh "haml \"#{File.join(relative_base, relative)}\" \"#{File.join(relative_base, relative.chomp(File.extname(relative)))}\"" | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment