]> git.cworth.org Git - sup/commitdiff
Remove the now useless PersonManager
authorNicolas Pouillard <nicolas.pouillard@gmail.com>
Mon, 16 Mar 2009 18:38:17 +0000 (19:38 +0100)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 25 Mar 2009 15:03:22 +0000 (08:03 -0700)
Replace PersonManager.person_for by Person.from_address
and PersonManager.people_for by Person.from_address_list

lib/sup.rb
lib/sup/buffer.rb
lib/sup/contact.rb
lib/sup/index.rb
lib/sup/message.rb
lib/sup/modes/edit-message-mode.rb
lib/sup/modes/reply-mode.rb
lib/sup/modes/thread-view-mode.rb
lib/sup/person.rb

index 2a9995fa4d82f5cea84ba1520a5595d9ba6ce495..3afac5e012b0e9438434981fa2ebaae068ec9ea4 100644 (file)
@@ -114,7 +114,6 @@ module Redwood
   end
 
   def start
-    Redwood::PersonManager.new
     Redwood::SentManager.new Redwood::SENT_FN
     Redwood::ContactManager.new Redwood::CONTACT_FN
     Redwood::LabelManager.new Redwood::LABEL_FN
index 2143debd66166a571734d20cb927d3984ff42b08..c9e34b3595c62b82b64350163e0d547e127f95eb 100644 (file)
@@ -506,7 +506,7 @@ EOS
     answer = BufferManager.ask_many_emails_with_completions domain, question, completions, default
 
     if answer
-      answer.split_on_commas.map { |x| ContactManager.contact_for(x) || PersonManager.person_for(x) }
+      answer.split_on_commas.map { |x| ContactManager.contact_for(x) || Person.from_address(x) }
     end
   end
 
index bbb872f3d14b67b8e78ab2cf29ff1a1def2af2f4..51fd0e978c902f17485c8fcd81f20cc766b74157 100644 (file)
@@ -17,7 +17,7 @@ class ContactManager
       IO.foreach(fn) do |l|
         l =~ /^([^:]*): (.*)$/ or raise "can't parse #{fn} line #{l.inspect}"
         aalias, addr = $1, $2
-        p = PersonManager.person_for addr
+        p = Person.from_address addr
         @p2a[p] = aalias
         @a2p[aalias] = p unless aalias.nil? || aalias.empty?
       end
index 8af4edd89e9a3c04799ac3d7a6774097d52d1630..9addc6505bf1e20b7f84b18883b03ffc43f55604 100644 (file)
@@ -449,9 +449,9 @@ EOS
         t = @index[docid][:to]
 
         if AccountManager.is_account_email? f
-          t.split(" ").each { |e| contacts[PersonManager.person_for(e)] = true }
+          t.split(" ").each { |e| contacts[Person.from_address(e)] = true }
         else
-          contacts[PersonManager.person_for(f)] = true
+          contacts[Person.from_address(f)] = true
         end
       end
     end
index 33d801c3a81a30b5c51e5e15457f7b401873ce35..0ee46fb25d7ecbb97807910c9fa0785337bccc2c 100644 (file)
@@ -78,10 +78,10 @@ class Message
     
     @from =
       if header["from"]
-        PersonManager.person_for header["from"]
+        Person.from_address header["from"]
       else
         fakename = "Sup Auto-generated Fake Sender <sup@fake.sender.example.com>"
-        PersonManager.person_for fakename
+        Person.from_address fakename
       end
 
     Redwood::log "faking message-id for message from #@from: #{id}" if fakeid
@@ -105,9 +105,9 @@ class Message
       end
 
     @subj = header.member?("subject") ? header["subject"].gsub(/\s+/, " ").gsub(/\s+$/, "") : DEFAULT_SUBJECT
-    @to = PersonManager.people_for header["to"]
-    @cc = PersonManager.people_for header["cc"]
-    @bcc = PersonManager.people_for header["bcc"]
+    @to = Person.from_address_list header["to"]
+    @cc = Person.from_address_list header["cc"]
+    @bcc = Person.from_address_list header["bcc"]
 
     ## before loading our full header from the source, we can actually
     ## have some extra refs set by the UI. (this happens when the user
