From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Fri, 02 Jan 2009 04:53:24 -0800 Subject: [sup-talk] a few sup newbie questions In-Reply-To: <1230630305-sup-9424@audrey> References: <1229548441-sup-531@audrey> <1229552235-sup-1046@entry> <1230571384-sup-9910@audrey> <1230573934-sup-5232@cabinet> <1230630305-sup-9424@audrey> Message-ID: <1230900174-sup-3836@entry> Reformatted excerpts from marianne.promberger+sup-talk's message of 2008-12-30: > Thanks. Any chance you could give me a pointer on how I can get it to > "return a person"? > > I've tried stuff like ... (in ~/.sup/hook/reply-from.rb) > > if message.to =~ /rubyforge/ > hook_reply_from = "My Name " > end > > if message.recipient_email =~ /rubyforge/ > return "My name " > end > > ... with different variations of patterns I'm testing for and with > different returned strings. You can create a person from a string by using this method: PersonManager.person_for "My name " You can give it any valid email address, and it takes care of returning the same Person object for duplicate addresses. Brief Ruby aside: If you're going to be doing a lot of such comparisons, you can structure the hook like: PersonManager.person_for case when message.to =~ /rubyforge/ "My name " when message.recipient_email =~ /rubyforge/ "My name " else "My name " end Note that the return statement isn't required (the final value of the hook is used), and multiple if-then's can be collapsed into a case statement. > Any pointers appreciated! (Including general information where I could > RTFM .. I looked at "sup -l" but that's pretty brief. Sadly, there's no good documentation for this right now beyond asking on the mailing list. (Well besides learning Ruby and looking at the code.) I'm sorry about that. -- William