Class: Evernotable::Command::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/evernotable/command/auth.rb

Instance Method Summary collapse

Methods inherited from Base

#authenticate_user, #initialize, #invoke_client, #note_client

Methods included from Utilities

#display, #encrypt_key, #error, #format_with_bang, #output_with_bang, #read_from_file, #wrap_enml, #write_to_file

Constructor Details

This class inherits a constructor from Evernotable::Command::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/evernotable/command/auth.rb', line 22

def method_missing(method_name, *args)
  case method_name
  when :help then
    display '--------------------------------------------'
    display '# authenticate 
    evernotable auth login
    evernotable auth logout'
    display '--------------------------------------------'
  end
end

Instance Method Details

#loginObject



5
6
7
8
9
10
11
# File 'lib/evernotable/command/auth.rb', line 5

def 
  user = [] << @highline.ask("Enter your Evernote username: ")
  user << @highline.ask("Enter your Evernote password: ") { |q| q.echo = "*" }
  authenticate_user(user)
  write_to_file credentials_file, user.join('/')
  display "You were successfully authenticated."
end

#logoutObject



13
14
15
16
17
18
19
20
# File 'lib/evernotable/command/auth.rb', line 13

def logout
  if File.exist?(credentials_file)
    File.delete(credentials_file)
    display "You were successfully logged out."
  else
    output_with_bang "You are not logged in."
  end
end