Skip to content

Commit

Permalink
Moved connection object like a global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nico01f committed Nov 23, 2015
1 parent 1e01991 commit 4a71818
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions gmail.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
require 'gmail'
require 'colorize'
require 'colorize'
require 'yaml'

ACCOUNT = YAML.load_file('account.yml') unless defined? ACCOUNT

ACCOUNT = YAML.load_file("account.yml") unless defined? ACCOUNT
G = Gmail.connect(ACCOUNT['email'], ACCOUNT['password'])

#Conecta con Gmail
def conecta(email, pass)
g = Gmail.connect(email, pass)
if g.logged_in? == true
puts "Connected!".green
else
puts "Doh! Not connected".red
end
def unread
n = G.inbox.count(:unread)
puts "There #{n} mails unread."
end


def info_credencial()
puts "Usuario: #{ACCOUNT['email']}"
password_hided = "*" * ACCOUNT['password'].length
puts "Password: #{password_hided}"
puts "============="
conecta(ACCOUNT['email'], ACCOUNT['password'])
def connected
if G.logged_in? == true
puts 'Connected!'.green
else
puts 'Doh! Not connected'.red
end
end

info_credencial()
puts "Exiting...".yellow


def info_credencial
puts "Usuario: #{ACCOUNT['email']}"
password_hided = '*' * ACCOUNT['password'].length
puts "Password: #{password_hided}"
puts '==============='
connected
unread
end

info_credencial
puts 'Exiting...'.yellow

0 comments on commit 4a71818

Please sign in to comment.