evertils-common 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evertils/common/model/note.rb +25 -5
- data/lib/evertils/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8b45578676e4d762f853e3d756b1fb5c8e303d24d66b2300f5f6c9493615b1
|
4
|
+
data.tar.gz: 62faf643f539241e36ccbb34998c529ec5efd032603bedd273a2a777b37df886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335e2dbc236f7adb1a34482d4e9d1c5833ff004634bad41933097deb2f7c4213e740fc19f95d784f82627043482e520f8fc25ebe7880edea5ad4a4a3df469ba8
|
7
|
+
data.tar.gz: 96d6df7189d9f9dd75aa920e408738400dd8ed6fc8b8a11cb262c317148a8f37c46d30936825949fa8a1b94653568c919dc0171d6a84eac2c8dcb6620c50df83
|
@@ -6,12 +6,13 @@ module Evertils
|
|
6
6
|
module Model
|
7
7
|
class Note
|
8
8
|
attr_accessor :shareable, :updated, :colour
|
9
|
+
attr_reader :conf
|
9
10
|
|
10
11
|
#
|
11
12
|
# @since 0.3.3
|
12
13
|
def initialize(conf = {})
|
14
|
+
@conf = conf
|
13
15
|
raise "Title (title) is a required field" unless conf[:title]
|
14
|
-
raise "Body (body) is a required field" unless conf[:sections][:body]
|
15
16
|
|
16
17
|
@note = ::Evernote::EDAM::Type::Note.new
|
17
18
|
|
@@ -20,10 +21,10 @@ module Evertils
|
|
20
21
|
self.created = conf[:created_on] || DateTime.now
|
21
22
|
|
22
23
|
note_content = ''
|
23
|
-
note_content += conf[:sections][:header]
|
24
|
-
conf[:sections][:body]&.map { |el| note_content += "<h2>#{el}</h2>" }
|
25
|
-
note_content += conf[:sections][:footer]
|
26
|
-
self.body = note_content
|
24
|
+
note_content += conf[:sections][:header] if valid_header?
|
25
|
+
conf[:sections][:body]&.map { |el| note_content += "<h2>#{el}</h2>" } if valid_body?
|
26
|
+
note_content += conf[:sections][:footer] if valid_footer?
|
27
|
+
self.body = conf[:content] || note_content
|
27
28
|
|
28
29
|
@note.title = conf[:title]
|
29
30
|
@note.tagNames = conf[:tags] || []
|
@@ -118,6 +119,25 @@ module Evertils
|
|
118
119
|
notebook = query.entity
|
119
120
|
@note.notebookGuid = notebook.guid if query
|
120
121
|
end
|
122
|
+
|
123
|
+
def valid_header?
|
124
|
+
sections = conf.key?(:sections)
|
125
|
+
header = sections && conf[:sections].key?(:header)
|
126
|
+
|
127
|
+
header && conf[:sections][:header] == 'nil'
|
128
|
+
end
|
129
|
+
|
130
|
+
def valid_body?
|
131
|
+
sections = conf.key?(:sections)
|
132
|
+
sections && conf[:sections].key?(:header)
|
133
|
+
end
|
134
|
+
|
135
|
+
def valid_footer?
|
136
|
+
sections = conf.key?(:sections)
|
137
|
+
footer = sections && conf[:sections].key?(:footer)
|
138
|
+
|
139
|
+
footer && conf[:sections][:footer] == 'nil'
|
140
|
+
end
|
121
141
|
end
|
122
142
|
end
|
123
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evertils-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Priebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|