evernote_oauth 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +32 -1
- data/evernote_oauth.gemspec +1 -1
- data/lib/evernote/edam/note_store/note_list.rb +10 -0
- data/lib/evernote/edam/note_store/note_metadata.rb +11 -0
- data/lib/evernote/edam/note_store/notes_metadata_list.rb +10 -0
- data/lib/evernote/edam/note_store/sync_chunk.rb +10 -0
- data/lib/evernote/edam/type/note.rb +15 -0
- data/lib/evernote/edam/type/resource.rb +27 -0
- data/lib/evernote/edam/type/shared_notebook.rb +11 -0
- data/lib/evernote/edam/type/tag.rb +11 -0
- data/lib/evernote_oauth.rb +3 -0
- data/lib/evernote_oauth/store_attachable.rb +31 -0
- data/lib/evernote_oauth/thrift_client_delegation.rb +16 -3
- data/lib/evernote_oauth/version.rb +1 -1
- data/lib/evernote_types.rb +10 -0
- metadata +12 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Evernote OAuth / Thrift API client library for Ruby
|
2
2
|
===================================================
|
3
|
-
- Evernote OAuth version 0.1.
|
3
|
+
- Evernote OAuth version 0.1.2
|
4
4
|
|
5
5
|
Install the gem
|
6
6
|
---------------
|
@@ -90,6 +90,37 @@ shared_notebook = shared_note_store.getSharedNotebookByAuth
|
|
90
90
|
shared_note_store.listTagsByNotebook(shared_notebook.notebookGuid)
|
91
91
|
```
|
92
92
|
|
93
|
+
### Method Chaining ###
|
94
|
+
You can chain methods:
|
95
|
+
```ruby
|
96
|
+
note_store.findNotes(Evernote::EDAM::NoteStore::NoteFilter.new, 0, 10).first.tags.first.parent
|
97
|
+
=> [<Evernote::EDAM::Type::Tag guid:"xxxxx", name:"sample", updateSequenceNum:100>]
|
98
|
+
```
|
99
|
+
Here are the additional methods for each types:
|
100
|
+
|
101
|
+
- Evernote::EDAM::NoteStore::NoteList
|
102
|
+
- notes
|
103
|
+
- Evernote::EDAM::NoteStore::NoteMetadata
|
104
|
+
- tags
|
105
|
+
- Evernote::EDAM::NoteStore::NotesMetadataList
|
106
|
+
- notes
|
107
|
+
- Evernote::EDAM::NoteStore::SyncChunk
|
108
|
+
- notes, notebooks, tags, searches, resources, linkedNotebooks
|
109
|
+
- Evernote::EDAM::Type::Note
|
110
|
+
- notebook, tags
|
111
|
+
- Evernote::EDAM::Type::Resource
|
112
|
+
- note: needs hash argument
|
113
|
+
- with_constant: boolean
|
114
|
+
- with_resources_data: boolean
|
115
|
+
- with_resources_recognition: boolean
|
116
|
+
- with_resources_alternate_data: boolean
|
117
|
+
- Evernote::EDAM::Type::SharedNotebook
|
118
|
+
- notebook
|
119
|
+
- Evernote::EDAM::Type::Tag
|
120
|
+
- parent
|
121
|
+
|
122
|
+
Notes: Those methods call thrift API internally. The result will be cached in the object so that the second method call wouldn't thrift API again.
|
123
|
+
|
93
124
|
References
|
94
125
|
----------
|
95
126
|
- Evernote Developers: http://dev.evernote.com/
|
data/evernote_oauth.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.email = %q{api@evernote.com}
|
15
15
|
s.files = ["LICENSE", "README.md", "evernote_oauth.gemspec"] + Dir.glob('{lib,spec}/**/*')
|
16
16
|
s.has_rdoc = false
|
17
|
-
s.homepage = %q{http://github.com/
|
17
|
+
s.homepage = %q{http://github.com/evernote/evernote-oauth-ruby}
|
18
18
|
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.rubyforge_project = %q{evernote_oauth}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Evernote
|
2
|
+
module EDAM
|
3
|
+
module Type
|
4
|
+
class Resource
|
5
|
+
@note_by_options = {}
|
6
|
+
|
7
|
+
def note(options)
|
8
|
+
options = {
|
9
|
+
with_content: false,
|
10
|
+
with_resources_data: false,
|
11
|
+
with_resources_recognition: false,
|
12
|
+
with_resources_alternate_data: false
|
13
|
+
}.merge(options)
|
14
|
+
|
15
|
+
@note_by_opions[options] ||
|
16
|
+
(@note_by_options[options] = note_store.getNote(
|
17
|
+
noteGuid,
|
18
|
+
options[:with_content],
|
19
|
+
options[:with_resources_data],
|
20
|
+
options[:with_resources_recognition],
|
21
|
+
options[:with_resources_alternate_data])
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/evernote_oauth.rb
CHANGED
@@ -4,9 +4,12 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
require 'evernote-thrift'
|
6
6
|
|
7
|
+
require 'evernote_types'
|
8
|
+
|
7
9
|
require 'evernote_oauth/thrift_client_delegation'
|
8
10
|
require 'evernote_oauth/client'
|
9
11
|
require 'evernote_oauth/user_store'
|
10
12
|
require 'evernote_oauth/note_store'
|
11
13
|
require 'evernote_oauth/shared_note_store'
|
14
|
+
require 'evernote_oauth/store_attachable'
|
12
15
|
require 'evernote_oauth/version'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module EvernoteOAuth
|
2
|
+
module StoreAttachable
|
3
|
+
def attach_user_store(*field_symbols)
|
4
|
+
attach_store('user', *field_symbols)
|
5
|
+
end
|
6
|
+
|
7
|
+
def attach_note_store(*field_symbols)
|
8
|
+
attach_store('note', *field_symbols)
|
9
|
+
end
|
10
|
+
|
11
|
+
def attach_store(type, *field_symbols)
|
12
|
+
field_symbols.each do |fs|
|
13
|
+
define_method(fs) do
|
14
|
+
original = "@#{fs}".to_sym
|
15
|
+
target = "@#{fs}_with_#{type}_stores".to_sym
|
16
|
+
with_stores = (
|
17
|
+
instance_variable_get(target) ||
|
18
|
+
begin
|
19
|
+
store_name = "#{type}_store"
|
20
|
+
store = eval(store_name)
|
21
|
+
[instance_variable_get(original)].flatten.each{|n|
|
22
|
+
n.define_singleton_method(store_name.to_sym){store}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
)
|
26
|
+
instance_variable_set(target, with_stores)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -8,14 +8,27 @@ module EvernoteOAuth
|
|
8
8
|
idx_token = parameters.index{|e| e.last == :authenticationToken}
|
9
9
|
new_args = args.dup.insert(idx_token, @token)
|
10
10
|
begin
|
11
|
-
@client.send(name, *new_args, &block)
|
11
|
+
result = @client.send(name, *new_args, &block)
|
12
12
|
rescue ArgumentError => e
|
13
13
|
puts e.inspect
|
14
|
-
@client.send(name, *args, &block)
|
14
|
+
result = @client.send(name, *args, &block)
|
15
15
|
end
|
16
16
|
else
|
17
|
-
@client.send(name, *args, &block)
|
17
|
+
result = @client.send(name, *args, &block)
|
18
18
|
end
|
19
|
+
|
20
|
+
attr_name = underscore(self.class.name.split('::').last).to_sym
|
21
|
+
attr_value = self
|
22
|
+
[result].flatten.each{|r| r.define_singleton_method(attr_name){attr_value}}
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def underscore(word)
|
28
|
+
word.to_s.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
29
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
30
|
+
tr("-", "_").
|
31
|
+
downcase
|
19
32
|
end
|
20
33
|
end
|
21
34
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'evernote_oauth/store_attachable'
|
2
|
+
|
3
|
+
require 'evernote/edam/type/note'
|
4
|
+
require 'evernote/edam/type/resource'
|
5
|
+
require 'evernote/edam/type/shared_notebook'
|
6
|
+
require 'evernote/edam/type/tag'
|
7
|
+
|
8
|
+
require 'evernote/edam/note_store/note_list'
|
9
|
+
require 'evernote/edam/note_store/note_metadata'
|
10
|
+
require 'evernote/edam/note_store/sync_chunk'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evernote_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -69,19 +69,29 @@ files:
|
|
69
69
|
- LICENSE
|
70
70
|
- README.md
|
71
71
|
- evernote_oauth.gemspec
|
72
|
+
- lib/evernote/edam/note_store/note_list.rb
|
73
|
+
- lib/evernote/edam/note_store/note_metadata.rb
|
74
|
+
- lib/evernote/edam/note_store/notes_metadata_list.rb
|
75
|
+
- lib/evernote/edam/note_store/sync_chunk.rb
|
76
|
+
- lib/evernote/edam/type/note.rb
|
77
|
+
- lib/evernote/edam/type/resource.rb
|
78
|
+
- lib/evernote/edam/type/shared_notebook.rb
|
79
|
+
- lib/evernote/edam/type/tag.rb
|
72
80
|
- lib/evernote_oauth/client.rb
|
73
81
|
- lib/evernote_oauth/note_store.rb
|
74
82
|
- lib/evernote_oauth/shared_note_store.rb
|
83
|
+
- lib/evernote_oauth/store_attachable.rb
|
75
84
|
- lib/evernote_oauth/thrift_client_delegation.rb
|
76
85
|
- lib/evernote_oauth/user_store.rb
|
77
86
|
- lib/evernote_oauth/version.rb
|
78
87
|
- lib/evernote_oauth.rb
|
88
|
+
- lib/evernote_types.rb
|
79
89
|
- spec/evernote_oauth/client_spec.rb
|
80
90
|
- spec/evernote_oauth/note_store_spec.rb
|
81
91
|
- spec/evernote_oauth/shared_note_store_spec.rb
|
82
92
|
- spec/evernote_oauth/user_store_spec.rb
|
83
93
|
- spec/spec_helper.rb
|
84
|
-
homepage: http://github.com/
|
94
|
+
homepage: http://github.com/evernote/evernote-oauth-ruby
|
85
95
|
licenses: []
|
86
96
|
post_install_message:
|
87
97
|
rdoc_options:
|