Watchful ======== A shell script for busy web developers What? ----- Watchful is a lightweight tool that runs command line tools on updated files. It was built by a web developer who got seriously tired of managing a whole range of CLI minification, translation, and compression tools on his CSS and Javascript. You can think of Watchful as kind of recursive, specialized [Rake](http://rake.rubyforge.org/): you tell it which tools to run on which files, then fire it off in your current project directory and go back to your text editor. When you save a change to a relevant file under that directory, Watchful will run the proper tool on it. If you are on OS X and have [Growl](http://growl.info/) installed, you’ll get a notification. Where? ------ Watchful is currently hosted on [GitHub](http://github.com): [http://github.com/kemitchell/watchful](http://github.com/kemitchell/watchful) Please feel free to fork me! Eventually, Watchful will be available as a Ruby Gem: sudo gem install watchful How? ---- All configuration is done in pure Ruby. Configurations are created by subclassing `Watchful::Configuration` in “watchful” files. An example follows: require 'watchful/configuration' class MyConfiguration < Watchful::Configuration description 'LESS CSS and YUI Compressor' # actions are applied in order, hence Less is defined before YUI action :name => "Less CSS", :in => ".less", # The extension of files to use as input :out => ".css", # Extension to replace the above for output files :command => "lessc %s %s", # The command to create output files from input files # Currently the command is built using sprintf. # In the future all of the above will also take blocks. # For now, the first %s is the full input path, # and the second the full output path. :dependencies => ['less'] # If “less” isn’t found in PATH, this action will be disabled. action :name => 'YUI Compressor', :in => '.css', :out => '.min.css', # Notice that Watchful computers extensions differently than basename # Namely, the extension is anything in the file name from the # first period onward. :command => 'java -jar /usr/local/utils/yuicompressor-2.4.2.jar --type css --charset utf-8 %s -o %s', :dependencies => ['java', '/usr/local/utils/yuicompressor-2.4.2.jar'] # Dependencies can be programs (e.g. “java”), or full file paths. end When Watchful is started, it searches in the following locations (in the following order) for files called “watchful” and loads them: 1. In the directory Watchful is told to monitor 2. In the current user’s home directory If no such files are found, Watchful will use the default configuration, which searches your PATH for tools it recognizes. If your tool isn't listed in [http://github.com/kemitchell/watchful/blob/master/lib/watchful/defaultconfiguration.rb](defaultconfiguration.rb) and you would like it to be, please fork the project on github or send me a patch. I would be happy to include any tools with current stable or Beta releases.