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 +4 -4
- data/lib/controllers/generate.rb +14 -7
- data/lib/helpers/formatting.rb +21 -5
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dd3665b2b457314b37dab1ba7758e34ecce2785
|
4
|
+
data.tar.gz: 9f703b41beb6ad89d2cae27e94e1b2de91e5bf8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 087b3e62dcc315a87a247926ccf6f9e9de6a7d49b4a0a88e2564dbdaee64cf490288a7c53658679789b1889bf837716a75227b52d4f68348b65e57ed0d98d019
|
7
|
+
data.tar.gz: 4d561b8df58874305aab10a16d40a9388833da3782f753a77a67778e4081bedf11628b2646282cd790f80995d68351f87e2b57f2c0dae8ef3b49b5b96517b377
|
data/lib/controllers/generate.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/helpers/formatting.rb
CHANGED
@@ -23,8 +23,16 @@ module Evertils
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Template file for note body
|
26
|
-
def template_contents
|
27
|
-
|
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
|
-
|
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[
|
75
|
+
tmpl = $config.custom_templates[type]
|
60
76
|
|
61
77
|
if !tmpl.nil?
|
62
78
|
rval = $config.custom_path
|
data/lib/version.rb
CHANGED