Class: EyeMap

Inherits:
Object
  • Object
show all
Defined in:
lib/eyemap/eyemap.rb

Overview

EyeMap - an Objective interface to IMAP

Those who have worked with IMAP should know that the servers that implement it have a world of hurt coming to them, and that’s why they don’t implement every single part of the spec right. There are too many SHOULD’s and not enough MUST’s.

Anyways, our solution to this model is pretty simple. Provide drivers for the IMAP servers, which control their quirks, and present a unified interface in which the user does not have to care about the nasty underpinnings and can just get work done.

EyeMap is a part of the Re: Mail project.

To connect to an IMAP store, use the EyeMap.connect() call.

To figure out what to do after you’ve got your connection, look at the methods in EyeMap::Driver.

Defined Under Namespace

Classes: Driver, Exception, Folder, Message, Search

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEyeMap

Returns a new instance of EyeMap.



227
228
229
# File 'lib/eyemap/eyemap.rb', line 227

def initialize
    throw EyeMap::Exception::BadCall.new("Use EyeMap.connect() to connect to a driver")
end

Class Method Details

.connect(*args) ⇒ Object

Use a driver to connect to an IMAP store.

The arguments here are a collection of EyeMap::Capabilities items. If there are any driver-specific items, those will be noted for that driver. Please read the documentation for both.

Capabilities are /driver/ capabilities and not IMAP capabilities in the traditional sense (although there are a few correlations).

You will generally not work with these directly, outside of passing them to the EyeMap.connect() call, or if you’re writing a driver.

All items are symbols, so while not listed here, they start with a colon:

  • delimiter: The folder delimiter that the IMAP server uses.

  • folder_class: The class that new folder objects are created from.

  • message_class: The class that new message objects are created from.

  • driver_class: Calculated from ‘driver’, this is the class of the driver that is being used.

  • driver: The ‘text’ name of the driver, used to locate the driver.

  • user: The username to connect to the IMAP store with.

  • password: The password to connect to the IMAP store with.

  • host: The host of the IMAP store.

  • ssl: Set to true to use SSL to connect to the IMAP store.

  • auth_mech: The authentication mechanism to use.

  • verify_ssl: Verify our SSL connection?

  • port: The port to use in our IMAP connection.

  • cert: The certificate to use (SSL only)



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/eyemap/eyemap.rb', line 201

def EyeMap.connect(*args)
    args = args[0]

    if ! args[:driver]
        args[:driver] = 'auto'
    end

    # require the appropriate driver from the driver/ directory
    begin
        require "eyemap/drivers/#{args[:driver]}"
    rescue LoadError => e
        throw EyeMap::Exception::InvalidDriver.new("Driver '#{args[:driver]}' doesn't exist or isn't working properly.")
    end

    # fetch the driver's class object from the symbol table (Kernel is hte root level)
    # and store it in the :driver_class argument.
    args[:driver_class] = EyeMap::Driver.const_get(Inflector.camelize(args[:driver]).to_sym)

    # call, connect, and return the value of the constructor
    obj = args[:driver_class].new(args)

    obj.connect()
    return obj

end