Skip to content

Instantly share code, notes, and snippets.

@robertjwhitney
Created December 22, 2011 23:24
Show Gist options
  • Save robertjwhitney/1512298 to your computer and use it in GitHub Desktop.
Save robertjwhitney/1512298 to your computer and use it in GitHub Desktop.
stupid watcher is stupid
Gem::Specification.new do |s|
s.name = 'stupid-watcher'
s.version = '0.0.2'
s.platform = Gem::Platform::RUBY
s.author = 'Robert Whitney'
s.email = 'robertj.whitney@gmail.com'
s.summary = 'Stupid watcher is stupid'
s.description = 'Watches a file, does stuff when that file is updated.'
s.files = ['stupid_watcher.rb']
s.require_path = '.'
s.add_dependency('rake')
s.add_dependency('fssm')
end
# Everybody is stupid sometimes.
#
# In your Gemfile:
# gem 'stupid-watcher', :git => 'git://gist.github.com/1512298'
#
# In your Rakefile:
# require 'stupid_watcher'
#
# Then do something stupid like:
# rake stupid:watch index.haml "haml index.haml index.html"
#
namespace :stupid do
desc 'Watch a file and do some stuff when something happens to it.'
task :watch do
require 'fssm'
puts 'Watching for Changes'
FSSM.monitor do
path '.' do
glob "**/#{ARGV[1]}"
# available actions are: update, delete, or create
update do |base, relative|
puts "-"
puts "Detected change to: #{relative}"
system(ARGV[2])
puts "Ran: #{ARGV[2]}"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment