commit d09d4afbeb035c497f3682559ecb30ab42c009c6
parent 360e105c0d08a5765b23c37b2026bff586b3d136
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Thu, 24 Jan 2008 20:33:41 -0800
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.
Diffstat:
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git 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
@@ -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
@@ -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