Class: FuzzyNotes::EvernoteSync
- Inherits:
-
Object
- Object
- FuzzyNotes::EvernoteSync
- Includes:
- Authentication, Logger
- Defined in:
- lib/fuzzy_notes/evernote_sync.rb
Constant Summary collapse
- USER_STORE_URL =
'http://evernote.com/edam/user'
- NOTE_STORE_URL =
'http://evernote.com/edam/note'
- NOTE_EXT =
'html'
- MAX_NOTES =
1000
Constants included from Logger::Colors
Logger::Colors::CREATE_COLOR, Logger::Colors::DEFAULT_COLOR, Logger::Colors::DELETE_COLOR, Logger::Colors::EXPORT_COLOR, Logger::Colors::IMPORT_COLOR, Logger::Colors::NOTE_COLOR, Logger::Colors::NUMBER_COLOR, Logger::Colors::PATH_COLOR, Logger::Colors::USER_COLOR
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ EvernoteSync
constructor
opts should be a hash with the following keys: :username, :password, :consumer_key, :consumer_secret.
- #sync ⇒ Object
Methods included from Authentication
Methods included from Logger
Constructor Details
#initialize(params = {}) ⇒ EvernoteSync
opts should be a hash with the following keys: :username, :password, :consumer_key, :consumer_secret
19 20 21 22 23 24 |
# File 'lib/fuzzy_notes/evernote_sync.rb', line 19 def initialize(params = {}) return unless auth_result = authenticate(params) @path = params[:note_path] @token = auth_result.authenticationToken @note_store = Evernote::NoteStore.new("#{NOTE_STORE_URL}/#{auth_result.user.shardId}") end |
Class Method Details
.sanitize_evernote(path) ⇒ Object
47 48 49 50 |
# File 'lib/fuzzy_notes/evernote_sync.rb', line 47 def self.sanitize_evernote(path) html = File.read(path) Sanitize.clean(html) end |
Instance Method Details
#sync ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fuzzy_notes/evernote_sync.rb', line 26 def sync return unless authenticated? && valid_sync_path? log.info "syncing evernote directory #{PATH_COLOR} #{@path}" log.info "#{IMPORT_COLOR} synchronizing with Evernote account..." log.indent(2) { log.info "#{IMPORT_COLOR} checking for updates..." } log.indent(4) do notebook_structs = fetch_notebooks log.info "#{IMPORT_COLOR} syncing Evernote deletions..." log.indent(2) do propagate_evernote_deletions(notebook_structs) end notebook_structs.each do |notebook_struct| log.info "#{IMPORT_COLOR} syncing notebook #{NOTE_COLOR} #{notebook_struct.name}" log.indent(2) do create_local_notebook(notebook_struct) sync_notes(notebook_struct) end end end end |