GithubHelp home page GithubHelp logo

dm-imap-adapter's Introduction

IMAP Adapter for DataMapper
===========================

There exist other implementations of an imap adapter but they are either not 0.10 compatible or I couldn't find a working version. Also, I am picky and want to do this right.

Philosophy
==========

A resource is a mailbox. So you will probably end up with a Gmail::Inbox and a Gmail::Trash. To move an item to the trash you would resource.move_to(Gmail::Trash) [not implemented yet]. Various Types are provided to make it easier to work with the different things like From and To and CC and all of that. These also help with the queries [not implemented yet].

Specs
=====

I use bacon. It's the best testing library that exists.

gem install bacon

bacon spec/dm-imap-adapter_spec.rb

or use autotest (although I'm not sure I got that setup perfectly).

The specs currently assume you have a test account with test as the password on localhost which has an INBOX. All emails in this inbox will be deleted, just like a test database.

How to use
==========

gem install gemcutter          # unless you already have
gem tumble                     # unless you already have
gem install dm-imap-adapter

Check the specs!

Also, do this for your model:

class Inbox
  include DataMapper::Resource
  include DataMapper::Types::Imap
  
  def self.default_repository_name
    :test_inbox
  end

  property :uid, UID, :key => true # do we need :key here since UID is a serial?
  property :message_id, MessageId
  property :subject, Subject
  property :sender, Sender
  property :from, From
  property :to, To
  property :body, BodyText
  property :raw_body, Body
  property :date, InternalDate
  property :envelope_date, EnvelopeDate
  property :size, Size
  property :sequence, Sequence
end

How can I help?
===============

Glad you asked!

There are lots of things that don't work yet, mostly because I don't need them to (all I need is #all and #destroy). Here are the big things that don't work yet:

* #update
* #create should use update to set any attributes that can't be set during the initial append to the mailbox
* Flags - a Type needs to be created that manages an array of symbols. Maybe base it off the Enum?
* Searching should actually use the uid_search method and not rely on the in memory query filter. If you got 1000 emails in your inbox your currently screwed.
* Figuring out why I had to hack net/imap so much to support dovecot on my machine. Seems strange that I had to open the class like that.
* Extend other net/imap structs like the Address one.
* Better specs!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.