Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] new in svn: hook system and polling hooks
@ 2007-08-19  1:03 William Morgan
  2007-08-20  1:30 ` William Morgan
  0 siblings, 1 reply; 2+ messages in thread
From: William Morgan @ 2007-08-19  1:03 UTC (permalink / raw)


I've added a system for hooking user-created code into Sup. (Finally!)

Sup hooks take the form of Ruby scripts, placed in ~/.sup/hooks. Each
hook corresponds to a file in that directory. To see documentation on
the available hooks, just run "sup -l".

Hooks are passed information in the form of local "variables" (really
method calls, so don't try assigning to them). There are two
Sup-specific functions they can call, "say" and "log". "say" will write
a temporary message to the bottom portion of the screen, which is erased
when the hook stops executing. "log" will write a message to the sup
log.

There are only two hooks right now, before-poll and after-poll.
Before-poll should satisfy the desire of fetchmail users and after-poll
should satisfy the desire of all xbiff users.

Future work:
Allow sharing of information between successive invocations via instance
variables; and add lots of hooks (some kind of mime handler is probably
my immediate goal.)

-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [sup-talk] new in svn: hook system and polling hooks
  2007-08-19  1:03 [sup-talk] new in svn: hook system and polling hooks William Morgan
@ 2007-08-20  1:30 ` William Morgan
  0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2007-08-20  1:30 UTC (permalink / raw)


Excerpts from William Morgan's message of Sat Aug 18 18:03:57 -0700 2007:
> Future work:
> Allow sharing of information between successive invocations via instance
> variables

Ok, this is in. Here's how I'm handling fetchmail invocation. In
hooks/before-poll.rb:

  if (@last_fetchmail_time || Time.at(0)) < Time.now - 60
    say "Running fetchmail..."
    system "fetchmail >& /dev/null"
  end
  @last_fetchmail_time = Time.now


-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-20  1:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-19  1:03 [sup-talk] new in svn: hook system and polling hooks William Morgan
2007-08-20  1:30 ` William Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox