]> git.cworth.org Git - sup/commitdiff
add Person#indexable_content and call this from Message#indexable_content
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 25 Jan 2008 04:33:41 +0000 (20:33 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Fri, 25 Jan 2008 04:38:25 +0000 (20:38 -0800)
Move the responsibility for determining what's indexable from an email
address to the Person class.

lib/sup/index.rb
lib/sup/message.rb
lib/sup/person.rb

index 0af66befb4c80d4acf2e2ebba2faa118c7ace5e6..cf2ac6dba1ddb4694415795573612a839e8df291 100644 (file)
@@ -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(" "),
     }
index 1466c0486ffeae5a3827b10c9394affda861c336..957143c8241eed9553392abe2fad6347af1e8739 100644 (file)
@@ -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 " "
index 5bd15a82856095f7582f7f7c109218931d23d514..7bce69554496a24308655c0c94d2dc6aa3f52986 100644 (file)
@@ -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