evertils-common 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e57d1a952e6919cb2e454985c29c01786127dd8
4
- data.tar.gz: acb73cef67dcb5b2614b26d631824a00f72bf304
3
+ metadata.gz: b70b024e3851efb6d76aed24af44ffc8c3327369
4
+ data.tar.gz: 2e0c3360da532242d17099b7c6cdaf987bb55814
5
5
  SHA512:
6
- metadata.gz: ca62fed087792f4fb6b11b3cad3e73db0431a5153c0442c8eb4f167fcf93ab99d2221df0ef819b51708aba08845936b5930e14393c753177fa39fced5807c5ca
7
- data.tar.gz: 5ef8ceb6814ad67cba541375284b7787e517467122f3f848d383707bb7ad496d9c849fa19f6e5a8a4f82b7d74bb4c1519f9b97476c5bdf679e24df1adf31fd2d
6
+ metadata.gz: c8e2ddbc9c861da1ae85f6b68c48a7d3edf3ad4766db91df045bbd19375d8f5db71ff93a3474f415c2ede1ec0c448915ca950c0eb1363e230a1f6a3ed77e171f
7
+ data.tar.gz: 623c1cf08c20ea33bb832e7a15cc833f49e637ef6ef541cb422ef8fce2daec1596b36e90f038fd5054bc2d7527272ef7b877ee5c8b28c82b5d9dd3702506538a
data/README.md CHANGED
@@ -6,26 +6,27 @@ Evertils::Common is an abstraction library for interacting with the Evernote API
6
6
 
7
7
  ```ruby
8
8
  gem 'evertils-common'
9
- ```
10
9
 
11
- And then execute:
10
+ # or...
11
+ gem install evertils-common
12
+ ```
12
13
 
13
- $ bundle
14
+ Then add the following to your ~/.bash_profile
14
15
 
15
- Or install it yourself as:
16
+ ```shell
17
+ export EVERTILS_TOKEN="token_goes_here"
18
+ ```
16
19
 
17
- $ gem install evertils-common
20
+ Get your Evernote Developer Tokens [here](https://www.evernote.com/Login.action?targetUrl=%2Fapi%2FDeveloperToken.action).
18
21
 
19
22
  ## Usage
20
23
 
21
- TODO: Write usage instructions here
24
+ Please see the code samples in the [wiki](https://github.com/aapis/evertils-common/wiki).
22
25
 
23
26
  ## Development
24
27
 
25
28
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
29
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
30
  ## Contributing
30
31
 
31
32
  Bug reports and pull requests are welcome on GitHub at https://github.com/aapis/evertils-common.
@@ -43,6 +43,14 @@ module Evertils
43
43
  def user
44
44
  @@user.getUser(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
45
45
  end
46
+
47
+ def call(func, *args)
48
+ if args.size > 0
49
+ @store.method(func.to_s).call(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, *args)
50
+ else
51
+ @store.method(func.to_s).call(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
52
+ end
53
+ end
46
54
  end
47
55
  end
48
56
  end
@@ -1,13 +1,7 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Note
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
- end
4
+ class Note < Entity::Base
11
5
 
12
6
  def create_from_yml(full_path)
13
7
  begin
@@ -38,9 +32,7 @@ module Evertils
38
32
  our_note.tagNames = []
39
33
 
40
34
  # only join when required
41
- if body.is_a? Array
42
- body = body.join
43
- end
35
+ body = body.join if body.is_a? Array
44
36
 
45
37
  # a file was requested, lets prepare it for storage
46
38
  if !file.nil?
@@ -60,22 +52,17 @@ module Evertils
60
52
 
61
53
  nb = Entity::Notebook.new
62
54
  parent_notebook = nb.find(p_notebook_name)
63
-
64
- if parent_notebook.nil?
65
- parent_notebook = @evernote.getDefaultNotebook(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
66
- end
55
+ parent_notebook = @evernote.call(:getDefaultNotebook) if parent_notebook.nil?
67
56
 
68
- ## parent_notebook is optional; if omitted, default notebook is used
69
- if parent_notebook.is_a? ::Evernote::EDAM::Type::Notebook
70
- our_note.notebookGuid = parent_notebook.guid
71
- end
57
+ # parent_notebook is optional; if omitted, default notebook is used
58
+ our_note.notebookGuid = parent_notebook.guid if parent_notebook.is_a? ::Evernote::EDAM::Type::Notebook
72
59
 
73
- ## Attempt to create note in Evernote account
60
+ # Attempt to create note in Evernote account
74
61
  begin
75
- output[:note] = @evernote.createNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, our_note)
62
+ output[:note] = @evernote.call(:createNote, our_note)
76
63
 
77
64
  if share_note
78
- shareKey = @evernote.shareNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, output[:note].guid)
65
+ shareKey = @evernote.call(:shareNote, output[:note].guid)
79
66
  output[:share_url] = "https://#{Evertils::Common::EVERNOTE_HOST}/shard/#{@model.shardId}/sh/#{output[:note].guid}/#{shareKey}"
80
67
  end
81
68
  rescue ::Evernote::EDAM::Error::EDAMUserException => edue
@@ -88,13 +75,7 @@ module Evertils
88
75
  Notify.error "EDAMNotFoundException: Invalid parent notebook GUID"
89
76
  end
90
77
 
91
- # A parent notebook object exists, otherwise it was saved to the default
92
- # notebook
93
- if parent_notebook.is_a? ::Evernote::EDAM::Type::Notebook
94
- Notify.success("#{parent_notebook.stack}/#{parent_notebook.name}/#{our_note.title} created")
95
- else
96
- Notify.success("DEFAULT_NOTEBOOK/#{our_note.title} created")
97
- end
78
+ Notify.success("#{parent_notebook.stack}/#{parent_notebook.name}/#{our_note.title} created")
98
79
 
99
80
  output
100
81
  end
@@ -107,39 +88,31 @@ module Evertils
107
88
  def destroy(name)
108
89
  note = find(name).guid
109
90
 
110
- @evernote.deleteNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, note)
91
+ @evernote.call(:deleteNote, note)
111
92
  end
112
93
 
113
94
  def expunge(name)
114
95
  note = find(name).guid
115
96
 
116
- @evernote.expungeNote(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, note)
97
+ @evernote.call(:expungeNote, note)
117
98
  end
118
99
 
119
100
  def find(name)
120
101
  filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
121
102
  filter.words = name
122
103
 
123
- result = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new
124
- result.includeTitle = true
125
- result.includeUpdated = true
126
- result.includeTagGuids = true
104
+ spec = ::Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new
105
+ spec.includeTitle = true
106
+ spec.includeUpdated = true
107
+ spec.includeTagGuids = true
127
108
 
128
- result = @evernote.findNotesMetadata(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, filter, 0, 1, result)
109
+ result = @evernote.call(:findNotesMetadata, filter, 0, 1, spec)
129
110
 
130
111
  if result.totalNotes > 0
131
112
  result.notes[0]
132
113
  end
133
114
  end
134
115
 
135
- private
136
-
137
- def has_required_fields(hash, required)
138
- hash.keys.each do |key|
139
- required.include? key
140
- end
141
- end
142
-
143
116
  end
144
117
  end
145
118
  end
@@ -1,16 +1,9 @@
1
- require 'evertils/common/authentication'
2
1
  require 'evertils/common/entity/notebooks'
3
2
 
4
3
  module Evertils
5
4
  module Common
6
5
  module Entity
7
- class Notebook
8
-
9
- def initialize
10
- @evernote = Authentication.new.store
11
-
12
- self
13
- end
6
+ class Notebook < Entity::Base
14
7
 
15
8
  def find(name)
16
9
  @notebook = nil
@@ -34,13 +27,13 @@ module Evertils
34
27
  notebook.name = "#{stack}/#{name}"
35
28
  end
36
29
 
37
- @evernote.createNotebook(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, notebook)
30
+ @evernote.call(:createNotebook, notebook)
38
31
  end
39
32
 
40
33
  def expunge(name)
41
34
  nb = find(name)
42
35
 
43
- @evernote.expungeNotebook(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, nb.guid)
36
+ @evernote.call(:expungeNotebook, nb.guid)
44
37
  end
45
38
 
46
39
  def notes(guid = nil)
@@ -51,14 +44,6 @@ module Evertils
51
44
  notes.find(nil, @notebook.guid)
52
45
  end
53
46
 
54
- private
55
-
56
- def has_required_fields(hash, required)
57
- hash.keys.each do |key|
58
- required.include? key
59
- end
60
- end
61
-
62
47
  end
63
48
  end
64
49
  end
@@ -1,18 +1,10 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Notebooks
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Notebooks < Entity::Base
13
5
 
14
6
  def all
15
- @evernote.listNotebooks(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
7
+ @evernote.call(:listNotebooks)
16
8
  end
17
9
 
18
10
  def create_from_yml(full_path)
@@ -40,14 +32,6 @@ module Evertils
40
32
  end
41
33
  end
42
34
 
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
-
51
35
  end
52
36
  end
53
37
  end
@@ -1,22 +1,14 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Notes
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Notes < Entity::Base
13
5
 
14
6
  def findAll(title, notebook = nil)
15
7
  filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
16
8
  filter.words = "intitle:#{title}" if title
17
9
  filter.notebookGuid = notebook if notebook
18
10
 
19
- @evernote.findNotes(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, filter, nil, 300)
11
+ @evernote.call(:findNotes, filter, nil, 300)
20
12
  end
21
13
 
22
14
  def findOne(title, notebook = nil)
@@ -24,7 +16,7 @@ module Evertils
24
16
  filter.words = "intitle:#{title}" if title
25
17
  filter.notebookGuid = notebook if notebook
26
18
 
27
- @evernote.findNotes(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, filter, nil, 1)
19
+ @evernote.call(:findNotes, filter, nil, 1)
28
20
  end
29
21
 
30
22
  end
@@ -1,15 +1,7 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Stack
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Stack < Entity::Base
13
5
 
14
6
  def create_from_yml(full_path)
15
7
  begin
@@ -36,14 +28,6 @@ module Evertils
36
28
  end
37
29
  end
38
30
 
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
31
  end
48
32
  end
49
33
  end
@@ -1,18 +1,10 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Sync
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Sync < Entity::Base
13
5
 
14
6
  def state
15
- @evernote.getSyncState()
7
+ @evernote.call(:getSyncState)
16
8
  end
17
9
 
18
10
  end
@@ -1,15 +1,7 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Tag
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Tag < Entity::Base
13
5
 
14
6
  def find(name)
15
7
  @tag = nil
@@ -28,13 +20,13 @@ module Evertils
28
20
  tag = ::Evernote::EDAM::Type::Tag.new
29
21
  tag.name = name
30
22
 
31
- @evernote.createTag(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, tag)
23
+ @evernote.call(:createTag, tag)
32
24
  end
33
25
 
34
26
  def expunge(name)
35
27
  tag = find(name)
36
28
 
37
- @evernote.expungeTag(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN, tag.guid)
29
+ @evernote.call(:expungeTag, tag.guid)
38
30
  end
39
31
 
40
32
  end
@@ -1,18 +1,10 @@
1
- require 'evertils/common/authentication'
2
-
3
1
  module Evertils
4
2
  module Common
5
3
  module Entity
6
- class Tags
7
-
8
- def initialize
9
- @evernote = Authentication.new.store
10
-
11
- self
12
- end
4
+ class Tags < Entity::Base
13
5
 
14
6
  def all
15
- @evernote.listTags(Evertils::Common::EVERNOTE_DEVELOPER_TOKEN)
7
+ @evernote.call(:listTags)
16
8
  end
17
9
 
18
10
  end
@@ -0,0 +1,22 @@
1
+ require 'evertils/common/authentication'
2
+
3
+ module Evertils
4
+ module Common
5
+ module Entity
6
+ class Base
7
+
8
+ def initialize
9
+ @evernote = Authentication.new
10
+ self
11
+ end
12
+
13
+ def has_required_fields(hash, required)
14
+ hash.keys.each do |key|
15
+ required.include? key
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require 'evertils/common/entity/notebook'
2
+ require 'evertils/common/entity/notebooks'
3
+ require 'evertils/common/entity/notes'
4
+ require 'evertils/common/entity/note'
5
+ require 'evertils/common/entity/tag'
6
+ require 'evertils/common/entity/tags'
7
+ require 'evertils/common/entity/sync'
8
+
9
+ module Evertils
10
+ module Common
11
+ module Queries
12
+ class Backup
13
+
14
+ def files(*files)
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ require 'evertils/common/entity/notebook'
2
+ require 'evertils/common/entity/notebooks'
3
+ require 'evertils/common/entity/notes'
4
+ require 'evertils/common/entity/note'
5
+ require 'evertils/common/entity/tag'
6
+ require 'evertils/common/entity/tags'
7
+ require 'evertils/common/entity/sync'
8
+
9
+ module Evertils
10
+ module Common
11
+ module Queries
12
+ class Time
13
+
14
+ def notes_created_in_range(start, finish)
15
+
16
+ end
17
+
18
+ def notes_updated_in_range(start, finish)
19
+
20
+ end
21
+
22
+ def notebooks_created_in_range(start, finish)
23
+
24
+ end
25
+
26
+ def notebooks_updated_in_range(start, finish)
27
+
28
+ end
29
+
30
+ def last_sync
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  module Evertils
2
2
  module Common
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
5
5
  end
@@ -2,8 +2,11 @@ require 'evernote-thrift'
2
2
  require 'notifaction'
3
3
  require 'yaml'
4
4
  require 'evertils/common/enml'
5
+ require 'evertils/common/entity'
5
6
  require 'evertils/common/version'
7
+ require 'evertils/common/queries/backup'
6
8
  require 'evertils/common/queries/simple'
9
+ require 'evertils/common/queries/time'
7
10
 
8
11
  module Evertils
9
12
  module Common
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.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
@@ -14,56 +14,56 @@ dependencies:
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: evernote-thrift
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: notifaction
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Evernote utilities for your CLI workflow
@@ -75,7 +75,7 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
- - .gitignore
78
+ - ".gitignore"
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
81
  - README.md
@@ -86,6 +86,7 @@ files:
86
86
  - lib/evertils/common.rb
87
87
  - lib/evertils/common/authentication.rb
88
88
  - lib/evertils/common/enml.rb
89
+ - lib/evertils/common/entity.rb
89
90
  - lib/evertils/common/entity/note.rb
90
91
  - lib/evertils/common/entity/notebook.rb
91
92
  - lib/evertils/common/entity/notebooks.rb
@@ -94,7 +95,9 @@ files:
94
95
  - lib/evertils/common/entity/sync.rb
95
96
  - lib/evertils/common/entity/tag.rb
96
97
  - lib/evertils/common/entity/tags.rb
98
+ - lib/evertils/common/queries/backup.rb
97
99
  - lib/evertils/common/queries/simple.rb
100
+ - lib/evertils/common/queries/time.rb
98
101
  - lib/evertils/common/version.rb
99
102
  homepage: http://rubygems.org/gems/evertils-common
100
103
  licenses:
@@ -106,12 +109,12 @@ require_paths:
106
109
  - lib
107
110
  required_ruby_version: !ruby/object:Gem::Requirement
108
111
  requirements:
109
- - - '>='
112
+ - - ">="
110
113
  - !ruby/object:Gem::Version
111
114
  version: '0'
112
115
  required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  requirements:
114
- - - '>='
117
+ - - ">="
115
118
  - !ruby/object:Gem::Version
116
119
  version: '0'
117
120
  requirements: []