Skip to content

Instantly share code, notes, and snippets.

@dgoodlad
Created March 3, 2010 10:43
Show Gist options
  • Save dgoodlad/320516 to your computer and use it in GitHub Desktop.
Save dgoodlad/320516 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'fsevents'
require 'json'
ignores = JSON.parse(File.read(".couchappignore")).map { |s| Regexp.new(s) }
ignores.push /(^.git|.DS_Store|\.swp$|\.couchappignore)/
appdir = File.expand_path(File.dirname(__FILE__))
def build_css
puts "------ #{Time.now.strftime("%k:%M")} Building CSS"
puts `compass -c compass-config.rb --update`
end
def push_app
puts "------ #{Time.now.strftime("%k:%M")} Pushing"
`couchapp push`
end
stream = FSEvents::Stream.watch(File.dirname(__FILE__)) do |events|
appfiles = events.modified_files.delete_if { |f|
stripped = f.gsub(appdir + "/", "")
ignores.any? { |regex| regex.match stripped }
}
build_css if appfiles.any? { |path| /\.sass$/ =~ path }
push_app if appfiles.size > 0
end
stream.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment