Module: Everdone
- Defined in:
- lib/everdone/enmlformatter.rb,
lib/everdone.rb,
lib/everdone/sync.rb,
lib/everdone/config.rb,
lib/everdone/todoist.rb,
lib/everdone/version.rb,
lib/everdone/evernote.rb,
lib/everdone/todoItem.rb
Overview
Class to help create the ENML (EverNote Markup Language) content
Defined Under Namespace
Classes: Config, EnmlFormatter, Evernote, Sync, TodoItem, TodoNote, Todoist
Constant Summary
collapse
- VERSION =
"0.0.32"
Class Method Summary
collapse
Class Method Details
.get_notebook_from_project(project) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/everdone.rb', line 25
def self.get_notebook_from_project(project)
notebook = @@config.todoist_evernote_map[project] if not @@config.todoist_evernote_map.has_key?(project) notebook = @@config.default_notebook
end
return notebook
end
|
.init ⇒ Object
19
20
21
22
23
|
# File 'lib/everdone.rb', line 19
def self.init
@@config = Config.new(File.expand_path("../everdone/default_config.json", __FILE__), "#{Dir.home}/.everdone")
@@evernote = Evernote.new(@@config)
@@todoist = Todoist.new(@@config)
end
|
.sync ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/everdone.rb', line 33
def self.sync
self.init
sync = Sync.new(@@config, @@todoist)
items = @@todoist.get_completed_items()
puts "INFO: Returned #{items.length} items"
processed = [] found = [] excluded = [] items.each { |item|
if not sync.is_already_processed(item.id)
notebook = get_notebook_from_project(item.projects[0])
find_count = @@evernote.find_note_counts("#{@@config.todoist_content_tag}#{item.id}", notebook) if notebook
if notebook.nil?
excluded.push(item.id) elsif find_count > 0
found.push(item.id) else content = EnmlFormatter.new(@@config)
content.text("Project: ").link(item.projects[0], item.get_project_url(0))
if item.labels.length > 0
content.space.space.space.space
content.text("Labels: ")
item.labels.each { |label|
content.link(label, item.get_label_url(label)).space
}
end
content.space.space.space.text("#{@@config.todoist_content_tag}#{item.id}")
item.notes.each { |note|
content.h3("Note created #{content.datetime_to_string(note.created, @@config.todoist_datetime_format)} [Todoist note id: #{note.id}]")
content.rawtext(note.content)
}
@@evernote.create_note(item.title,
content.to_s,
notebook,
Evernote.convert_text_to_timestamp(item.created, @@config.todoist_datetime_format))
end
processed.push(item.id) end
}
sync.close(processed)
puts "INFO: Done! Of #{items.length} found..."
puts " #{processed.length - (found.length+excluded.length)} added to Evernote"
puts " #{found.length} were already in Evernote" if found.length > 0
puts " #{excluded.length} were not added as they are in blacklisted Todoist projects" if excluded.length > 0
puts " All time total processed now #{sync.get_processed_total()}"
end
|