From: William Morgan Date: Fri, 25 Jan 2008 04:33:41 +0000 (-0800) Subject: add Person#indexable_content and call this from Message#indexable_content X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=d09d4afbeb035c497f3682559ecb30ab42c009c6;p=sup add Person#indexable_content and call this from Message#indexable_content Move the responsibility for determining what's indexable from an email address to the Person class. --- diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 0af66be..cf2ac6d 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -186,8 +186,8 @@ EOS :body => m.indexable_content, :snippet => snippet, :label => m.labels.uniq.join(" "), - :from => m.from ? m.from.email : "", - :to => (m.to + m.cc + m.bcc).map { |x| x.email }.join(" "), + :from => m.from ? m.from.indexable_content : "", + :to => (m.to + m.cc + m.bcc).map { |x| x.indexable_content }.join(" "), :subject => wrap_subj(m.subj), :refs => (m.refs + m.replytos).uniq.join(" "), } diff --git a/lib/sup/message.rb b/lib/sup/message.rb index 1466c04..957143c 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -252,10 +252,10 @@ EOS def indexable_content load_from_source! [ - from && "#{from.name} #{from.email}", - to.map { |p| "#{p.name} #{p.email}" }, - cc.map { |p| "#{p.name} #{p.email}" }, - bcc.map { |p| "#{p.name} #{p.email}" }, + from && from.indexable_content, + to.map { |p| p.indexable_content }, + cc.map { |p| p.indexable_content }, + bcc.map { |p| p.indexable_content }, chunks.select { |c| c.is_a? Chunk::Text }.map { |c| c.lines }, Message.normalize_subj(subj), ].flatten.compact.join " " diff --git a/lib/sup/person.rb b/lib/sup/person.rb index 5bd15a8..7bce695 100644 --- a/lib/sup/person.rb +++ b/lib/sup/person.rb @@ -162,6 +162,10 @@ class Person 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