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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22dd994d7ac10f3862a2d5ebea103ea136864a3e8b9f58c4696a24df4c3fd6b3
4
- data.tar.gz: 513b9d7f97fa5bea2796267734dc5ff759fc1d3c204a5f01d69c189998f5ddd9
3
+ metadata.gz: 0f8b45578676e4d762f853e3d756b1fb5c8e303d24d66b2300f5f6c9493615b1
4
+ data.tar.gz: 62faf643f539241e36ccbb34998c529ec5efd032603bedd273a2a777b37df886
5
5
  SHA512:
6
- metadata.gz: 9f958b628108cba980269b5a9cfe58ed721523f6104045b2378eabe34a95b4b6fc190dde97e01d3b070565896342b93359acb718284432c763552d497d143a6c
7
- data.tar.gz: 21b87e63f9412b83fcc12039bfe44e9f678d098e479ecbc2944dacd2efbbdbeacd657e2768270190c28489d07452bb6c7155454afdec15cf91bb61d7c1c61f64
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] unless conf[:sections][:header] == 'nil'
24
- conf[:sections][:body]&.map { |el| note_content += "<h2>#{el}</h2>" }
25
- note_content += conf[:sections][:footer] unless conf[:sections][:footer] == 'nil'
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
@@ -1,5 +1,5 @@
1
1
  module Evertils
2
2
  module Common
3
- VERSION = '0.3.10'.freeze
3
+ VERSION = '0.3.11'.freeze
4
4
  end
5
5
  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.10
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-10 00:00:00.000000000 Z
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake