def save
File.open(@fn, "w") do |f|
@@people.each do |email, p|
+ next if p.email == p.name
+ next if p.email =~ /=/ # drop rfc2047-encoded, and lots of other useless emails. definitely a heuristic.
f.puts "#{p.email}: #{p.timestamp} #{p.name}"
end
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)
def full_address
if @name && @email
- if @name =~ /"/
+ if @name =~ /[",@]/
"#{@name.inspect} <#@email>" # escape quotes
else
"#@name <#@email>"
Person.new name, email
end
+
+ def eql? o; email.eql? o.email end
+ def hash; email.hash end
end
end