Class: Fbapp::Drivers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/fbapp/drivers/base.rb

Direct Known Subclasses

Celerity, Mechanize

Instance Method Summary collapse

Instance Method Details

#get_or_cache_credentialsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fbapp/drivers/base.rb', line 7

def get_or_cache_credentials
  credfile = File.expand_path("~/fbapp")
  if File.exist?(credfile)
    email, pass = File.read(credfile).split("\n")
  else
    highline = HighLine.new
    email    = highline.ask("Email:    ")
    pass     = highline.ask("Password: ") { |q| q.echo = false }

    File.open(credfile, "w+") do |f|
      f.puts email
      f.puts pass
    end
  end

  return [email, pass]
end