sudo gem install ruby-gmail pit mime
Pitの設定
ruby -e 'require "pit";Pit.set("google", :data=>{"username"=>"yuiseki", "password"=>"kogaidan"})'
gmail.rb
#!/usr/bin/env ruby
require 'pit'
require 'gmail'
config = Pit.get('google')
gmail = Gmail.new(config['username'], config['password'])
important_and_unread = gmail.mailbox('[Gmail]/Important').count(:unread)
puts important_and_unread
ワンライナー
ruby -e 'require"pit"; require"gmail"; g=Pit.get("google"); p Gmail.new(g["name"], g["pass"]).label("[Gmail]/Important").count(:unread)'