evertils 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fd3248143eff7e8b781638d5099de4e5c05535a
4
- data.tar.gz: 5b2f2eef86e3159a1039a23bac1c1f5825cd1828
3
+ metadata.gz: 6dd3665b2b457314b37dab1ba7758e34ecce2785
4
+ data.tar.gz: 9f703b41beb6ad89d2cae27e94e1b2de91e5bf8f
5
5
  SHA512:
6
- metadata.gz: 4aca086dff5f7374d585f7311be1c506be32e6df2f1557e84c8728f548d8ed2930555c8991e5483af051361ce3c3b77697422e3514b5e6b62cd2858ca274d164
7
- data.tar.gz: 059af51da8b902f6a751ac41b56483d5e349cdf1fb0f848da0a84d729ad8f74a1a6cc29016beae3b33755a852e3904f7cbae58f7617aaf25fc45a4762fc7c33e
6
+ metadata.gz: 087b3e62dcc315a87a247926ccf6f9e9de6a7d49b4a0a88e2564dbdaee64cf490288a7c53658679789b1889bf837716a75227b52d4f68348b65e57ed0d98d019
7
+ data.tar.gz: 4d561b8df58874305aab10a16d40a9388833da3782f753a77a67778e4081bedf11628b2646282cd790f80995d68351f87e2b57f2c0dae8ef3b49b5b96517b377
@@ -36,7 +36,7 @@ module Evertils
36
36
  # generate daily notes
37
37
  def daily
38
38
  title = @format.date_templates[NOTEBOOK_DAILY]
39
- body = @format.template_contents
39
+ body = @format.template_contents(NOTEBOOK_DAILY)
40
40
  body += to_enml($config.custom_sections[NOTEBOOK_DAILY]) unless $config.custom_sections.nil?
41
41
  parent_notebook = NOTEBOOK_DAILY
42
42
 
@@ -46,7 +46,7 @@ module Evertils
46
46
  # generate weekly notes
47
47
  def weekly
48
48
  title = @format.date_templates[NOTEBOOK_WEEKLY]
49
- body = @format.template_contents
49
+ body = @format.template_contents(NOTEBOOK_WEEKLY)
50
50
  body += to_enml($config.custom_sections[NOTEBOOK_WEEKLY]) unless $config.custom_sections.nil?
51
51
  parent_notebook = NOTEBOOK_WEEKLY
52
52
 
@@ -66,7 +66,7 @@ module Evertils
66
66
  # generate monthly notes
67
67
  def monthly
68
68
  title = @format.date_templates[NOTEBOOK_MONTHLY]
69
- body = @format.template_contents
69
+ body = @format.template_contents(NOTEBOOK_MONTHLY)
70
70
  body += to_enml($config.custom_sections[NOTEBOOK_MONTHLY]) unless $config.custom_sections.nil?
71
71
  parent_notebook = NOTEBOOK_MONTHLY
72
72
 
@@ -82,7 +82,7 @@ module Evertils
82
82
  Notify.error("Name argument is required", {}) if @name.nil?
83
83
 
84
84
  title = "#{@name} #{DateTime.now.strftime('%m-%Y')}"
85
- body = @format.template_contents
85
+ body = @format.template_contents(NOTEBOOK_MTS)
86
86
  body += to_enml($config.custom_sections[NOTEBOOK_MTS]) unless $config.custom_sections.nil?
87
87
  parent_notebook = NOTEBOOK_MTS
88
88
 
@@ -103,11 +103,19 @@ module Evertils
103
103
  # generate priority queue notes
104
104
  def pq
105
105
  title = @format.date_templates[NOTEBOOK_PRIORITY_QUEUE]
106
- body = @format.template_contents
106
+ body = @format.template_contents(NOTEBOOK_PRIORITY_QUEUE)
107
107
  body += to_enml($config.custom_sections[NOTEBOOK_PRIORITY_QUEUE]) unless $config.custom_sections.nil?
108
108
  parent_notebook = NOTEBOOK_PRIORITY_QUEUE
109
109
 
110
- note = @model.create_note(title: title, body: body, parent_notebook: parent_notebook)
110
+ @model.create_note(title: title, body: body, parent_notebook: parent_notebook)
111
+ end
112
+
113
+ # creates the notes required to start the day
114
+ # - priority queue
115
+ # - daily
116
+ def morning
117
+ pq
118
+ daily
111
119
  end
112
120
 
113
121
  private
@@ -117,7 +125,6 @@ module Evertils
117
125
  def to_enml(hash)
118
126
  Evertils::Helper::EvernoteENML.with_list(hash)
119
127
  end
120
-
121
128
  end
122
129
  end
123
130
  end
@@ -23,8 +23,16 @@ module Evertils
23
23
  end
24
24
 
25
25
  # Template file for note body
26
- def template_contents
27
- IO.readlines(load_template, :encoding => 'UTF-8').join("").delete!("\n")
26
+ def template_contents(type = nil)
27
+ begin
28
+ raise ArgumentError, "Type is required" if type.nil?
29
+
30
+ IO.readlines(load_template(type), :encoding => 'UTF-8').join("").delete!("\n")
31
+ rescue Errno::ENOENT => e
32
+ Notify.error(e.message)
33
+ rescue ArgumentError => e
34
+ Notify.error(e.message)
35
+ end
28
36
  end
29
37
 
30
38
  # Template string for note title
@@ -50,13 +58,21 @@ module Evertils
50
58
 
51
59
  #
52
60
  # @since 0.3.1
53
- def load_template
54
- default = "#{Evertils::TEMPLATE_DIR}#{command.downcase}.enml"
61
+ def load_template(type)
62
+ template_type_map = {
63
+ :Daily => "daily",
64
+ :Weekly => "weekly",
65
+ :Monthly => "monthly",
66
+ :"Monthly Task Summaries" => "mts",
67
+ :"Priority Queue" => "pq"
68
+ }
69
+
70
+ default = "#{Evertils::TEMPLATE_DIR}#{template_type_map[type]}.enml"
55
71
 
56
72
  return default if $config.custom_templates.nil?
57
73
 
58
74
  rval = default
59
- tmpl = $config.custom_templates[command]
75
+ tmpl = $config.custom_templates[type]
60
76
 
61
77
  if !tmpl.nil?
62
78
  rval = $config.custom_path
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Evertils
2
- VERSION = "0.3.3".freeze
2
+ VERSION = "0.3.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evertils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe