evernote_utils 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/evernote_utils.gemspec +2 -2
- data/lib/evernote_utils/array.rb +23 -0
- data/lib/evernote_utils/filter.rb +26 -0
- data/lib/evernote_utils/note.rb +4 -25
- data/lib/evernote_utils/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e326fee20e091ca7e271c3c9451ded1c32905f53
|
4
|
+
data.tar.gz: c5b744271ddfa3098621d6b757dff7d6f9e74a8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5929c1b89f09628a1f6ce1c1e38410436397163e8c770d562495455743dad6b7db74a053148a47ee314a552ce32ae09371b2984c6472fc21040333a9024914cb
|
7
|
+
data.tar.gz: df7c88a5509225112d53edf0065b67787e9e07baaf6d3bc23ed80be4e06233bbd551c3456ee223b6b14a5ccfb9878825f19cf52603210f15ae9962b4333e572a
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
If you don't have your Evernote API Key yet, get it from [Evernote Developers Page](http://dev.evernote.com/doc/).
|
24
24
|
|
25
|
-
Note that you should send "Activation Request" to access
|
25
|
+
Note that you should send "Activation Request" to access production data. Please check [Frequently Ask Questions - Evernote Developers](http://dev.evernote.com/support/faq.php#activatekey).
|
26
26
|
|
27
27
|
Then authenticate user's Evernote account via OAuth. Instruction is here: [Getting Started with the Evernote API - Evernote Developers](http://dev.evernote.com/doc/start/ruby.php)
|
28
28
|
|
@@ -50,7 +50,12 @@ Then you can access Evernote resources.
|
|
50
50
|
|
51
51
|
enutils.notes(words: 'Clojure', limit: 5, order: :updated)
|
52
52
|
|
53
|
-
It returns `ENUtils::
|
53
|
+
It returns `ENUtils::NoteList` instances. You can know total count of search result by calling `ENUtils::NoteList#total_count`
|
54
|
+
|
55
|
+
enutils.notes(words: 'Clojure', limit: 5, order: :updated).total_count #=> 150
|
56
|
+
|
57
|
+
`ENUtils::NoteList` is a collection of `ENUtils::Note`. `ENUtils::Note` is a thin wrapper of `Evernote::EDAM::Type::Note`.
|
58
|
+
|
54
59
|
|
55
60
|
And here, `ENUtils#notes` accepts following options:
|
56
61
|
|
@@ -80,7 +85,6 @@ These methods return array of `ENUtils::Notebook` and `ENUtils::Tag` respectivel
|
|
80
85
|
## Planning to do
|
81
86
|
|
82
87
|
* relationships: notebook.notes, note.tags, tag.notes
|
83
|
-
* counting result notes
|
84
88
|
|
85
89
|
|
86
90
|
## Contributing
|
data/evernote_utils.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ENUtils::VERSION
|
9
9
|
spec.authors = ["memerelics"]
|
10
10
|
spec.email = ["takuya21hashimoto@gmail.com"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{A thin OOP-friendly wrapper of Evernote Ruby SDK.}
|
12
|
+
spec.summary = %q{A thin OOP-friendly wrapper of Evernote Ruby SDK.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "evernote_utils/filter"
|
2
|
+
|
3
|
+
module ENUtils
|
4
|
+
class NoteList < Array
|
5
|
+
|
6
|
+
attr_reader :core, :options
|
7
|
+
|
8
|
+
def initialize(core, array, options={})
|
9
|
+
@core = core
|
10
|
+
@options = options
|
11
|
+
super(array)
|
12
|
+
end
|
13
|
+
|
14
|
+
# findNoteCounts returns
|
15
|
+
# Evernote::EDAM::NoteStore::NoteCollectionCounts
|
16
|
+
# notebookCounts:{"xxxxxxxx-...xxx": 10, ...},
|
17
|
+
# tagCounts:{"xxxxxx-...xxxx": 1, ..."}
|
18
|
+
def total_count
|
19
|
+
counts = core.notestore.findNoteCounts(core.token, NoteFilter.build(options), false)
|
20
|
+
counts.notebookCounts.reduce(0){|sum, pair| sum += pair.last }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ENUtils
|
2
|
+
class NoteFilter
|
3
|
+
|
4
|
+
def self.build(options={})
|
5
|
+
filter = Evernote::EDAM::NoteStore::NoteFilter.new
|
6
|
+
if (notebook = options[:notebook])
|
7
|
+
notebook_guid = notebook.is_a?(ENUtils::Notebook) ? notebook.guid : notebook
|
8
|
+
filter.notebookGuid = notebook_guid
|
9
|
+
end
|
10
|
+
if (tags = options[:tags]) || (tag = options[:tag])
|
11
|
+
tag_guids = (tags || [tag]).map{|t| t.is_a?(ENUtils::Tag) ? t.guid : t }
|
12
|
+
filter.tagGuids = tag_guids
|
13
|
+
end
|
14
|
+
filter.words = options[:words] if options[:words]
|
15
|
+
filter.order = OrderFields[options[:order].to_sym] if available_order?(options[:order])
|
16
|
+
filter.ascending = options[:asc] if options[:asc]
|
17
|
+
filter
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.available_order?(value)
|
21
|
+
return false if value.nil?
|
22
|
+
OrderFields.keys.include?(value.to_sym)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/evernote_utils/note.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/object'
|
2
|
+
require "evernote_utils/array"
|
3
|
+
require "evernote_utils/filter"
|
2
4
|
|
3
5
|
module ENUtils
|
4
6
|
class Note < Evernote::EDAM::Type::Note
|
@@ -40,31 +42,8 @@ module ENUtils
|
|
40
42
|
def self.where(core, options={})
|
41
43
|
offset = options.delete(:offset) || 0
|
42
44
|
limit = options.delete(:limit) || DEFAULT_LIMIT
|
43
|
-
core.notestore.findNotes(core.token,
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def self.build_filter(options={})
|
50
|
-
filter = Evernote::EDAM::NoteStore::NoteFilter.new
|
51
|
-
if (notebook = options[:notebook])
|
52
|
-
notebook_guid = notebook.is_a?(ENUtils::Notebook) ? notebook.guid : notebook
|
53
|
-
filter.notebookGuid = notebook_guid
|
54
|
-
end
|
55
|
-
if (tags = options[:tags]) || (tag = options[:tag])
|
56
|
-
tag_guids = (tags || [tag]).map{|t| t.is_a?(ENUtils::Tag) ? t.guid : t }
|
57
|
-
filter.tagGuids = tag_guids
|
58
|
-
end
|
59
|
-
filter.words = options[:words] if options[:words]
|
60
|
-
filter.order = OrderFields[options[:order].to_sym] if available_order?(options[:order])
|
61
|
-
filter.ascending = options[:asc] if options[:asc]
|
62
|
-
filter
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.available_order?(value)
|
66
|
-
return false if value.nil?
|
67
|
-
OrderFields.keys.include?(value.to_sym)
|
45
|
+
result = core.notestore.findNotes(core.token, NoteFilter.build(options), offset, limit).notes.map{|n| new(n) }
|
46
|
+
NoteList.new(core, result, options)
|
68
47
|
end
|
69
48
|
|
70
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evernote_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- memerelics
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description: A thin OOP-friendly wrapper of Evernote Ruby SDK.
|
112
112
|
email:
|
113
113
|
- takuya21hashimoto@gmail.com
|
114
114
|
executables: []
|
@@ -122,6 +122,8 @@ files:
|
|
122
122
|
- Rakefile
|
123
123
|
- evernote_utils.gemspec
|
124
124
|
- lib/evernote_utils.rb
|
125
|
+
- lib/evernote_utils/array.rb
|
126
|
+
- lib/evernote_utils/filter.rb
|
125
127
|
- lib/evernote_utils/note.rb
|
126
128
|
- lib/evernote_utils/notebook.rb
|
127
129
|
- lib/evernote_utils/tag.rb
|
@@ -151,7 +153,7 @@ rubyforge_project:
|
|
151
153
|
rubygems_version: 2.0.14
|
152
154
|
signing_key:
|
153
155
|
specification_version: 4
|
154
|
-
summary:
|
156
|
+
summary: A thin OOP-friendly wrapper of Evernote Ruby SDK.
|
155
157
|
test_files:
|
156
158
|
- spec/evernote_utils_spec.rb
|
157
159
|
- spec/spec_helper.rb
|