[ANN] gmailer-0.0.2

(Park Heesob) #1

GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. You can make GMail as an online
backup system or as a virtual filesystem with this library.

Now usage is very simple and compact like this:

GMailer.connect(name,pwd) do |g|
  #fetch
  g.fetch(:label=>"my_label") {|snapshot|
        puts "Total # of conversations of my_label = " +
snapshot.box_total.to_s
  }

  #get contact
  g.fetch(:contact=>"freq").each do |item|
    puts "Name: #{item['name']} Email: #{item['email']}"
  end

  #send
  g.send(
      :to => "whoo@foo.bar",
      :subj => "Hello There!",
      :body => "Hi...\n\nBlah blah blah~...",
      :files => ["./test.txt"]
   )
end

Project:: http://rubyforge.org/projects/gmailutils/
Bugs:: http://rubyforge.org/tracker/?group_id=869

Regards,

Park Heesob

(Konstantin Levinski) #2

Hi!

Your library keeps getting cooler, the send() thing is especially
interesting...

I just wanted to add a note about
naming_conventions() vs. namingConventions(). You could add

def method_missing(sym, *args, &block)
  parts = sym.to_s.split("_"); throw NameError(sym) if parts.size < 2
  camel_case = parts[0]+(parts[1..-1].map(){|x| x.capitalize }).join()
  send(camel_case, *args, &block)
end

to the Gmailer class, and omit all aliases - it will autoforward
messages named with _ to camelCased ones.
(not sure if it is the RubyWay, though : )

(James Britt) #3

Park Heesob wrote:

GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. You can make GMail as an online
backup system or as a virtual filesystem with this library.

Now usage is very simple and compact like this:

GMailer.connect(name,pwd) do |g|
  #fetch
  g.fetch(:label=>"my_label") {|snapshot|
        puts "Total # of conversations of my_label = " + snapshot.box_total.to_s
  }

Very, very nice.

Do you have an example of reading an actual mail message?

Once I have a snapshot, how I get to individual mail?

Thanks,

James

···

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys