From: Gregor Hoffleit <gregor@hoffleit.de>
To: sup-talk@rubyforge.org
Subject: [sup-talk] Ruby question: before-add-message.rb and adding multiple labels at once
Date: Wed, 13 Jan 2010 14:13:18 +0100 [thread overview]
Message-ID: <1263386714-sup-5331@sam.mediasupervision.de> (raw)
In order to keep before-add-message.rb readable, I was using one-line
filters like:
message.add_label "ad apple" if message.from.email =~ /@insideapple.apple.com/
message.add_label "ad amazon" if message.from.email =~ /promotion.*@amazon.com/
message.add_label "list sup" if message.subj =~ /\[sup-talk\]/
message.add_label "list sup-devel" if message.subj =~ /\[sup-devel\]/
That seemed to work, somehow. Only now I realized that message.add_label
in fact only takes a single label as argument.
Is it true that I have to change the above syntax into the much more
verbose:
if message.subj =~ /\[sup-devel\]/
message.add_label :list
message.add_label :"sup-devel"
end
Removing a message from the inbox ("message.remove_label :inbox") while
applying a label leads to a similar 'code bloat'.
Also, it took me a while to realize that errors in before-add-message.rb
won't lead to a visible error message, but that before-add-message.rb
just silently quits.
The examples in http://sup.rubyforge.org/wiki/wiki.pl?Hooks are a very
good start.
Still, perhaps somebody with robust Ruby skills could add in a section
about the exact usage of message.add_label and message.remove_label,
e.g.:
- What's the difference between "label" and :label?
- Can I use multiple labels in one invocation?
- How about dashes in labels? Is :sup-devel valid, or should I use
:"sup-devel"?
- How about spaces in label?
- How about "-inbox"? Does it work?
Regards,
Gregor Hoffleit
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next reply other threads:[~2010-01-13 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 13:13 Gregor Hoffleit [this message]
2010-01-13 15:49 ` Eric Sherman
2010-01-15 15:51 ` Gregor Hoffleit
2010-01-17 15:29 ` William Morgan
2010-01-15 17:01 Gregor Hoffleit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1263386714-sup-5331@sam.mediasupervision.de \
--to=gregor@hoffleit.de \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox