lib/sup/person.rb in sup-0.4 vs lib/sup/person.rb in sup-0.5
- old
+ new
@@ -7,11 +7,11 @@
@fn = fn
@@people = {}
## read in stored people
IO.readlines(fn).map do |l|
- l =~ /^(.*)?:\s+(\d+)\s+(.*)$/ or raise "can't parse: #{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
self.class.i_am_the_instance self
@@ -19,11 +19,11 @@
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.
+ 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
@@ -158,9 +158,13 @@
else
[nil, s]
end
Person.new name, email
+ end
+
+ def indexable_content
+ [name, email, email.split(/@/).first].join(" ")
end
def eql? o; email.eql? o.email end
def hash; email.hash end
end