Class: Maildir::Queue
- Inherits:
-
Maildir
- Object
- Maildir
- Maildir::Queue
- Defined in:
- lib/maildir/queue.rb
Instance Method Summary collapse
-
#push(data) ⇒ Object
Adds a new message to the queue.
-
#requeue_stalled_messages(time) ⇒ Object
Returns a count of requeued messages.
-
#shift ⇒ Object
Finds a new message and marks it as being processed (i.e. moves message from new to cur).
-
#stalled_messages(time) ⇒ Object
Returns messages in cur that haven’t been modified since
time
.
Instance Method Details
#push(data) ⇒ Object
Adds a new message to the queue. Returns a Maildir::Message object
5 6 7 |
# File 'lib/maildir/queue.rb', line 5 def push(data) add(data) end |
#requeue_stalled_messages(time) ⇒ Object
Returns a count of requeued messages
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/maildir/queue.rb', line 27 def (time) (time).inject(0) do |count, | begin push(.data) .destroy count + 1 rescue Errno::ENOENT # Could not read message.data count end end end |
#shift ⇒ Object
Finds a new message and marks it as being processed (i.e. moves message from new to cur). Returns message if successful; nil if there are no new messages.
12 13 14 15 16 17 |
# File 'lib/maildir/queue.rb', line 12 def shift loop do = do_shift return unless false == end end |
#stalled_messages(time) ⇒ Object
Returns messages in cur that haven’t been modified since time
20 21 22 23 24 |
# File 'lib/maildir/queue.rb', line 20 def (time) list(:cur).select do || (mtime = .mtime) && mtime < time end end |