evernote_utils 0.1.0 → 0.1.1

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: d1e1c09e9e0935584b6a41379c739096141e4b18
4
- data.tar.gz: ea9ffa77b7129b6838ad2268a4924fbe6e843ecb
3
+ metadata.gz: 57c0d166e80d636e51953b16e20e5f7db48dea6b
4
+ data.tar.gz: 0400c84673459939b503b9b4316a7e67280b18f4
5
5
  SHA512:
6
- metadata.gz: 01803687ee5b0165c1471c38ea3f06ba963bf239d52d9d3407022659ceaa50103ced7cf3b76489840079c36190613040908d77a251463f0c298fc5474b7238f2
7
- data.tar.gz: b65ce02d5ba3570f55d49dd75a2d6526ded0c7e5d6e3c9e9bc88d7008a16905940f02611c181acb01901b349782c1b05edb7ed4b5825d9b567956890d1b17006
6
+ metadata.gz: 4054c7b549b4e451b2072d07916ca79038c47d7c5aeff611b77b608612ddd7867b1e943cb3bc0ba36dfe3827a282eccb954f89db0c67c6d0336fb75acd27fc71
7
+ data.tar.gz: 5c269300936d85b1569f481cc08f0795376e4fad743973a1c784d0978cbb1f7359e93f3d2db880c1a67e6bba834e7618b81df65220395d9320ede2129edabf9c
data/README.md CHANGED
@@ -146,7 +146,13 @@ note.tags = tags
146
146
  note.title = 'some new title'
147
147
 
148
148
  note.save #=> save to Evernote Cloud
149
- ````
149
+ ```
150
+
151
+ ### crete tag
152
+
153
+ ```ruby
154
+ enutils.create_tag(name: 'mytagname')
155
+ ```
150
156
 
151
157
  ## Planning to do
152
158
 
@@ -61,6 +61,10 @@ module ENUtils
61
61
  Notebook.where(self, options)
62
62
  end
63
63
 
64
+ def create_tag(attrs)
65
+ Tag.create(self, attrs)
66
+ end
67
+
64
68
  def tag(name=nil)
65
69
  return nil unless name
66
70
  Tag.find_by_name(self, name)
@@ -109,6 +109,15 @@ module ENUtils
109
109
  attrs[:notebookGuid] = notebook.guid if notebook.is_a? ENUtils::Notebook
110
110
  attrs[:notebookGuid] = notebook if notebook.is_a? String
111
111
  end
112
+ if tags = attrs.delete(:tags) || attrs.delete(:tag)
113
+ tags = [tags] unless tags.is_a? Array
114
+ attrs[:tagGuids] ||= []; attrs[:tagNames] ||= []
115
+ tags.each do |tag|
116
+ attrs[:tagGuids] << tag.guid if tag.is_a?(ENUtils::Tag)
117
+ attrs[:tagGuids] << tag if tag.is_a?(String) && tag.match(ENUtils::GUID_REGEXP)
118
+ attrs[:tagNames] << tag if tag.is_a?(String) && !tag.match(ENUtils::GUID_REGEXP)
119
+ end
120
+ end
112
121
  attrs[:content] = html_to_enml(attrs[:content]) if attrs.delete(:from_html)
113
122
  attrs
114
123
  end
@@ -14,6 +14,18 @@ module ENUtils
14
14
  @updateSequenceNum = edam_tag.updateSequenceNum
15
15
  end
16
16
 
17
+ # https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_createTag
18
+ def self.create(core, attrs)
19
+ edam_tag = Evernote::EDAM::Type::Tag.new(attrs)
20
+ begin
21
+ res = core.notestore.createTag(core.token, edam_tag)
22
+ rescue Evernote::EDAM::Error::EDAMUserException
23
+ # build error message because $!.message is nil
24
+ raise $!.class, "[ErrorCode: #{$!.errorCode}] #{$!.parameter}", $!.backtrace
25
+ end
26
+ new(core, res)
27
+ end
28
+
17
29
  def notes(options={})
18
30
  Note.where(@core, options.merge(tag: self))
19
31
  end
@@ -1,3 +1,3 @@
1
1
  module ENUtils
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evernote_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - memerelics
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evernote-thrift