* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / sample / drb / dcdbiff.rb
blob6a24680c33fc56781b4514e62ba3fd6cf56cd727
2 # dcdbiff.rb - distributed cdbiff (client)
3 #  * original: cdbiff by Satoru Takabayashi <http://namazu.org/~satoru/cdbiff>
5 require 'drb/drb'
6 require 'drb/eq'
8 class Notify
9   include DRbUndumped
11   def initialize(biff, command)
12     @biff = biff
13     @command = command
15     @biff.add_observer(self)
16   end
18   def update(filename, time)
19     p [filename, time] if $DEBUG
20     system(@command)
21   end
23   def done
24     begin
25       @biff.delete_observer(self)
26     rescue
27     end
28   end
29 end
31 def main
32   command = 'eject'
33   uri = 'druby://localhost:19903'
35   DRb.start_service
36   biff = DRbObject.new(nil, uri)
37   notify = Notify.new(biff, command)
39   trap("INT"){ notify.done }
40   DRb.thread.join
41 end
43 main