Created
December 22, 2011 23:24
-
-
Save robertjwhitney/1512298 to your computer and use it in GitHub Desktop.
stupid watcher is stupid
This file contains 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
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 = '[email protected]' | |
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 |
This file contains 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
# 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