[ANN] gmailer-0.0.5

(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.

CHANGE since 0.0.4
- add create_label, delete_label, rename_label, apply_label, delete_label
method
- add update_preference, get_preference method
- fix some bugs

The usage is very simple and compact like this:

GMailer.connect(name,pwd) do |g|
  #fetch
  g.fetch(:label=>"my_label") {|s|
        puts "Total # of conversations of my_label = " + s.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",
      :subject => "Hello There!",
      :body => "Hi...\n\nBlah blah blah~...",
      :files => ["./test.txt"]
   )

  # update_preference
  g.update_preference(:max_page_size=>50,
    :keyboard_shortcuts=>true,
    :indicators=>true,
    :display_language=>'en',
    :signature=>'This is a signature',
    :reply_to=>'return@foo.bar',
    :snippets=>true,
    :display_name=>'Display Name')

  # get preference
  pref = g.get_preference
  puts "Display language:#{pref['display_language']}, Max Page
Size:#{pref['max_page_size']}"

  #creating new labels
  g.create_label('label_name')

  #renaming existing labels
  g.rename_label('label_name','renamed_label')

  #deleting labels
  g.delete_label('label_name')

  #applying a label to a message
  g.apply_label(msgid,'label_name')

  #removing a label from a message
  g.remove_label(msgid,'label_name')

  # get labels
  labels = g.get_labels

  # get messages
  g.get_messages(:label=>labels[0]).each {|m|
     puts "Subject: #{m['subject']} / Snippet: #{m['snippet']}" if m['new?']
  }
end

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

Regards,

Park Heesob

(Daniel Amelang) #2

Hey Park, looks great. We can tell that you're putting a lot into this
lib. And aren't you supposed to be new to this ruby thing :slight_smile: You're
doing great.

Minor note: you have a number of methods that have the name 'get_this'
and 'get_that'. Consider leaving the 'get' out of the name. In other
languages, get methods are common to distinguish methods from public
members, but since everything is a method in ruby, people tend to
leave out the 'get'. So, basically, you'd have g.messages instead of
g.get_messages and g.labels instead of g.get_labels.

I put it on the tracker to make this suggestion 'official'.

Perhaps other people on this list can confirm/dispute that this would
be preferred.

Dan