lib/helpers/evernote.rb in evertils-0.0.11 vs lib/helpers/evernote.rb in evertils-0.1.0

- old
+ new

@@ -110,11 +110,11 @@ end output end - def note(title_filter = nil, notebook_filter = nil) + def find_note(title_filter = nil, notebook_filter = nil) filter = ::Evernote::EDAM::NoteStore::NoteFilter.new filter.words = "intitle:#{title_filter}" if title_filter filter.notebookGuid = notebook_filter if notebook_filter @@store.findNotes(@@developer_token, filter, nil, 1) @@ -127,11 +127,25 @@ @@store.findNotes(@@developer_token, filter, nil, 300) end def note_exists - note = note(date_templates[$request.command]) - note.totalNotes > 0 + results = Helper::Results.new + template = date_templates[$request.command] + note = find_note(template) + + # Evernote's search matches things like the following, so we have to get + # more specific + # Daily Log [July 3 - F] == Daily Log [July 10 - F] + if note.totalNotes > 0 + note.notes.each do |n| + results.add(n.title != template) + end + else + results.add(false) + end + + results.should_eval_to(false) end def create_note(title = date_templates[$request.command], body = template_contents, p_notebook_name = nil, file = nil, share_note = false) if $request.command == :weekly && !Date.today.monday? Notify.error("Sorry, you can only create new weekly logs on Mondays") \ No newline at end of file