Monitoring File Changes and Getting Notified via Growl

I’ve been experimenting with Duby for faster computations in Opaz-PlugDK. I wanted to stay in the editor, triggering compilations with opt+s, and to be notified through Growl when something happens (in my case, compiling duby).

Here’s how to do it, using FSSM and Ruby-Growl.


# all cross-platforms gems in theory
require 'fssm'
require 'ruby-growl'

growl = Growl.new "localhost", "ruby-growl", ["Opaz-PlugDK"]

FSSM.monitor('plugins', '**/*.duby') do
  update do |base, relative|
    in_folder(base) do
      growl.notify "Opaz-PlugDK", relative, "Compiling..." 
      unless system("dubyc -java #{relative}")
        growl.notify "Opaz-PlugDK", relative, "Duby compile failed" 
      else
        growl.notify "Opaz-PlugDK", relative, "OK!" 
      end
    end
  end
end

I really love Ruby for those things :)

The comments system is brand new - don't be afraid to comment!

Etuis et housses pour iPad | Learnivore.com