sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 5e241b83742edc33af69157a38f6326d0305df18
parent 58421e994205c8b2870ff57ed0a6a13f92c21829
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Sun,  6 Jan 2008 11:25:03 -0800

add a :regexen section of an account in config.yaml for email regexes

Diffstat:
M lib/sup/account.rb | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/sup/account.rb b/lib/sup/account.rb
@@ -20,6 +20,7 @@ class AccountManager
   def initialize accounts
     @email_map = {}
     @accounts = {}
+    @regexen = {}
     @default_account = nil
 
     add_account accounts[:default], true
@@ -53,11 +54,21 @@ class AccountManager
       next if @email_map.member? email
       @email_map[email] = a
     end
+
+    hash[:regexen].each do |re|
+      @regexen[Regexp.new(re)] = a
+    end if hash[:regexen]
   end
 
   def is_account? p; is_account_email? p.email end
-  def account_for email; @email_map[email] end
   def is_account_email? email; !account_for(email).nil? end
+  def account_for email
+    if(a = @email_map[email])
+      a
+    else
+      @regexen.argfind { |re, a| re =~ email && a }
+    end
+  end
 end
 
 end