evertils 0.3.14 → 0.3.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evertils/types/daily.rb +5 -2
- data/lib/evertils/types/priority-queue.rb +33 -18
- data/lib/evertils/types/weekly.rb +0 -14
- data/lib/evertils/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: 718d7296f7fb64fe1e53c51150e94d5dbfca5771
|
4
|
+
data.tar.gz: 1f4a1ff05f39f7e2dfd49a7d525cce45157b5075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ac052ae463845c104993eb40e4735629c5094cc438bc9ae4c6c50f1ddc11f36a1909e48601b7003ef33848bf853be929ab4f6f4ff762d75ca56cfd1500153a
|
7
|
+
data.tar.gz: 7e54c227677a05a14621fcc4b20314e2a06c3ac60ed2f57c55b0ffaa7090b5f51cb83ed255a0d299f9e3b1ae86cb4af18e34afb3d80fbdbdb424a1d0cc3d69f3
|
data/lib/evertils/types/daily.rb
CHANGED
@@ -3,6 +3,7 @@ module Evertils
|
|
3
3
|
class Daily < Type::Base
|
4
4
|
NOTEBOOK = :Daily
|
5
5
|
COLOUR = 0xffe8b7
|
6
|
+
MAX_SEARCH_SIZE = 21
|
6
7
|
|
7
8
|
#
|
8
9
|
# @since 0.3.7
|
@@ -36,15 +37,16 @@ module Evertils
|
|
36
37
|
@api = Evertils::Helper.load('ApiEnmlHandler', @config)
|
37
38
|
enml = @api.from_str(@format.template_contents(NOTEBOOK))
|
38
39
|
|
40
|
+
Notify.info('Waiting for...')
|
39
41
|
pq = find_priority_queue
|
40
42
|
|
41
43
|
# didn't find the note the first time? wait and try again
|
42
44
|
if pq.entity.nil?
|
43
|
-
iter =
|
45
|
+
iter = 1
|
44
46
|
loop do
|
45
47
|
iter += 1
|
46
48
|
pq = find_priority_queue(true)
|
47
|
-
break unless pq.entity.nil?
|
49
|
+
break unless pq.entity.nil? || iter == MAX_SEARCH_SIZE
|
48
50
|
end
|
49
51
|
|
50
52
|
Notify.info("#{iter} attempts to find the pq note") unless iter.zero?
|
@@ -65,6 +67,7 @@ module Evertils
|
|
65
67
|
def find_priority_queue(sleep = false)
|
66
68
|
sleep(5) if sleep
|
67
69
|
title = @format.date_templates[:'Priority Queue']
|
70
|
+
Notify.info(title)
|
68
71
|
@model.find_note_contents(title)
|
69
72
|
end
|
70
73
|
end
|
@@ -3,6 +3,7 @@ module Evertils
|
|
3
3
|
class PriorityQueue < Type::Base
|
4
4
|
NOTEBOOK = :'Priority Queue'
|
5
5
|
COLOUR = 0xffe8b7
|
6
|
+
MAX_SEARCH_SIZE = 21
|
6
7
|
|
7
8
|
#
|
8
9
|
# @since 0.3.7
|
@@ -10,13 +11,14 @@ module Evertils
|
|
10
11
|
super(config, *args)
|
11
12
|
|
12
13
|
@handler = Evertils::Helper.load('ApiEnmlHandler', @config)
|
14
|
+
@title = @format.date_templates[NOTEBOOK]
|
13
15
|
|
14
16
|
if Date.today.monday?
|
15
|
-
@
|
17
|
+
@content = condition_monday
|
16
18
|
elsif Date.today.tuesday?
|
17
|
-
@
|
19
|
+
@content = condition_tuesday
|
18
20
|
else
|
19
|
-
@
|
21
|
+
@content = condition_default
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -38,15 +40,14 @@ module Evertils
|
|
38
40
|
|
39
41
|
raise "Queue was not found - #{friday.strftime('%B %-d')}" unless found
|
40
42
|
|
41
|
-
|
42
|
-
@format.date_templates[NOTEBOOK],
|
43
|
-
@handler.convert_to_xml(found.entity.content).prepare
|
44
|
-
]
|
43
|
+
@handler.convert_to_xml(found.entity.content).prepare
|
45
44
|
end
|
46
45
|
|
47
46
|
# Find monday's note
|
47
|
+
# TODO: refactor
|
48
48
|
# @since 0.3.7
|
49
49
|
def condition_tuesday
|
50
|
+
# get monday note
|
50
51
|
monday = (Date.today - 1)
|
51
52
|
dow = @format.day_of_week(monday.strftime('%a'))
|
52
53
|
monday_note_title = "Queue For [#{monday.strftime('%B %-d')} - #{dow}]"
|
@@ -54,21 +55,38 @@ module Evertils
|
|
54
55
|
|
55
56
|
if !monday_note.entity.nil?
|
56
57
|
note = monday_note.entity
|
57
|
-
note.title = @format.date_templates[NOTEBOOK]
|
58
58
|
else
|
59
59
|
# if it does not exist, get friday's note
|
60
60
|
friday = (Date.today - 4)
|
61
61
|
dow = @format.day_of_week(friday.strftime('%a'))
|
62
|
-
|
63
|
-
|
62
|
+
fri_note_title = "Queue For [#{friday.strftime('%B %-d')} - #{dow}]"
|
63
|
+
fri_note = @model.find_note_contents(fri_note_title)
|
64
|
+
|
65
|
+
if fri_note.entity.nil?
|
66
|
+
# if it does not exist, get $day - 1 note until we find one
|
67
|
+
day = friday
|
68
|
+
iter = 0
|
69
|
+
|
70
|
+
Notify.info('Searching for...')
|
71
|
+
|
72
|
+
loop do
|
73
|
+
iter += 1
|
74
|
+
day -= 1
|
75
|
+
dow = @format.day_of_week(day.strftime('%a'))
|
76
|
+
note_title = "Queue For [#{day.strftime('%B %-d')} - #{dow}]"
|
77
|
+
query = @model.find_note_contents(note_title)
|
78
|
+
note = query.entity
|
79
|
+
|
80
|
+
Notify.info(" (#{iter}) #{note_title}")
|
81
|
+
|
82
|
+
break unless note.nil? || iter == MAX_SEARCH_SIZE
|
83
|
+
end
|
84
|
+
end
|
64
85
|
end
|
65
86
|
|
66
87
|
raise 'Queue was not found' unless note
|
67
88
|
|
68
|
-
|
69
|
-
note.title,
|
70
|
-
@handler.convert_to_xml(note.content).prepare
|
71
|
-
]
|
89
|
+
@handler.convert_to_xml(note.content).prepare
|
72
90
|
end
|
73
91
|
|
74
92
|
# Default action for not-Monday/Tuesday
|
@@ -81,10 +99,7 @@ module Evertils
|
|
81
99
|
|
82
100
|
raise "Queue was not found - #{yest.strftime('%B %-d')}" unless found
|
83
101
|
|
84
|
-
|
85
|
-
@format.date_templates[NOTEBOOK],
|
86
|
-
@handler.convert_to_xml(found.content).prepare
|
87
|
-
]
|
102
|
+
@handler.convert_to_xml(found.content).prepare
|
88
103
|
end
|
89
104
|
end
|
90
105
|
end
|
@@ -18,20 +18,6 @@ module Evertils
|
|
18
18
|
def tags
|
19
19
|
["week-#{Date.today.cweek}"]
|
20
20
|
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# @since 0.3.7
|
24
|
-
def should_create?
|
25
|
-
is_monday = Date.today.monday?
|
26
|
-
|
27
|
-
weekly_note_title = @format.date_templates[NOTEBOOK]
|
28
|
-
found = @model.find_note_contents(weekly_note_title)
|
29
|
-
result = found.entity.nil? && is_monday
|
30
|
-
|
31
|
-
Notify.warning "#{self.class.name} skipped, note already exists" unless result
|
32
|
-
|
33
|
-
result
|
34
|
-
end
|
35
21
|
end
|
36
22
|
end
|
37
23
|
end
|
data/lib/evertils/version.rb
CHANGED