Sha256: c61e617a5d3892fd8a53e1c74338e605405e6546d91820117ca2ebba04d4174b

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'net/imap'
require 'net/smtp'
require 'mail'
require 'date'
require 'time'
require 'gmail_xoauth'

if RUBY_VERSION < "1.8.7"
  require "smtp_tls"
end

class Object
  def to_imap_date
    Date.parse(to_s).strftime("%d-%B-%Y")
  end
end

module Gmail
  autoload :Version, "gmail/version"
  autoload :Client,  "gmail/client"
  autoload :Labels,  "gmail/labels"
  autoload :Mailbox, "gmail/mailbox"
  autoload :Message, "gmail/message"

  class << self
    def new(email, token, secret, consumer_key, consumer_secret, options={}, &block)
      client = Client.new(email, token, secret, consumer_key, consumer_secret, options)
      client.connect and client.login
      if block_given?
        yield client
        client.logout
      end
      client
    end
    alias :connect :new
    
    def new!(email, token, secret, consumer_key, consumer_secret, options={}, &block)
      client = Client.new(email, token, secret, consumer_key, consumer_secret, options)
      client.connect! and client.login!
      if block_given?
        yield client
        client.logout
      end
      client
    end
    alias :connect! :new!
  end # << self
end # Gmail

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gmail_oauth-0.1.3 lib/gmail.rb
gmail_oauth-0.1.2 lib/gmail.rb
gmail_oauth-0.1.1 lib/gmail.rb