Skip to content

Running Programmatically

rdp edited this page Sep 13, 2010 · 6 revisions

Example


require 'watchr'
script = Watchr::Script.new
script.watch('foo') { puts 'bar' } # this call doesn't block
contrl = Watchr::Controller.new(script, Watchr.handler.new)
contrl.run

The Script class’s tests use it that way: http://github.com/mynyml/watchr/blob/master/test/test_script.rb

You can also look at other projects that use watchr as a lib:

  • http://github.com/francois/autotestr
  • http://github.com/viking/autowatchr

How to mix with a glob


all = Dir['lib/*.rb'].join('|')
watch(all) { |md| }

How to traverse recursive subdirectories


watch('.*/abc.rb') do |md|; end

the .* automatically expands to include subdirectories.

Clone this wiki locally