Module: Gurgitate::Deliver::MBox

Defined in:
lib/gurgitate/deliver/mbox.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check_mailbox(mailbox) ⇒ Object

Checks to see if mailbox is an mbox mailbox

mailbox

A string containing the path of the mailbox to save the message to. If it is of the form “=mailbox”, it saves the message to Maildir/mailbox. Otherwise, it simply saves the message to the file mailbox.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gurgitate/deliver/mbox.rb', line 16

def self::check_mailbox mailbox

    begin
        if File.stat(mailbox).file? then
            return MBox
        else
            return nil
        end
    rescue Errno::ENOENT
        return nil
    end
end

Instance Method Details

#deliver_message(mailbox) ⇒ Object

Delivers the message to mailbox

mailbox

A string containing the path of the mailbox to save the message to. If it is of the form “=mailbox”, it saves the message to Maildir/mailbox. Otherwise, it simply saves the message to the file mailbox.



35
36
37
38
39
40
41
42
43
44
# File 'lib/gurgitate/deliver/mbox.rb', line 35

def deliver_message mailbox
    File.open(mailbox,File::WRONLY |
                      File::APPEND |
                      File::CREAT) do |f|
        f.flock(File::LOCK_EX)
        message=(if f.stat.size > 0 then "\n" else "" end) + to_mbox
        f.print message
        f.flock(File::LOCK_UN)
    end
end