1#
2# dcdbiff.rb - distributed cdbiff (client)
3#  * original: cdbiff by Satoru Takabayashi <http://namazu.org/~satoru/cdbiff>
4
5require 'drb/drb'
6require 'drb/eq'
7
8class Notify
9  include DRbUndumped
10
11  def initialize(biff, command)
12    @biff = biff
13    @command = command
14
15    @biff.add_observer(self)
16  end
17
18  def update(filename, time)
19    p [filename, time] if $DEBUG
20    system(@command)
21  end
22
23  def done
24    begin
25      @biff.delete_observer(self)
26    rescue
27    end
28  end
29end
30
31def main
32  command = 'eject'
33  uri = 'druby://localhost:19903'
34
35  DRb.start_service
36  biff = DRbObject.new(nil, uri)
37  notify = Notify.new(biff, command)
38
39  trap("INT"){ notify.done }
40  DRb.thread.join
41end
42
43main
44