class EnClient::Command
Attributes
command_id[RW]
dm[RW]
shell[RW]
sm[RW]
tm[RW]
Public Class Methods
create_from_hash(hash)
click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 331 def self.create_from_hash(hash) unless hash.has_key? :class raise IllegalArgumentException.new("key \"class\" is not found") end class_name = hash[:class] command = get_command class_name unless command raise IllegalArgumentException.new("command #{class_name} is not found") end hash.each do |key, value| next if key == :class setter_name = key.to_s + "=" meth = command.send setter_name, value end command end
Private Class Methods
get_command(name)
click to toggle source
Private helpers
# File usr/lib/evernote-mode/enclient.rb, line 396 def self.get_command(name) all_commands = [AuthCommand, ListNoteCommand, ListNotebookCommand, ListTagCommand, ListSearchCommand, SearchNoteCommand, GetNoteCommand, CreateNoteCommand, UpdateNoteCommand, DeleteNoteCommand, CreateNotebookCommand, UpdateNotebookCommand, CreateTagCommand, UpdateTagCommand, CreateSearchCommand, UpdateSearchCommand] command_class = all_commands.find do |elem| Formatter.remove_package_names(elem.name) == name end if command_class command_class.new end end
Public Instance Methods
exec()
click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 351 def exec exec_impl rescue reply = ErrorReply.new reply.command_id = @command_id ErrorUtils.set_reply_error $!, reply LOG.warn reply.message LOG.warn $!.backtrace @shell.reply self, reply end
Private Instance Methods
check_auth()
click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 388 def check_auth @sm.auth_token # check authentication end
server_task(ordered = false) { || ... }
click to toggle source
Utilities for subclasses
# File usr/lib/evernote-mode/enclient.rb, line 368 def server_task(ordered = false, &block) task = Task.new do begin yield rescue if $!.is_a? SystemCallError # workaround for corruption of note_store after timed out @sm.fix_note_store end reply = ErrorReply.new reply.command_id = @command_id ErrorUtils.set_reply_error $!, reply LOG.warn reply.message LOG.warn $!.backtrace @shell.reply self, reply end end @tm.put task, !ordered end