From 8b1ceac46867999fbaf2793cb13f6e9cfe6a86c3 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Mon, 5 Nov 2007 02:42:23 +0000 Subject: [PATCH] added before-add-message hook, thanks to Marcus Williams git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@666 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- lib/sup/hook.rb | 16 +++++++++++++--- lib/sup/poll.rb | 9 ++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb index dae2ce5..f1157ca 100644 --- a/lib/sup/hook.rb +++ b/lib/sup/hook.rb @@ -12,6 +12,7 @@ class HookManager ## this is basically fail-fast. class HookContext def initialize name + @__say_id = nil @__name = name @__locals = {} end @@ -30,8 +31,12 @@ class HookManager end def say s - @__say_id = BufferManager.say s, @__say_id - BufferManager.draw_screen + if BufferManager.instantiated? + @__say_id = BufferManager.say s, @__say_id + BufferManager.draw_screen + else + log s + end end def log s @@ -39,7 +44,12 @@ class HookManager end def ask_yes_or_no q - BufferManager.ask_yes_or_no q + if BufferManager.instantiated? + BufferManager.ask_yes_or_no q + else + print q + gets.chomp.downcase == 'y' + end end def __binding diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb index f36c37f..e124af1 100644 --- a/lib/sup/poll.rb +++ b/lib/sup/poll.rb @@ -5,6 +5,12 @@ module Redwood class PollManager include Singleton + HookManager.register "before-add-message", < m Index.sync_message m, docid, entry UpdateManager.relay self, :add, m unless entry rescue MessageFormatError => e -- 2.45.2