Class: Evernotable::Command::Base
- Inherits:
-
Object
- Object
- Evernotable::Command::Base
show all
- Includes:
- Utilities
- Defined in:
- lib/evernotable/command/base.rb
Instance Method Summary
collapse
Methods included from Utilities
#display, #encrypt_key, #error, #format_with_bang, #output_with_bang, #read_from_file, #wrap_enml, #write_to_file
Constructor Details
#initialize(params = [], env = :sandbox) ⇒ Base
Returns a new instance of Base.
10
11
12
13
14
15
|
# File 'lib/evernotable/command/base.rb', line 10
def initialize(params=[], env=:sandbox)
@config = YAML.load(File.read('lib/evernotable_config.yml'))
@env = env.to_s
@args = params.map {|p| p.strip}
@highline = HighLine.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
40
41
|
# File 'lib/evernotable/command/base.rb', line 40
def method_missing(method_name, *args)
end
|
Instance Method Details
#authenticate_user(user = []) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/evernotable/command/base.rb', line 17
def authenticate_user(user=[])
user = read_from_file(credentials_file).split('/') if user.empty?
@user_client = Evernotable::Client::User.new({:user => user.first, :password => user.last, :config => @config, :env => @env})
begin
@user_client.authenticate
rescue Evernotable::Client::ClientException => ex
raise Evernotable::Command::CommandFailed, "Invalid Evernote credentials."
end
end
|
#note_client ⇒ Object
27
28
29
30
|
# File 'lib/evernotable/command/base.rb', line 27
def note_client
authenticate_user
Evernotable::Client::Note.new({:user_shard => @user_client.current_user.shardId, :client_token => @user_client.client_token, :config => @config, :env => @env})
end
|