]> git.cworth.org Git - sup/commitdiff
Remove the people.txt mapping.
authorNicolas Pouillard <nicolas.pouillard@gmail.com>
Mon, 16 Mar 2009 18:37:38 +0000 (19:37 +0100)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 25 Mar 2009 14:58:47 +0000 (07:58 -0700)
lib/sup.rb
lib/sup/account.rb
lib/sup/contact.rb
lib/sup/person.rb

index 92ace7d8f0c3072dbb2a98393fe7fd8484945b4d..2a9995fa4d82f5cea84ba1520a5595d9ba6ce495 100644 (file)
@@ -53,7 +53,6 @@ module Redwood
   COLOR_FN   = File.join(BASE_DIR, "colors.yaml")
   SOURCE_FN  = File.join(BASE_DIR, "sources.yaml")
   LABEL_FN   = File.join(BASE_DIR, "labels.txt")
-  PERSON_FN  = File.join(BASE_DIR, "people.txt")
   CONTACT_FN = File.join(BASE_DIR, "contacts.txt")
   DRAFT_DIR  = File.join(BASE_DIR, "drafts")
   SENT_FN    = File.join(BASE_DIR, "sent.mbox")
@@ -115,7 +114,7 @@ module Redwood
   end
 
   def start
-    Redwood::PersonManager.new Redwood::PERSON_FN
+    Redwood::PersonManager.new
     Redwood::SentManager.new Redwood::SENT_FN
     Redwood::ContactManager.new Redwood::CONTACT_FN
     Redwood::LabelManager.new Redwood::LABEL_FN
@@ -130,7 +129,6 @@ module Redwood
   def finish
     Redwood::LabelManager.save if Redwood::LabelManager.instantiated?
     Redwood::ContactManager.save if Redwood::ContactManager.instantiated?
-    Redwood::PersonManager.save if Redwood::PersonManager.instantiated?
     Redwood::BufferManager.deinstantiate! if Redwood::BufferManager.instantiated?
   end
 
index f8ac0fcaf672ace7e2b72e4e666e2b56d7c6fc19..6f86129ca5d8997b0572f38512ba84a691ee4a7c 100644 (file)
@@ -5,8 +5,8 @@ class Account < Person
 
   def initialize h
     raise ArgumentError, "no name for account" unless h[:name]
-    raise ArgumentError, "no name for email" unless h[:name]
-    super h[:name], h[:email], 0, true
+    raise ArgumentError, "no email for account" unless h[:email]
+    super h[:name], h[:email]
     @sendmail = h[:sendmail]
     @signature = h[:signature]
   end
@@ -42,7 +42,6 @@ class AccountManager
     hash[:alternates] ||= []
 
     a = Account.new hash
-    PersonManager.register a
     @accounts[a] = true
 
     if default
index b0c272e8ece056b825ede520312f49d35de7d23c..bbb872f3d14b67b8e78ab2cf29ff1a1def2af2f4 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, :definitive => true
+        p = PersonManager.person_for addr
         @p2a[p] = aalias
         @a2p[aalias] = p unless aalias.nil? || aalias.empty?
       end
index fb58f23889d53503bce539407b2583767b40a49c..995620b65a1809954181612366b1791e12b848c8 100644 (file)
@@ -3,60 +3,24 @@ module Redwood
 class PersonManager
   include Singleton
 
-  def initialize fn
-    @fn = fn
-    @@people = {}
-
-    ## read in stored people
-    IO.readlines(fn).map do |l|
-      l =~ /^(.*)?:\s+(\d+)\s+(.*)$/ or next
-      email, time, name = $1, $2, $3
-      @@people[email] = Person.new name, email, time, false
-    end if File.exists? fn
-
+  def initialize
     self.class.i_am_the_instance self
   end
 
-  def save
-    File.open(@fn, "w") do |f|
-      @@people.each do |email, p|
-        next if p.email == p.name
-        next if p.name =~ /=/ # drop rfc2047-encoded, and lots of other useless emails. definitely a heuristic.
-        f.puts "#{p.email}: #{p.timestamp} #{p.name}"
-      end
-    end
-  end
-
-  def self.people_for s, opts={}
+  def self.people_for s
     return [] if s.nil?
-    s.split_on_commas.map { |ss| self.person_for ss, opts }
+    s.split_on_commas.map { |ss| self.person_for ss }
   end
 
-  def self.person_for s, opts={}
-    p = Person.from_address(s) or return nil
-    p.definitive = true if opts[:definitive]
-    register p
-  end
-  
-  def self.register p
-    oldp = @@people[p.email]
-
-    if oldp.nil? || p.better_than?(oldp)
-      @@people[p.email] = p
-    end
-
-    @@people[p.email].touch!
-    @@people[p.email]
+  def self.person_for s
+    Person.from_address(s)
   end
 end
 
-## don't create these by hand. rather, go through personmanager, to
-## ensure uniqueness and overriding.
 class Person 
-  attr_accessor :name, :email, :timestamp
-  bool_accessor :definitive
+  attr_accessor :name, :email
 
-  def initialize name, email, timestamp=0, definitive=false
+  def initialize name, email
     raise ArgumentError, "email can't be nil" unless email
     
     if name
@@ -67,26 +31,10 @@ class Person
     end
 
     @email = email.gsub(/^\s+|\s+$/, "").gsub(/\s+/, " ").downcase
-    @definitive = definitive
-    @timestamp = timestamp
-  end
-
-  ## heuristic: whether the name attached to this email is "real", i.e. 
-  ## we should bother to store it.
-  def generic?
-    @email =~ /no\-?reply/
-  end
-
-  def better_than? o
-    return false if o.definitive? || generic?
-    return true if definitive?
-    o.name.nil? || (name && name.length > o.name.length && name =~ /[a-z]/)
   end
 
   def to_s; "#@name <#@email>" end
 
-  def touch!; @timestamp = Time.now.to_i end
-
 #   def == o; o && o.email == email; end
 #   alias :eql? :==
 #   def hash; [name, email].hash; end