@@ -117,10 +117,10 @@ class Message
     @refs = (@refs + refs).uniq
     @replytos = (header["in-reply-to"] || "").scan(/<(.+?)>/).map { |x| sanitize_message_id x.first }
 
-    @replyto = PersonManager.person_for header["reply-to"]
+    @replyto = Person.from_address header["reply-to"]
     @list_address =
       if header["list-post"]
-        @list_address = PersonManager.person_for header["list-post"].gsub(/^<mailto:|>$/, "")
+        @list_address = Person.from_address header["list-post"].gsub(/^<mailto:|>$/, "")
       else
         nil
       end
@@ -391,7 +391,7 @@ private
     elsif m.header.content_type == "message/rfc822"
       payload = RMail::Parser.read(m.body)
       from = payload.header.from.first
-      from_person = from ? PersonManager.person_for(from.format) : nil
+      from_person = from ? Person.from_address(from.format) : nil
       [Chunk::EnclosedMessage.new(from_person, payload.to_s)] +
         message_to_chunks(payload, encrypted)
     else
index cc6e7af4a482d46dfefd74f5034846c81035620d..31aa8972766c34d17ae8f9cda5379b5363af559f 100644 (file)
@@ -321,8 +321,8 @@ protected
 
     ## do whatever crypto transformation is necessary
     if @crypto_selector && @crypto_selector.val != :none
-      from_email = PersonManager.person_for(@header["From"]).email
-      to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| PersonManager.person_for(p).email }
+      from_email = Person.from_address(@header["From"]).email
+      to_email = [@header["To"], @header["Cc"], @header["Bcc"]].flatten.compact.map { |p| Person.from_address(p).email }
 
       m = CryptoManager.send @crypto_selector.val, from_email, to_email, m
     end
@@ -412,7 +412,7 @@ private
   end
 
   def sig_lines
-    p = PersonManager.person_for(@header["From"])
+    p = Person.from_address(@header["From"])
     from_email = p && p.email
 
     ## first run the hook
index 4e08e8e9158bead401d437d4933d1a3ed0c42b81..c1c542b373e30bb74061e0ddfe502eddb31f5bc2 100644 (file)
@@ -63,7 +63,7 @@ EOS
       if hook_reply_from
         hook_reply_from
       elsif @m.recipient_email && AccountManager.is_account_email?(@m.recipient_email)
-        PersonManager.person_for(@m.recipient_email)
+        Person.from_address(@m.recipient_email)
       elsif(b = (@m.to + @m.cc).find { |p| AccountManager.is_account? p })
         b
       else
index f4d4232073e0126eef807e87170611c6840f344d..f27f00d81ec28bb7563dac53e2ccfd406ae93e2f 100644 (file)
@@ -149,7 +149,7 @@ EOS
   def subscribe_to_list
     m = @message_lines[curpos] or return
     if m.list_subscribe && m.list_subscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
-      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [Person.from_address($1)], :subj => $3
     else
       BufferManager.flash "Can't find List-Subscribe header for this message."
     end
@@ -158,7 +158,7 @@ EOS
   def unsubscribe_from_list
     m = @message_lines[curpos] or return
     if m.list_unsubscribe && m.list_unsubscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
-      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+      ComposeMode.spawn_nicely :from => AccountManager.account_for(m.recipient_email), :to => [Person.from_address($1)], :subj => $3
     else
       BufferManager.flash "Can't find List-Unsubscribe header for this message."
     end
index 995620b65a1809954181612366b1791e12b848c8..ca703519031dfb6fc539e0f934a11843cf39a96b 100644 (file)
@@ -1,22 +1,5 @@
 module Redwood
 
-class PersonManager
-  include Singleton
-
-  def initialize
-    self.class.i_am_the_instance self
-  end
-
-  def self.people_for s
-    return [] if s.nil?
-    s.split_on_commas.map { |ss| self.person_for ss }
-  end
-
-  def self.person_for s
-    Person.from_address(s)
-  end
-end
-
 class Person 
   attr_accessor :name, :email
 
@@ -110,6 +93,11 @@ class Person
     Person.new name, email
   end
 
+  def self.from_address_list ss
+    return [] if ss.nil?
+    ss.split_on_commas.map { |s| self.from_address s }
+  end
+
   def indexable_content
     [name, email, email.split(/@/).first].join(" ")
   end