everton 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,5 +26,14 @@ n.find_notes('intitle:Aspirations').each do |note|
26
26
  puts note.title
27
27
  end
28
28
 
29
-
30
-
29
+ #
30
+ # Create a new text note
31
+ #
32
+ n.add_note('title', 'note body')
33
+
34
+ #
35
+ # Updating a note
36
+ #
37
+ note = n.find_notes.first
38
+ note.title = 'new title'
39
+ note.update
data/lib/everton.rb CHANGED
@@ -9,43 +9,15 @@ require 'uri'
9
9
  #
10
10
 
11
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
12
+ class UserStore
13
+ def validate_version
41
14
  end
42
15
  end
43
16
  end
44
17
 
45
-
46
18
  module Everton
47
19
 
48
- VERSION = '0.1.1'
20
+ VERSION = '0.1.2'
49
21
 
50
22
  class Remote
51
23
 
@@ -71,8 +43,17 @@ module Everton
71
43
  end
72
44
  end
73
45
 
46
+ class ::Evernote::EDAM::Type::Note
47
+ def update
48
+ Everton::Remote.note_store.updateNote(Everton::Remote.access_token, self)
49
+ end
50
+ end
51
+
74
52
  class ::Evernote::EDAM::Type::Notebook
75
53
 
54
+ #
55
+ # Add a text note and return it
56
+ #
76
57
  def add_note(title, text)
77
58
  note = Evernote::EDAM::Type::Note.new()
78
59
  note.title = title
@@ -84,6 +65,9 @@ module Everton
84
65
  Everton::Remote.note_store.createNote(Everton::Remote.access_token, note)
85
66
  end
86
67
 
68
+ #
69
+ # Add an image note and return it
70
+ #
87
71
  def add_image(title, text, filename)
88
72
  image = File.open(filename, "rb") { |io| io.read }
89
73
  hashFunc = Digest::MD5.new
@@ -111,7 +95,6 @@ module Everton
111
95
  note.resources = [ resource ]
112
96
 
113
97
  Everton::Remote.note_store.createNote(Everton::Remote.access_token, note)
114
-
115
98
  end
116
99
 
117
100
  # See advanced search
@@ -121,7 +104,7 @@ module Everton
121
104
  #
122
105
  # http://www.evernote.com/about/developer/api/ref/NoteStore.html#Fn_NoteStore_findNotes
123
106
  def find_notes(filter=nil, params = {})
124
- f = Evernote::EDAM::Type::NoteFilter.new()
107
+ f = Evernote::EDAM::NoteStore::NoteFilter.new()
125
108
  f.notebookGuid = self.guid
126
109
  f.words = filter if filter
127
110
  offset = params[:offset] || 0
@@ -136,6 +119,12 @@ module Everton
136
119
  Remote.note_store.listNotebooks(Remote.access_token)
137
120
  end
138
121
 
122
+ def self.create(name, params = {})
123
+ n = Evernote::EDAM::Type::Notebook.new()
124
+ n.name = name
125
+ Remote.note_store.createNotebook(Remote.access_token, n)
126
+ end
127
+
139
128
  def self.find(name)
140
129
  all.each do |n|
141
130
  return n if n.name == name
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everton
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Rubio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-13 00:00:00 Z
18
+ date: 2011-07-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ files:
98
98
  - examples/add_image.rb
99
99
  - examples/add_text.rb
100
100
  - examples/basics.rb
101
- - examples/find_notes.rb
101
+ - examples/notes.rb
102
102
  - lib/everton.rb
103
103
  homepage: http://github.com/rubiojr/everton
104
104
  licenses:
@@ -137,4 +137,4 @@ test_files:
137
137
  - examples/add_image.rb
138
138
  - examples/add_text.rb
139
139
  - examples/basics.rb
140
- - examples/find_notes.rb
140
+ - examples/notes.rb