Created
July 26, 2011 16:11
-
-
Save noeticpenguin/1107131 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
require 'rubygems' | |
require 'fssm' | |
require 'thor' | |
class Watcher < Thor | |
include Thor::Actions | |
def initialize(*args) | |
super | |
end | |
desc "watch", "watch files on save and compile them" | |
method_option :cp, :type => :boolean, :desc => "cp the files to the server" | |
def watch | |
FSSM.monitor do | |
dir = "/path" | |
path '.' do | |
update do |b, r| | |
if File.fnmatch('**.haml', r) | |
base = File.basename("#{r}", ".haml") + ".html" | |
puts "HAML #{r} to #{base}" | |
`haml --no-escape-attrs #{r} > #{base}` | |
%x[cp #{base} #{dir}/symbolic.keyboard.jsp] if options[:cp] | |
elsif File.fnmatch('**.sass', r) | |
base = File.basename("#{r}", ".sass") + ".css" | |
puts "*Sass: #{r} to #{base}" | |
%x[sass #{r} #{base}] | |
%x[cp #{base} #{dir}/css/symbolic.keyboard.css] if options[:cp] | |
elsif File.fnmatch('**.coffee', r) | |
base = File.basename("#{r}", ".coffee") + ".js" | |
puts "**Coffee: #{r} to #{base}" | |
%x[coffee -bc #{r}] | |
%x[docco #{r}] | |
%x[cp #{base} #{dir}/javascript/symbolic.keyboard.js] if options[:cp] | |
end | |
end | |
end | |
end | |
end | |
end | |
Watcher.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment