everton 0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -1
- data/examples/find_notes.rb +30 -0
- data/lib/everton.rb +53 -1
- metadata +6 -3
data/README.md
CHANGED
@@ -4,10 +4,12 @@ Thin wrapper around Evernote ruby client library (https://github.com/cgs/evernot
|
|
4
4
|
|
5
5
|
# Installing #
|
6
6
|
|
7
|
-
gem install
|
7
|
+
gem install everton
|
8
8
|
|
9
9
|
# Usage #
|
10
10
|
|
11
|
+
You'll need an Evernote API key to use this library. Get yourself a "Client application" API key from Evernote (http://www.evernote.com/about/developer/api/#key). For more info, see https://github.com/cgs/evernote/blob/master/README.mkd
|
12
|
+
|
11
13
|
require 'rubygems'
|
12
14
|
require 'everton'
|
13
15
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'lib/everton'
|
2
|
+
|
3
|
+
config = {
|
4
|
+
:username => 'myuser',
|
5
|
+
:password => 'mypass',
|
6
|
+
:consumer_key => 'key',
|
7
|
+
:consumer_secret => 'secret',
|
8
|
+
:user_store_url => 'http://sandbox.evernote.com/edam/user'
|
9
|
+
}
|
10
|
+
|
11
|
+
# Authenticate
|
12
|
+
Everton::Remote.authenticate config
|
13
|
+
|
14
|
+
|
15
|
+
# Iterate over all the netbooks and print the notebook name
|
16
|
+
n = Everton::Notebook.all.first
|
17
|
+
|
18
|
+
# Find the first 20 notes in notebook n
|
19
|
+
n.find_notes.each do |note|
|
20
|
+
puts note.title
|
21
|
+
end
|
22
|
+
|
23
|
+
# Find a note in notebook n using filter
|
24
|
+
# See http://www.evernote.com/about/kb/article/advanced-search?lang=en
|
25
|
+
n.find_notes('intitle:Aspirations').each do |note|
|
26
|
+
puts note.title
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
data/lib/everton.rb
CHANGED
@@ -8,8 +8,44 @@ require 'uri'
|
|
8
8
|
# http://forum.evernote.com/phpbb/viewtopic.php?f=43&t=27547
|
9
9
|
#
|
10
10
|
|
11
|
+
module Evernote
|
12
|
+
module EDAM
|
13
|
+
module Type
|
14
|
+
class NoteFilter
|
15
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
16
|
+
ORDER = 1
|
17
|
+
ASCENDING = 2
|
18
|
+
WORDS = 3
|
19
|
+
NOTEBOOKGUID = 4
|
20
|
+
TAGGUIDS = 5
|
21
|
+
TIMEZONE = 6
|
22
|
+
INACTIVE = 7
|
23
|
+
|
24
|
+
FIELDS = {
|
25
|
+
ORDER => {:type => ::Thrift::Types::I32, :name => 'order', :optional => true},
|
26
|
+
ASCENDING => {:type => ::Thrift::Types::BOOL, :name => 'ascending', :optional => true},
|
27
|
+
WORDS => {:type => ::Thrift::Types::STRING, :name => 'words', :optional => true},
|
28
|
+
NOTEBOOKGUID => {:type => ::Thrift::Types::STRING, :name => 'notebookGuid', :optional => true},
|
29
|
+
TAGGUIDS => {:type => ::Thrift::Types::LIST, :name => 'tagGuids', :optional => true, :enum_class => Evernote::EDAM::Type::PrivilegeLevel},
|
30
|
+
TIMEZONE => {:type => ::Thrift::Types::STRING, :name => 'timezone', :optional => true},
|
31
|
+
INACTIVE => {:type => ::Thrift::Types::BOOL, :name => 'active', :optional => true}
|
32
|
+
}
|
33
|
+
|
34
|
+
def struct_fields; FIELDS; end
|
35
|
+
|
36
|
+
def validate
|
37
|
+
end
|
38
|
+
|
39
|
+
::Thrift::Struct.generate_accessors self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
11
46
|
module Everton
|
12
|
-
|
47
|
+
|
48
|
+
VERSION = '0.1.1'
|
13
49
|
|
14
50
|
class Remote
|
15
51
|
|
@@ -77,6 +113,21 @@ module Everton
|
|
77
113
|
Everton::Remote.note_store.createNote(Everton::Remote.access_token, note)
|
78
114
|
|
79
115
|
end
|
116
|
+
|
117
|
+
# See advanced search
|
118
|
+
# http://www.evernote.com/about/kb/article/advanced-search?lang=en
|
119
|
+
#
|
120
|
+
# http://www.evernote.com/about/developer/api/ref/NoteStore.html#Struct_NoteFilter
|
121
|
+
#
|
122
|
+
# http://www.evernote.com/about/developer/api/ref/NoteStore.html#Fn_NoteStore_findNotes
|
123
|
+
def find_notes(filter=nil, params = {})
|
124
|
+
f = Evernote::EDAM::Type::NoteFilter.new()
|
125
|
+
f.notebookGuid = self.guid
|
126
|
+
f.words = filter if filter
|
127
|
+
offset = params[:offset] || 0
|
128
|
+
max_notes = params[:max_notes] || 20
|
129
|
+
Everton::Remote.note_store.findNotes(Remote.access_token,f,offset,max_notes).notes
|
130
|
+
end
|
80
131
|
|
81
132
|
end
|
82
133
|
|
@@ -91,6 +142,7 @@ module Everton
|
|
91
142
|
end
|
92
143
|
nil
|
93
144
|
end
|
145
|
+
|
94
146
|
end
|
95
147
|
|
96
148
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: everton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Sergio Rubio
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-13 00:00:00 Z
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
20
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- examples/add_image.rb
|
98
99
|
- examples/add_text.rb
|
99
100
|
- examples/basics.rb
|
101
|
+
- examples/find_notes.rb
|
100
102
|
- lib/everton.rb
|
101
103
|
homepage: http://github.com/rubiojr/everton
|
102
104
|
licenses:
|
@@ -135,3 +137,4 @@ test_files:
|
|
135
137
|
- examples/add_image.rb
|
136
138
|
- examples/add_text.rb
|
137
139
|
- examples/basics.rb
|
140
|
+
- examples/find_notes.rb
|