Class: IMAPFlag

Inherits:
IMAPClient show all
Defined in:
lib/imap_flag.rb

Overview

Automatically flag your messages, yo!

aka part two of my Plan for Total Email Domination.

IMAPFlag flags messages you’ve responded to, messages you’ve written and messages in response to messages you’ve written.

If you unflag a message IMAPFlag is smart and doesn’t re-flag it.

I chose these settings because I find these messages interesting but don’t want to manually flag them. Why should I do all the clicking when the computer can do it for me?

Constant Summary collapse

AUTO_FLAG_KEYWORD =

IMAP keyword for automatically flagged messages

'IMAPFLAG_AUTO_FLAGGED'
MESSAGE_ID =

Message-Id query

'HEADER.FIELDS (MESSAGE-ID)'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IMAPClient

#connect, #find_mailboxes, #log, #mark, run, #search

Constructor Details

#initialize(options) ⇒ IMAPFlag

Creates a new IMAPFlag from options.

Options include:

+:Email:: Email address used for sending email

and all options from IMAPClient



53
54
55
56
# File 'lib/imap_flag.rb', line 53

def initialize(options)
  @email = options[:Email].split(/,\s*/)
  super
end

Class Method Details

.process_args(args) ⇒ Object

Handles processing of args.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/imap_flag.rb', line 32

def self.process_args(args)
  extra_options = { :Email => [nil, 'Email address not set'] }

  super args, extra_options do |opts, options|
    opts.on("-e", "--email EMAIL",
            "The email address you use to write email",
            "Default: #{options[:Email].inspect}",
            "Options file name: Email") do |email|
      options[:Email] = email
    end
  end
end

Instance Method Details

#runObject

Removes read, unflagged messages from all selected mailboxes…



61
62
63
# File 'lib/imap_flag.rb', line 61

def run
  super "Flagging messages", [:Flagged, AUTO_FLAG_KEYWORD]
end