Skip to content

Instantly share code, notes, and snippets.

@nissuk
Created November 11, 2011 17:00
Show Gist options
  • Save nissuk/1358544 to your computer and use it in GitHub Desktop.
Save nissuk/1358544 to your computer and use it in GitHub Desktop.
HAML, SCSS, CoffeeScriptの自動コンパイル実験(watchr)
# based on http://www.223soft.net/35
class W
def initialize(opts)
@dest_dir = opts[:dest_dir]
end
def exec(cmd, md)
p = Pathname.new(@dest_dir + "/" + File.dirname(md[0]))
p.mkdir if not p.exist?
puts "compiled to #{md[0]}" if system(cmd)
end
end
dest_dir = "dest"
w = W.new(:dest_dir => dest_dir)
watch("(.*)\.haml") {|md|
w.exec("haml -f html5 #{md[0]} -E UTF-8 #{dest_dir}/#{md[1]}.html", md)
}
watch("(.*)\.scss") {|md|
w.exec("sass --scss #{md[0]} #{dest_dir}/#{md[1]}.css", md)
}
watch("(.*)\.coffee") {|md|
w.exec("coffee -o #{dest_dir} -c #{md[0]}", md)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment