evertils 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/evertils +17 -17
- data/lib/controller.rb +0 -6
- data/lib/controllers/generate.rb +27 -136
- data/lib/helper.rb +2 -2
- data/lib/helpers/api-enml-handler.rb +46 -0
- data/lib/router.rb +0 -18
- data/lib/type.rb +35 -0
- data/lib/types/daily.rb +19 -0
- data/lib/types/monthly-task-summary.rb +37 -0
- data/lib/types/monthly.rb +37 -0
- data/lib/types/priority-queue.rb +86 -0
- data/lib/types/weekly.rb +38 -0
- data/lib/version.rb +1 -1
- metadata +8 -4
- data/lib/helpers/generate.rb +0 -39
- data/lib/model.rb +0 -26
- data/lib/model_data.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bf3d2b3c26ba0ece79f8aa12e697f5cd7edae75
|
4
|
+
data.tar.gz: 2fe5780fb6e21b93c3afb34f8dbd6f934f812f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57861f7047caa63344d7a55f0f0a0f99a9d67d4d2f84463034a68ddf0633c09f4ec9b8aa7478ea0c28fb0057cdca6ee9fd38b581045e525bdc91c992bce83b36
|
7
|
+
data.tar.gz: c7ffdb0d40287f62da1ad3291b882e29af084b4276de62a8c1200e56a3e28e12b6b0b408d96d7dfdaa164becbc828895cd48a134d30123b1cdf7ba0e2b6b5465
|
data/bin/evertils
CHANGED
@@ -18,23 +18,23 @@ require 'yaml'
|
|
18
18
|
require 'nokogiri'
|
19
19
|
|
20
20
|
# include required files
|
21
|
-
require_relative '../lib/kernel
|
22
|
-
require_relative '../lib/version
|
23
|
-
require_relative '../lib/
|
24
|
-
require_relative '../lib/helpers/
|
25
|
-
require_relative '../lib/
|
26
|
-
require_relative '../lib/
|
27
|
-
require_relative '../lib/
|
28
|
-
require_relative '../lib/
|
29
|
-
require_relative '../lib/
|
30
|
-
require_relative '../lib/
|
31
|
-
require_relative '../lib/
|
32
|
-
require_relative '../lib/
|
33
|
-
require_relative '../lib/
|
34
|
-
require_relative '../lib/
|
35
|
-
require_relative '../lib/helpers/formatting
|
36
|
-
require_relative '../lib/helpers/evernote-enml
|
37
|
-
require_relative '../lib/helper
|
21
|
+
require_relative '../lib/kernel'
|
22
|
+
require_relative '../lib/version'
|
23
|
+
require_relative '../lib/type'
|
24
|
+
require_relative '../lib/helpers/time'
|
25
|
+
require_relative '../lib/helpers/results'
|
26
|
+
require_relative '../lib/helpers/api-enml-handler'
|
27
|
+
require_relative '../lib/log'
|
28
|
+
require_relative '../lib/config'
|
29
|
+
require_relative '../lib/request'
|
30
|
+
require_relative '../lib/utils'
|
31
|
+
require_relative '../lib/logs'
|
32
|
+
require_relative '../lib/command'
|
33
|
+
require_relative '../lib/controller'
|
34
|
+
require_relative '../lib/router'
|
35
|
+
require_relative '../lib/helpers/formatting'
|
36
|
+
require_relative '../lib/helpers/evernote-enml'
|
37
|
+
require_relative '../lib/helper'
|
38
38
|
|
39
39
|
# Modify configuration options here
|
40
40
|
$config = Evertils::Cfg.new
|
data/lib/controller.rb
CHANGED
@@ -7,11 +7,6 @@ module Evertils
|
|
7
7
|
|
8
8
|
# Perform pre-run tasks
|
9
9
|
def pre_exec
|
10
|
-
# interface with the Evernote API so we can use it later
|
11
|
-
@model = Evertils::Common::Query::Simple.new
|
12
|
-
|
13
|
-
@format = Evertils::Helper.load('formatting')
|
14
|
-
|
15
10
|
OptionParser.new do |opt|
|
16
11
|
opt.banner = "#{Evertils::PACKAGE_NAME} controller command [...-flags]"
|
17
12
|
|
@@ -38,7 +33,6 @@ module Evertils
|
|
38
33
|
|
39
34
|
# Determines if the command can execute
|
40
35
|
def can_exec?(command = nil, name = nil)
|
41
|
-
@model = Evertils::Model.const_get(command.capitalize).new rescue nil
|
42
36
|
@helper = Evertils::Helper.const_get(command.capitalize).new rescue nil
|
43
37
|
@methods_require_internet = []
|
44
38
|
|
data/lib/controllers/generate.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
+
require_relative '../types/priority-queue'
|
2
|
+
require_relative '../types/monthly-task-summary'
|
3
|
+
require_relative '../types/daily'
|
4
|
+
require_relative '../types/weekly'
|
5
|
+
require_relative '../types/monthly'
|
6
|
+
|
1
7
|
module Evertils
|
2
8
|
module Controller
|
3
9
|
class Generate < Controller::Base
|
4
10
|
attr_accessor :force, :start, :name
|
5
11
|
|
6
|
-
# required user-created notebooks
|
7
|
-
NOTEBOOK_DAILY = :Daily
|
8
|
-
NOTEBOOK_WEEKLY = :Weekly
|
9
|
-
NOTEBOOK_MONTHLY = :Monthly
|
10
|
-
NOTEBOOK_DEPLOYMENT = :Deployments
|
11
|
-
NOTEBOOK_MTS = :'Monthly Task Summaries'
|
12
|
-
NOTEBOOK_PRIORITY_QUEUE = :'Priority Queue'
|
13
|
-
|
14
12
|
def pre_exec
|
15
13
|
@methods_require_internet.push(:daily, :weekly, :monthly, :mts)
|
16
14
|
|
@@ -27,160 +25,53 @@ module Evertils
|
|
27
25
|
|
28
26
|
# generate daily notes
|
29
27
|
def daily
|
30
|
-
|
31
|
-
|
32
|
-
body += to_enml($config.custom_sections[NOTEBOOK_DAILY]) unless $config.custom_sections.nil?
|
33
|
-
parent_notebook = NOTEBOOK_DAILY
|
34
|
-
|
35
|
-
@model.create_note(title: title, body: body, parent_notebook: parent_notebook)
|
28
|
+
note = Type::Daily.new
|
29
|
+
note.create
|
36
30
|
end
|
37
31
|
|
38
32
|
# generate weekly notes
|
39
33
|
def weekly
|
40
|
-
|
41
|
-
|
42
|
-
body += to_enml($config.custom_sections[NOTEBOOK_WEEKLY]) unless $config.custom_sections.nil?
|
43
|
-
parent_notebook = NOTEBOOK_WEEKLY
|
44
|
-
|
45
|
-
note = @model.create_note(title: title, body: body, parent_notebook: parent_notebook)
|
46
|
-
|
47
|
-
# BUG: inability to tag notes lies somewhere in evertils-common,
|
48
|
-
# specifically in how note.tag works
|
49
|
-
# As this is non-functional, lets not run it - commented out for now
|
50
|
-
# tag_manager = Evertils::Common::Manager::Tag.instance
|
51
|
-
# week_tag = tag_manager.find_or_create("week-#{Date.today.cweek}")
|
52
|
-
# note.tag(week_tag.prop(:name))
|
34
|
+
note = Type::Weekly.new
|
35
|
+
note.create
|
53
36
|
end
|
54
37
|
|
55
38
|
# generate monthly notes
|
56
39
|
def monthly
|
57
|
-
|
58
|
-
|
59
|
-
body += to_enml($config.custom_sections[NOTEBOOK_MONTHLY]) unless $config.custom_sections.nil?
|
60
|
-
parent_notebook = NOTEBOOK_MONTHLY
|
61
|
-
|
62
|
-
note = @model.create_note(title: title, body: body, parent_notebook: parent_notebook)
|
63
|
-
|
64
|
-
# BUG: inability to tag notes lies somewhere in evertils-common,
|
65
|
-
# specifically in how note.tag works
|
66
|
-
# As this is non-functional, lets not run it - commented out for now
|
67
|
-
# tag_manager = Evertils::Common::Manager::Tag.instance
|
68
|
-
# month_tag = tag_manager.find_or_create("month-#{Date.today.month}")
|
69
|
-
# note.tag(month_tag.prop(:name))
|
40
|
+
note = Type::Monthly.new
|
41
|
+
note.create
|
70
42
|
end
|
71
43
|
|
72
44
|
# generate monthly task summary templates
|
73
45
|
def mts
|
74
|
-
Notify.error(
|
46
|
+
Notify.error('Name argument is required', {}) if @name.nil?
|
75
47
|
|
76
|
-
|
77
|
-
|
78
|
-
body += to_enml($config.custom_sections[NOTEBOOK_MTS]) unless $config.custom_sections.nil?
|
79
|
-
parent_notebook = NOTEBOOK_MTS
|
80
|
-
|
81
|
-
# create the note from template
|
82
|
-
mts_note = @model.create_note(title: title, body: body, parent_notebook: parent_notebook)
|
83
|
-
|
84
|
-
# BUG: inability to tag notes lies somewhere in evertils-common,
|
85
|
-
# specifically in how note.tag works
|
86
|
-
# As this is non-functional, lets not run it - commented out for now
|
87
|
-
# tag_manager = Evertils::Common::Manager::Tag.instance
|
88
|
-
# month_tag = tag_manager.find_or_create("month-#{Date.today.month}")
|
89
|
-
# mts_note.tag(month_tag.prop(:name))
|
90
|
-
|
91
|
-
# TODO: commented out until support for multiple tags is added
|
92
|
-
# client_tag = tag_manager.find_or_create(@name)
|
93
|
-
# mts_note.tag(client_tag.prop(:name))
|
48
|
+
note = Type::MonthlyTaskSummary.new(@name)
|
49
|
+
note.create
|
94
50
|
end
|
95
51
|
|
96
52
|
# generate priority queue notes
|
97
53
|
def pq
|
98
|
-
|
99
|
-
|
100
|
-
friday = (Date.today - 3)
|
101
|
-
dow = @format.day_of_week(friday.strftime('%a'))
|
102
|
-
note_title = "Queue For [#{friday.strftime('%B %-d')} - #{dow}]"
|
103
|
-
found = @model.find_note_contents(note_title)
|
104
|
-
|
105
|
-
raise "Queue was not found - #{friday.strftime('%B %-d')}" unless found
|
106
|
-
|
107
|
-
title = @format.date_templates[NOTEBOOK_PRIORITY_QUEUE]
|
108
|
-
content = prepare_enml(found.entity.content)
|
109
|
-
|
110
|
-
@model.create_note(title: title, body: content, parent_notebook: NOTEBOOK_PRIORITY_QUEUE)
|
111
|
-
elsif Date.today.tuesday?
|
112
|
-
# find monday's note
|
113
|
-
monday = (Date.today - 1)
|
114
|
-
dow = @format.day_of_week(monday.strftime('%a'))
|
115
|
-
monday_note_title = "Queue For [#{monday.strftime('%B %-d')} - #{dow}]"
|
116
|
-
monday_note = @model.find_note_contents(monday_note_title)
|
117
|
-
|
118
|
-
if !monday_note.entity.nil?
|
119
|
-
note = monday_note.entity
|
120
|
-
note.title = @format.date_templates[NOTEBOOK_PRIORITY_QUEUE]
|
121
|
-
else
|
122
|
-
# if it does not exist, get friday's note
|
123
|
-
friday = (Date.today - 4)
|
124
|
-
dow = @format.day_of_week(friday.strftime('%a'))
|
125
|
-
note_title = "Queue For [#{friday.strftime('%B %-d')} - #{dow}]"
|
126
|
-
note = @model.find_note_contents(note_title)
|
127
|
-
end
|
128
|
-
|
129
|
-
raise 'Queue was not found' unless note
|
130
|
-
|
131
|
-
content = prepare_enml(note.content)
|
132
|
-
|
133
|
-
@model.create_note(title: note.title, body: content, parent_notebook: NOTEBOOK_PRIORITY_QUEUE)
|
134
|
-
else
|
135
|
-
yest = (Date.today - 1)
|
136
|
-
dow = @format.day_of_week(yest.strftime('%a'))
|
137
|
-
yest_note_title = "Queue For [#{yest.strftime('%B %-d')} - #{dow}]"
|
138
|
-
found = @model.find_note_contents(yest_note_title).entity
|
139
|
-
|
140
|
-
raise "Queue was not found - #{yest.strftime('%B %-d')}" unless found
|
141
|
-
|
142
|
-
title = @format.date_templates[NOTEBOOK_PRIORITY_QUEUE]
|
143
|
-
content = prepare_enml(found.content)
|
144
|
-
content += to_enml($config.custom_sections[NOTEBOOK_PRIORITY_QUEUE]) unless $config.custom_sections.nil?
|
145
|
-
|
146
|
-
@model.create_note(title: title, body: content, parent_notebook: NOTEBOOK_PRIORITY_QUEUE)
|
147
|
-
end
|
54
|
+
note = Type::PriorityQueue.new
|
55
|
+
note.create
|
148
56
|
end
|
149
57
|
|
150
58
|
# creates the notes required to start the day
|
151
59
|
# - priority queue
|
152
60
|
# - daily
|
153
|
-
# - weekly (if today is Monday)
|
61
|
+
# - weekly (if today is Monday and there isn't a weekly log already)
|
62
|
+
# - monthly (if today is the 1st and there isn't a monthly log already)
|
154
63
|
def morning
|
155
|
-
pq
|
156
|
-
|
157
|
-
weekly if Date.today.monday?
|
158
|
-
end
|
159
|
-
|
160
|
-
private
|
161
|
-
|
162
|
-
#
|
163
|
-
# @since 0.3.1
|
164
|
-
def to_enml(hash)
|
165
|
-
Evertils::Helper::EvernoteENML.with_list(hash)
|
166
|
-
end
|
167
|
-
|
168
|
-
#
|
169
|
-
# @since 0.3.5
|
170
|
-
def prepare_enml(content)
|
171
|
-
# remove the xml declaration and DTD
|
172
|
-
content = content.split("\n")
|
173
|
-
content.shift(2)
|
64
|
+
pq = Type::PriorityQueue.new
|
65
|
+
pq.create
|
174
66
|
|
175
|
-
|
176
|
-
|
67
|
+
daily = Type::Daily.new
|
68
|
+
daily.create
|
177
69
|
|
178
|
-
|
179
|
-
|
180
|
-
br.remove
|
181
|
-
end
|
70
|
+
weekly = Type::Weekly.new
|
71
|
+
weekly.create if weekly.should_create?
|
182
72
|
|
183
|
-
|
73
|
+
monthly = Type::Monthly.new
|
74
|
+
monthly.create if monthly.should_create?
|
184
75
|
end
|
185
76
|
end
|
186
77
|
end
|
data/lib/helper.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Helper
|
3
|
+
class ApiEnmlHandler
|
4
|
+
#
|
5
|
+
# @since 0.3.7
|
6
|
+
def initialize(enml = nil)
|
7
|
+
convert_to_xml(enml) if enml
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @since 0.3.7
|
13
|
+
def convert_to_xml(enml)
|
14
|
+
# remove the xml declaration and DTD
|
15
|
+
enml = enml.split("\n")
|
16
|
+
enml.shift(2)
|
17
|
+
|
18
|
+
@xml = Nokogiri::XML::DocumentFragment.parse(enml.join)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# @since 0.3.5
|
24
|
+
def prepare
|
25
|
+
note_xml = @xml.search('en-note')
|
26
|
+
|
27
|
+
# remove <br> tags
|
28
|
+
note_xml.search('br').each(&:remove)
|
29
|
+
|
30
|
+
enml = note_xml.inner_html.to_s
|
31
|
+
|
32
|
+
# append custom sections to the end of the content if they exist
|
33
|
+
return enml if $config.custom_sections.nil?
|
34
|
+
|
35
|
+
enml += to_enml($config.custom_sections[NOTEBOOK_PRIORITY_QUEUE])
|
36
|
+
enml
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# @since 0.3.1
|
41
|
+
def to_enml(hash)
|
42
|
+
Evertils::Helper::EvernoteENML.with_list(hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/router.rb
CHANGED
@@ -17,24 +17,6 @@ module Evertils
|
|
17
17
|
if context.can_exec? $request.controller, $request.command
|
18
18
|
context.pre_exec
|
19
19
|
|
20
|
-
# no command sent? Use default to populate model data
|
21
|
-
model_method = ($request.command ? $request.command : context.default_method).to_s + "_data"
|
22
|
-
|
23
|
-
# populate model data
|
24
|
-
method = context.model.public_method(model_method) rescue false
|
25
|
-
|
26
|
-
# model is not set, use Base model instead so the controller still has
|
27
|
-
# access to model methods
|
28
|
-
if context.model.nil?
|
29
|
-
context.model = Model::Base.new
|
30
|
-
end
|
31
|
-
|
32
|
-
# If the method exists, set model data accordingly
|
33
|
-
# If it doesn't exist then just fail silently, the model may not
|
34
|
-
# be required by some controllers
|
35
|
-
if method.respond_to? :call
|
36
|
-
context.model.data = method.call($request.custom || [])
|
37
|
-
end
|
38
20
|
|
39
21
|
if context.methods_require_internet.include? $request.command
|
40
22
|
if !Utils.has_internet_connection?
|
data/lib/type.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class Base
|
4
|
+
#
|
5
|
+
# @since 0.3.7
|
6
|
+
def initialize(*args)
|
7
|
+
@model = Evertils::Common::Query::Simple.new
|
8
|
+
@format = Evertils::Helper.load('Formatting')
|
9
|
+
@args = args unless args.size.zero?
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# @since 0.3.7
|
14
|
+
def create
|
15
|
+
data = {
|
16
|
+
title: @title,
|
17
|
+
body: @content,
|
18
|
+
parent_notebook: self.class::NOTEBOOK
|
19
|
+
}
|
20
|
+
|
21
|
+
raise 'Invalid title' if @title.nil?
|
22
|
+
raise 'Invalid note content' if @content.nil?
|
23
|
+
raise 'Invalid notebook' if self.class::NOTEBOOK.nil?
|
24
|
+
|
25
|
+
@model.create_note(data)
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# @since 0.3.7
|
30
|
+
def should_create?
|
31
|
+
raise 'Should be overwritten in sub classes'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/types/daily.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class Daily < Type::Base
|
4
|
+
attr_reader :title, :content, :notebook
|
5
|
+
|
6
|
+
NOTEBOOK = :Daily
|
7
|
+
|
8
|
+
#
|
9
|
+
# @since 0.3.7
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
@title = @format.date_templates[NOTEBOOK]
|
14
|
+
@content = @format.template_contents(NOTEBOOK)
|
15
|
+
@content += to_enml($config.custom_sections[NOTEBOOK]) unless $config.custom_sections.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class MonthlyTaskSummary < Type::Base
|
4
|
+
attr_reader :title, :content, :notebook
|
5
|
+
|
6
|
+
NOTEBOOK = :'Monthly Task Summaries'
|
7
|
+
|
8
|
+
#
|
9
|
+
# @since 0.3.7
|
10
|
+
def initialize(*args)
|
11
|
+
super(*args)
|
12
|
+
|
13
|
+
@name = @args.first
|
14
|
+
@title = "#{@name} #{DateTime.now.strftime('%m-%Y')}"
|
15
|
+
@content = @format.template_contents(NOTEBOOK)
|
16
|
+
@content += to_enml($config.custom_sections[NOTEBOOK]) unless $config.custom_sections.nil?
|
17
|
+
|
18
|
+
# BUG: inability to tag notes lies somewhere in evertils-common,
|
19
|
+
# specifically in how note.tag works
|
20
|
+
# As this is non-functional, lets not run it - commented out for now
|
21
|
+
# tag_manager = Evertils::Common::Manager::Tag.instance
|
22
|
+
# month_tag = tag_manager.find_or_create("month-#{Date.today.month}")
|
23
|
+
# mts_note.tag(month_tag.prop(:name))
|
24
|
+
|
25
|
+
# TODO: commented out until support for multiple tags is added
|
26
|
+
# client_tag = tag_manager.find_or_create(@name)
|
27
|
+
# mts_note.tag(client_tag.prop(:name))
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# @since 0.3.7
|
32
|
+
def notebook
|
33
|
+
NOTEBOOK
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class Monthly < Type::Base
|
4
|
+
attr_reader :title, :content, :notebook
|
5
|
+
|
6
|
+
NOTEBOOK = :Monthly
|
7
|
+
|
8
|
+
#
|
9
|
+
# @since 0.3.7
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
@title = @format.date_templates[NOTEBOOK]
|
14
|
+
@content = @format.template_contents(NOTEBOOK)
|
15
|
+
@content += to_enml($config.custom_sections[NOTEBOOK]) unless $config.custom_sections.nil?
|
16
|
+
|
17
|
+
# BUG: inability to tag notes lies somewhere in evertils-common,
|
18
|
+
# specifically in how note.tag works
|
19
|
+
# As this is non-functional, lets not run it - commented out for now
|
20
|
+
# tag_manager = Evertils::Common::Manager::Tag.instance
|
21
|
+
# month_tag = tag_manager.find_or_create("month-#{Date.today.month}")
|
22
|
+
# note.tag(month_tag.prop(:name))
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# @since 0.3.7
|
27
|
+
def should_create?
|
28
|
+
today_is_first_of_month = Date.today.day == 1
|
29
|
+
|
30
|
+
monthly_note_title = @format.date_templates[NOTEBOOK]
|
31
|
+
found = @model.find_note_contents(monthly_note_title)
|
32
|
+
|
33
|
+
!found.entity.nil? && today_is_first_of_month
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class PriorityQueue < Type::Base
|
4
|
+
attr_reader :title, :content, :notebook
|
5
|
+
|
6
|
+
NOTEBOOK = :'Priority Queue'
|
7
|
+
|
8
|
+
#
|
9
|
+
# @since 0.3.7
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
@handler = Evertils::Helper.load('ApiEnmlHandler')
|
14
|
+
|
15
|
+
if Date.today.monday?
|
16
|
+
@title, @content = condition_monday
|
17
|
+
elsif Date.today.tuesday?
|
18
|
+
@title, @content = condition_tuesday
|
19
|
+
else
|
20
|
+
@title, @content = condition_default
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Get friday's note
|
27
|
+
# @since 0.3.7
|
28
|
+
def condition_monday
|
29
|
+
friday = (Date.today - 3)
|
30
|
+
dow = @format.day_of_week(friday.strftime('%a'))
|
31
|
+
note_title = "Queue For [#{friday.strftime('%B %-d')} - #{dow}]"
|
32
|
+
found = @model.find_note_contents(note_title)
|
33
|
+
|
34
|
+
raise "Queue was not found - #{friday.strftime('%B %-d')}" unless found
|
35
|
+
|
36
|
+
[
|
37
|
+
@format.date_templates[NOTEBOOK],
|
38
|
+
@handler.convert_to_xml(found.entity.content).prepare
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Find monday's note
|
43
|
+
# @since 0.3.7
|
44
|
+
def condition_tuesday
|
45
|
+
monday = (Date.today - 1)
|
46
|
+
dow = @format.day_of_week(monday.strftime('%a'))
|
47
|
+
monday_note_title = "Queue For [#{monday.strftime('%B %-d')} - #{dow}]"
|
48
|
+
monday_note = @model.find_note_contents(monday_note_title)
|
49
|
+
|
50
|
+
if !monday_note.entity.nil?
|
51
|
+
note = monday_note.entity
|
52
|
+
note.title = @format.date_templates[NOTEBOOK]
|
53
|
+
else
|
54
|
+
# if it does not exist, get friday's note
|
55
|
+
friday = (Date.today - 4)
|
56
|
+
dow = @format.day_of_week(friday.strftime('%a'))
|
57
|
+
note_title = "Queue For [#{friday.strftime('%B %-d')} - #{dow}]"
|
58
|
+
note = @model.find_note_contents(note_title)
|
59
|
+
end
|
60
|
+
|
61
|
+
raise 'Queue was not found' unless note
|
62
|
+
|
63
|
+
[
|
64
|
+
note.title,
|
65
|
+
@handler.convert_to_xml(note.content).prepare
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Default action for not-Monday/Tuesday
|
70
|
+
# @since 0.3.7
|
71
|
+
def condition_default
|
72
|
+
yest = (Date.today - 1)
|
73
|
+
dow = @format.day_of_week(yest.strftime('%a'))
|
74
|
+
yest_note_title = "Queue For [#{yest.strftime('%B %-d')} - #{dow}]"
|
75
|
+
found = @model.find_note_contents(yest_note_title).entity
|
76
|
+
|
77
|
+
raise "Queue was not found - #{yest.strftime('%B %-d')}" unless found
|
78
|
+
|
79
|
+
[
|
80
|
+
@format.date_templates[NOTEBOOK],
|
81
|
+
@handler.convert_to_xml(found.content).prepare
|
82
|
+
]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/types/weekly.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Evertils
|
2
|
+
module Type
|
3
|
+
class Weekly < Type::Base
|
4
|
+
attr_reader :title, :content, :notebook
|
5
|
+
|
6
|
+
NOTEBOOK = :Weekly
|
7
|
+
|
8
|
+
#
|
9
|
+
# @since 0.3.7
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
@title = @format.date_templates[NOTEBOOK]
|
14
|
+
@content = @format.template_contents(NOTEBOOK)
|
15
|
+
@content += to_enml($config.custom_sections[NOTEBOOK]) unless $config.custom_sections.nil?
|
16
|
+
|
17
|
+
# BUG: inability to tag notes lies somewhere in evertils-common,
|
18
|
+
# specifically in how note.tag works
|
19
|
+
# As this is non-functional, lets not run it - commented out for now
|
20
|
+
# tag_manager = Evertils::Common::Manager::Tag.instance
|
21
|
+
# week_tag = tag_manager.find_or_create("week-#{Date.today.cweek}")
|
22
|
+
# note.tag(week_tag.prop(:name))
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# @since 0.3.7
|
27
|
+
def should_create?
|
28
|
+
today = Date.today
|
29
|
+
is_monday = today.monday?
|
30
|
+
|
31
|
+
weekly_note_title = @format.date_templates[NOTEBOOK]
|
32
|
+
found = @model.find_note_contents(weekly_note_title)
|
33
|
+
|
34
|
+
!found.entity.nil? && is_monday
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Priebe
|
@@ -122,19 +122,23 @@ files:
|
|
122
122
|
- lib/controllers/new.rb
|
123
123
|
- lib/controllers/status.rb
|
124
124
|
- lib/helper.rb
|
125
|
+
- lib/helpers/api-enml-handler.rb
|
125
126
|
- lib/helpers/evernote-enml.rb
|
126
127
|
- lib/helpers/evernote-markdown.rb
|
127
128
|
- lib/helpers/formatting.rb
|
128
|
-
- lib/helpers/generate.rb
|
129
129
|
- lib/helpers/results.rb
|
130
130
|
- lib/helpers/time.rb
|
131
131
|
- lib/kernel.rb
|
132
132
|
- lib/log.rb
|
133
133
|
- lib/logs.rb
|
134
|
-
- lib/model.rb
|
135
|
-
- lib/model_data.rb
|
136
134
|
- lib/request.rb
|
137
135
|
- lib/router.rb
|
136
|
+
- lib/type.rb
|
137
|
+
- lib/types/daily.rb
|
138
|
+
- lib/types/monthly-task-summary.rb
|
139
|
+
- lib/types/monthly.rb
|
140
|
+
- lib/types/priority-queue.rb
|
141
|
+
- lib/types/weekly.rb
|
138
142
|
- lib/utils.rb
|
139
143
|
- lib/version.rb
|
140
144
|
- logs/.gitignore
|
data/lib/helpers/generate.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Evertils
|
2
|
-
module Helper
|
3
|
-
class Generate
|
4
|
-
def self.format_date(title)
|
5
|
-
if title =~ /Daily/
|
6
|
-
resp = /Daily Log \[([A-Z].*) \- [A-Z]\]/.match(title)
|
7
|
-
|
8
|
-
if resp
|
9
|
-
Time.parse($1)
|
10
|
-
end
|
11
|
-
elsif title =~ /Weekly/
|
12
|
-
resp = /Weekly Log \[([A-Z].*) (\d+) \- (\d+)\]/.match(title)
|
13
|
-
|
14
|
-
if resp
|
15
|
-
first = Time.parse($1 +" "+ $2)
|
16
|
-
second = Time.parse($1 +" "+ $3)
|
17
|
-
|
18
|
-
[first, second]
|
19
|
-
end
|
20
|
-
elsif title =~ /Monthly/
|
21
|
-
resp = /Monthly Log \[([A-Z].*) (\d+)\]/.match(title)
|
22
|
-
|
23
|
-
if resp
|
24
|
-
Time.parse($1 +" "+ $2)
|
25
|
-
end
|
26
|
-
elsif title =~ /Quarterly/
|
27
|
-
resp = /Quarterly Log \[([A-Z].*) \- ([A-Z].*) (\d+)\]/.match(title)
|
28
|
-
|
29
|
-
if resp
|
30
|
-
first = Time.parse($1 +" "+ $3)
|
31
|
-
second = Time.parse($2 +" "+ $3)
|
32
|
-
|
33
|
-
[first, second]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/model.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Evertils
|
2
|
-
module Model
|
3
|
-
class Base
|
4
|
-
attr_accessor :data, :branch, :browser, :command, :start
|
5
|
-
|
6
|
-
def initialize(hash = nil)
|
7
|
-
@data = hash || Evertils::Model::Data.new
|
8
|
-
|
9
|
-
# Current time
|
10
|
-
#@time = @data.start
|
11
|
-
# Time the command was executed
|
12
|
-
@start = Time.now
|
13
|
-
# Current working branch
|
14
|
-
@branch = @data.branch
|
15
|
-
# Browser to execute tests in
|
16
|
-
@browser = @data.browser
|
17
|
-
# Instantiate the command execution class
|
18
|
-
@command = Command::Exec.new
|
19
|
-
end
|
20
|
-
|
21
|
-
def bind(hash)
|
22
|
-
initialize(hash)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/model_data.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
module Evertils
|
2
|
-
module Model
|
3
|
-
class Data
|
4
|
-
attr_accessor :identifier, :branch, :browser, :files_with_errors
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
@d = Hash.new([])
|
8
|
-
|
9
|
-
# setup defaults
|
10
|
-
defaults = {
|
11
|
-
:issues => {:errors => 0, :warnings => 0},
|
12
|
-
:status => {:success => 0, :error => 0, :total => 0, :errors_per_file => 0},
|
13
|
-
:success_rate => {:int => 0, :str => "0%"},
|
14
|
-
:log => '',
|
15
|
-
:below_acceptable_limit => false
|
16
|
-
}
|
17
|
-
|
18
|
-
@branch = Command::Exec.git_current_branch
|
19
|
-
@files_with_errors = []
|
20
|
-
|
21
|
-
@d.merge! defaults
|
22
|
-
end
|
23
|
-
|
24
|
-
def unset(key)
|
25
|
-
@d.delete(key.to_sym)
|
26
|
-
end
|
27
|
-
|
28
|
-
def instance_var(key, val = nil)
|
29
|
-
self.class.__send__(:attr_accessor, key)
|
30
|
-
instance_variable_set("@#{key}", val)
|
31
|
-
end
|
32
|
-
|
33
|
-
def serialize
|
34
|
-
@d.to_json
|
35
|
-
end
|
36
|
-
|
37
|
-
def status
|
38
|
-
get(:status)
|
39
|
-
end
|
40
|
-
|
41
|
-
def success_rate
|
42
|
-
get(:success_rate)
|
43
|
-
end
|
44
|
-
|
45
|
-
def increment_issues(key, val)
|
46
|
-
@d[:issues][key.to_sym] += val
|
47
|
-
end
|
48
|
-
|
49
|
-
def increment_status(key, val)
|
50
|
-
@d[:status][key.to_sym] += val
|
51
|
-
end
|
52
|
-
|
53
|
-
def issues
|
54
|
-
get(:issues)
|
55
|
-
end
|
56
|
-
|
57
|
-
def issues=(val)
|
58
|
-
set(:issues, val)
|
59
|
-
end
|
60
|
-
|
61
|
-
def log
|
62
|
-
get(:log, Evertils::DEFAULT_LOG)
|
63
|
-
end
|
64
|
-
|
65
|
-
def add_to_error_list(file)
|
66
|
-
@files_with_errors << file
|
67
|
-
end
|
68
|
-
|
69
|
-
def identifier=(val)
|
70
|
-
@identifier = val
|
71
|
-
|
72
|
-
# create the log file now
|
73
|
-
@d[:log] = Log.new(@branch, Time.now, @identifier)
|
74
|
-
end
|
75
|
-
|
76
|
-
def below_acceptable_limit?
|
77
|
-
get(:below_acceptable_limit) == true
|
78
|
-
end
|
79
|
-
|
80
|
-
def below_acceptable_limit=(val)
|
81
|
-
set(:below_acceptable_limit, val)
|
82
|
-
end
|
83
|
-
|
84
|
-
def bind!(seed_data)
|
85
|
-
@d = seed_data
|
86
|
-
end
|
87
|
-
|
88
|
-
def get(key, default = @d.default)
|
89
|
-
@d[key] || default
|
90
|
-
end
|
91
|
-
|
92
|
-
def set(key, val = nil)
|
93
|
-
@d[key] = val
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|