evertils-common 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evertils/common/entity/note.rb +24 -0
- data/lib/evertils/common/entity/notebook.rb +5 -31
- data/lib/evertils/common/entity/notebooks.rb +33 -0
- data/lib/evertils/common/entity/stack.rb +50 -0
- data/lib/evertils/common/entity/tag.rb +41 -0
- data/lib/evertils/common/entity/tags.rb +21 -0
- data/lib/evertils/common/evernote.rb +12 -4
- data/lib/evertils/common/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ece5b1508dd87b93750415035bd7aeb57b73b2b
|
4
|
+
data.tar.gz: b399fec366af5f05baabeb5cb7de6269003cf829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b2db29191840e3ff064062c6ddc5008647d6fef9912922315e4ad828911b674a3393ed8cb3b4c44f9df571e3585feaf04b6e097cf83b019274a820753dad4d9
|
7
|
+
data.tar.gz: a25b1523b621c672bc396ce5af21a449ffa56fe589afe5f3ecbdee72fca8d3275aff4ebc49dfbe4ebba570d7301e97cba18a6dbe5837cb7975cc13c6df446d68
|
@@ -101,7 +101,31 @@ module Evertils
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def destroy(name)
|
104
|
+
note = find(name).guid
|
104
105
|
|
106
|
+
@evernote.deleteNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, note)
|
107
|
+
end
|
108
|
+
|
109
|
+
def expunge(name)
|
110
|
+
note = find(name).guid
|
111
|
+
|
112
|
+
@evernote.expungeNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, note)
|
113
|
+
end
|
114
|
+
|
115
|
+
def find(name)
|
116
|
+
filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
|
117
|
+
filter.words = name
|
118
|
+
|
119
|
+
result = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new
|
120
|
+
result.includeTitle = true
|
121
|
+
result.includeUpdated = true
|
122
|
+
result.includeTagGuids = true
|
123
|
+
|
124
|
+
result = @evernote.findNotesMetadata(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, filter, 0, 1, result)
|
125
|
+
|
126
|
+
if result.totalNotes == 1
|
127
|
+
result.notes[0]
|
128
|
+
end
|
105
129
|
end
|
106
130
|
|
107
131
|
private
|
@@ -16,35 +16,12 @@ module Evertils
|
|
16
16
|
notebooks = Notebooks.new.all
|
17
17
|
|
18
18
|
notebooks.each do |notebook|
|
19
|
-
if notebook.name == name.to_s
|
19
|
+
if notebook.name == name.to_s
|
20
20
|
@notebook = notebook
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
@notebook
|
25
|
-
end
|
26
23
|
|
27
|
-
|
28
|
-
begin
|
29
|
-
if File.exists? full_path
|
30
|
-
conf = YAML::load(File.open(full_path))
|
31
|
-
required = %w(name children)
|
32
|
-
|
33
|
-
if has_required_fields(conf, required)
|
34
|
-
if !conf["children"].nil?
|
35
|
-
conf["children"].each do |name|
|
36
|
-
create(name, conf["name"])
|
37
|
-
end
|
38
|
-
end
|
39
|
-
else
|
40
|
-
raise ArgumentError, 'Configuration file is missing some required fields'
|
41
|
-
end
|
42
|
-
else
|
43
|
-
raise ArgumentError, "File not found: #{full_path}"
|
44
|
-
end
|
45
|
-
rescue ArgumentError => e
|
46
|
-
puts e.message
|
47
|
-
end
|
24
|
+
@notebook
|
48
25
|
end
|
49
26
|
|
50
27
|
def create(name, stack = nil)
|
@@ -59,19 +36,16 @@ module Evertils
|
|
59
36
|
@evernote.createNotebook(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, notebook)
|
60
37
|
end
|
61
38
|
|
62
|
-
def
|
39
|
+
def expunge(name)
|
40
|
+
nb = find(name)
|
63
41
|
|
42
|
+
@evernote.expungeNotebook(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, nb.guid)
|
64
43
|
end
|
65
44
|
|
66
45
|
def notes(guid = nil)
|
67
46
|
filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
|
68
47
|
filter.notebookGuid = @notebook.guid
|
69
48
|
|
70
|
-
result = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new
|
71
|
-
result.includeTitle = true
|
72
|
-
result.includeUpdated = true
|
73
|
-
result.includeTagGuids = true
|
74
|
-
|
75
49
|
notes = Notes.new
|
76
50
|
notes.find(nil, @notebook.guid)
|
77
51
|
end
|
@@ -15,6 +15,39 @@ module Evertils
|
|
15
15
|
@evernote.listNotebooks(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
|
16
16
|
end
|
17
17
|
|
18
|
+
def create_from_yml(full_path)
|
19
|
+
begin
|
20
|
+
nb = Notebook.new
|
21
|
+
|
22
|
+
if File.exists? full_path
|
23
|
+
conf = YAML::load(File.open(full_path))
|
24
|
+
required = %w(notebooks)
|
25
|
+
|
26
|
+
if has_required_fields(conf, required)
|
27
|
+
if !conf["notebooks"].nil?
|
28
|
+
conf["notebooks"].each do |name|
|
29
|
+
nb.create(name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
raise ArgumentError, 'Configuration file is missing some required fields'
|
34
|
+
end
|
35
|
+
else
|
36
|
+
raise ArgumentError, "File not found: #{full_path}"
|
37
|
+
end
|
38
|
+
rescue ArgumentError => e
|
39
|
+
puts e.message
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def has_required_fields(hash, required)
|
46
|
+
hash.keys.each do |key|
|
47
|
+
required.include? key
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
18
51
|
end
|
19
52
|
end
|
20
53
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'evertils/common/authentication'
|
2
|
+
|
3
|
+
module Evertils
|
4
|
+
module Common
|
5
|
+
module Entity
|
6
|
+
class Stack
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@evernote = Authentication.new.store
|
10
|
+
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_from_yml(full_path)
|
15
|
+
begin
|
16
|
+
nb = Notebook.new
|
17
|
+
|
18
|
+
if File.exists? full_path
|
19
|
+
conf = YAML::load(File.open(full_path))
|
20
|
+
required = %w(name children)
|
21
|
+
|
22
|
+
if has_required_fields(conf, required)
|
23
|
+
if !conf["children"].nil?
|
24
|
+
conf["children"].each do |name|
|
25
|
+
nb.create(name, conf["name"])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
else
|
29
|
+
raise ArgumentError, 'Configuration file is missing some required fields'
|
30
|
+
end
|
31
|
+
else
|
32
|
+
raise ArgumentError, "File not found: #{full_path}"
|
33
|
+
end
|
34
|
+
rescue ArgumentError => e
|
35
|
+
puts e.message
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def has_required_fields(hash, required)
|
42
|
+
hash.keys.each do |key|
|
43
|
+
required.include? key
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'evertils/common/authentication'
|
2
|
+
|
3
|
+
module Evertils
|
4
|
+
module Common
|
5
|
+
module Entity
|
6
|
+
class Tag
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@evernote = Authentication.new.store
|
10
|
+
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(name)
|
15
|
+
tags = Tags.new.all
|
16
|
+
|
17
|
+
tags.each do |tag|
|
18
|
+
if tag.name == name.to_s
|
19
|
+
return tag
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(name)
|
26
|
+
tag = ::Evernote::EDAM::Type::Tag.new
|
27
|
+
tag.name = name
|
28
|
+
|
29
|
+
@evernote.createTag(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, tag)
|
30
|
+
end
|
31
|
+
|
32
|
+
def expunge(name)
|
33
|
+
tag = find(name)
|
34
|
+
|
35
|
+
@evernote.expungeTag(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, tag.guid)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'evertils/common/authentication'
|
2
|
+
|
3
|
+
module Evertils
|
4
|
+
module Common
|
5
|
+
module Entity
|
6
|
+
class Tags
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@evernote = Authentication.new.store
|
10
|
+
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
@evernote.listTags(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'evertils/common/enml'
|
3
3
|
require 'evertils/common/results_helper'
|
4
|
-
require 'evertils/common/entity/notebooks'
|
5
4
|
require 'evertils/common/entity/notebook'
|
5
|
+
require 'evertils/common/entity/notebooks'
|
6
6
|
require 'evertils/common/entity/notes'
|
7
7
|
require 'evertils/common/entity/note'
|
8
|
+
require 'evertils/common/entity/tag'
|
9
|
+
require 'evertils/common/entity/tags'
|
8
10
|
|
9
11
|
module Evertils
|
10
12
|
module Common
|
@@ -15,7 +17,8 @@ module Evertils
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def tags
|
18
|
-
|
20
|
+
tags = Entity::Tags.new
|
21
|
+
tags.all
|
19
22
|
end
|
20
23
|
|
21
24
|
def notebook_by_name(name)
|
@@ -30,8 +33,8 @@ module Evertils
|
|
30
33
|
end
|
31
34
|
|
32
35
|
def create_stack_from(full_path)
|
33
|
-
|
34
|
-
|
36
|
+
stack = Entity::Stack.new
|
37
|
+
stack.create_from_yml(full_path)
|
35
38
|
end
|
36
39
|
|
37
40
|
def create_note_from(full_path)
|
@@ -39,6 +42,11 @@ module Evertils
|
|
39
42
|
note.create_from_yml(full_path)
|
40
43
|
end
|
41
44
|
|
45
|
+
def create_notebook_from(full_path)
|
46
|
+
nb = Entity::Notebook.new
|
47
|
+
nb.create_from_yml(full_path)
|
48
|
+
end
|
49
|
+
|
42
50
|
def create_notebook(name, stack = nil)
|
43
51
|
nb = Entity::Notebook.new
|
44
52
|
nb.create(name, stack)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evertils-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Priebe
|
@@ -90,6 +90,9 @@ files:
|
|
90
90
|
- lib/evertils/common/entity/notebook.rb
|
91
91
|
- lib/evertils/common/entity/notebooks.rb
|
92
92
|
- lib/evertils/common/entity/notes.rb
|
93
|
+
- lib/evertils/common/entity/stack.rb
|
94
|
+
- lib/evertils/common/entity/tag.rb
|
95
|
+
- lib/evertils/common/entity/tags.rb
|
93
96
|
- lib/evertils/common/evernote.rb
|
94
97
|
- lib/evertils/common/results_helper.rb
|
95
98
|
- lib/evertils/common/version.rb
|