Subject: [sup-talk] [PATCH] New hook to allow formatting of message headers

From: [email-masked] (Colin Bell)
Date: Wed, 21 Nov 2007 15:26:40 +1100

Hi,

This patch allows you to format the headers shown in the Detailed
Headers view. Also attached is an example hook which will show the
email client and a spam header.

--
Col

-------------- next part --------------
A non-text attachment was scrubbed...
Name: headers.diff
Type: application/octet-stream
Size: 1193 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071121/a752531a/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: format-message-headers.rb
Type: application/octet-stream
Size: 202 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071121/a752531a/attachment-0001.obj

---

From: [email-masked] (William Morgan)
Date: Wed, 05 Dec 2007 10:12:16 -0800

Hi Colin,

> email client and a spam header.

I've applied this to SVN trunk, but (as I am wont to do) I tweaked it a
bit. I renamed it "detailed-headers" and changed the arguments so that
you get, and return, a hash rather than an array, which I think is a
little friendlier.

Here's the new version of your hook:

  $ cat /detailed-headers.rb 
  ["User-Agent", "X-Mailer", "X-Spam-Status"].map do |key|
    if message.raw_header =~ /^#{key}: (.*)$/i
      headers[key] = $1
    end
  end

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (William Morgan)
Date: Wed, 05 Dec 2007 10:36:44 -0800

Excerpts from William Morgan's message of Wed Dec 05 10:12:16 -0800 2007:
> bit.

Tweaked it a little more to use an OrderedHash and to just modify the
headers in place. This way the header ordering is not random.

Here's the new hook:

  $ cat detailed-headers.rb 
  %w(User-Agent X-Mailer X-Spam-Status).map do |key|
    if message.raw_header =~ /^#{key}: (.*)$/i
      headers[key] = $1
    end
  end

---

From: [email-masked] (Nicolas Pouillard)
Date: Thu, 06 Dec 2007 18:12:09 +0100

>   %w(User-Agent X-Mailer X-Spam-Status).map do |key|

Why use .map instead of .each the result seems not that useful.

-- 
Nicolas Pouillard aka Ertai

---

From: [email-masked] (Nicolas Pouillard)
Date: Thu, 06 Dec 2007 18:14:52 +0100

---

From: [email-masked] (William Morgan)
Date: Fri, 07 Dec 2007 10:10:13 -0800

> Why use .map instead of .each the result seems not that useful.

You're right, #each would have been probably more idiomatic.