reminders_txt 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
- checksums.yaml.gz.sig +1 -2
- data.tar.gz.sig +0 -0
- data/lib/reminders_txt.rb +36 -18
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdef8b14487344306d7c51cbca1b0c4762d84cca
|
4
|
+
data.tar.gz: 8a0834e882eff028e90948ee1578e6c47bd72eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69c5d2c7f3d7894b3ab9092bebda0eef028ae0179f4574c89eda0b258ecc118b6088d046d53fc015302391340b3f70f38ac667373dc58003c0b83ea661a42d48
|
7
|
+
data.tar.gz: 3088b001e9cfa5aaaa13856f2265d1c2f862d1b49b992f74697dd56bf7e170a451353f9eccc9b9b75772cbab1052b21eb8cd91245f84e8a874e15e9ed69dbdf1
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�q��6j�� 2$�]N���{��4d�A�����Z6[@l�d��������vk|.6D�'ũ��b���F�=Y�>��l�գ,���B�7a�����Rx�\Tf
|
1
|
+
u�L[�sUn�I�j�N>$��6}��s5��F��܆���G��{�]���G�T��ʖ}
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/reminders_txt.rb
CHANGED
@@ -25,9 +25,10 @@ class RemindersTxt
|
|
25
25
|
include AppRoutes
|
26
26
|
using Ordinals
|
27
27
|
|
28
|
-
attr_reader :
|
28
|
+
attr_reader :reminders
|
29
29
|
|
30
|
-
def initialize(filename='reminders.txt', now: Time.now,
|
30
|
+
def initialize(filename='reminders.txt', now: Time.now,
|
31
|
+
dxfilepath: 'reminders.xml')
|
31
32
|
|
32
33
|
|
33
34
|
s = File.read filename
|
@@ -59,7 +60,8 @@ class RemindersTxt
|
|
59
60
|
|
60
61
|
def save_dx()
|
61
62
|
|
62
|
-
dx = Dynarex.new(
|
63
|
+
dx = Dynarex.new(
|
64
|
+
'reminders/reminder(input, title, recurring, date, end_date)')
|
63
65
|
@reminders.each {|x| dx.create x.to_h}
|
64
66
|
dx.save @dxfilepath
|
65
67
|
|
@@ -74,22 +76,22 @@ class RemindersTxt
|
|
74
76
|
|
75
77
|
dx = Dynarex.new @dxfilepath
|
76
78
|
|
77
|
-
@reminders.
|
79
|
+
@reminders.each do |reminder|
|
78
80
|
s = reminder.input
|
79
81
|
r = dx.find_by_input s
|
80
82
|
|
81
83
|
# it is on file and it's not an annual event?
|
82
84
|
# use the date from file if the record exists
|
83
85
|
|
84
|
-
reminder.date = (r and not s[/\*$/]) ? Date.parse(r.date) :
|
86
|
+
reminder.date = (r and not s[/\*$/]) ? Date.parse(r.date) : \
|
87
|
+
reminder.date.to_date
|
85
88
|
|
86
|
-
reminder
|
87
89
|
end
|
88
90
|
|
89
91
|
end
|
90
92
|
|
91
93
|
# delete expired non-recurring reminders
|
92
|
-
@reminders.reject! {|x| x.date.to_time < @now }
|
94
|
+
@reminders.reject! {|x| x.date.to_time < @now if not x.recurring }
|
93
95
|
|
94
96
|
@reminders.sort_by!(&:date)
|
95
97
|
|
@@ -137,7 +139,7 @@ class RemindersTxt
|
|
137
139
|
starting = /(?:\(?\s*starting (\d+\w{2} \w+\s*\w*)(?: until (.*))?\s*\))?/
|
138
140
|
|
139
141
|
get /^(.*)(every \w+ \w+(?: at (\d+am) )?)\s*#{starting}/ do \
|
140
|
-
|
142
|
+
|title, recurring, time, raw_date, end_date|
|
141
143
|
|
142
144
|
input = params[:input]
|
143
145
|
|
@@ -148,15 +150,18 @@ class RemindersTxt
|
|
148
150
|
|
149
151
|
if d < @now then
|
150
152
|
|
151
|
-
new_date = CronFormat.new(ChronicCron.new(recurring)
|
152
|
-
|
153
|
+
new_date = CronFormat.new(ChronicCron.new(recurring)\
|
154
|
+
.to_expression, d).to_time
|
155
|
+
input.gsub!(raw_date, new_date\
|
156
|
+
.strftime("#{new_date.day.ordinal} %b %Y"))
|
153
157
|
d = new_date
|
154
158
|
|
155
159
|
end
|
156
160
|
end
|
157
161
|
|
158
162
|
|
159
|
-
OpenStruct.new input: input, title: title, recurring: recurring,
|
163
|
+
OpenStruct.new input: input, title: title, recurring: recurring,
|
164
|
+
date: d, end_date: end_date
|
160
165
|
#[0, title, recurring, time, date, end_date].inspect
|
161
166
|
end
|
162
167
|
|
@@ -173,11 +178,18 @@ class RemindersTxt
|
|
173
178
|
|
174
179
|
d = Chronic.parse(raw_date)
|
175
180
|
|
176
|
-
|
177
|
-
|
181
|
+
recurring = nil
|
182
|
+
|
183
|
+
if annualar then
|
184
|
+
|
185
|
+
recurring = 'yearly'
|
186
|
+
if d < @now then
|
187
|
+
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
188
|
+
end
|
178
189
|
end
|
179
|
-
|
180
|
-
OpenStruct.new input: params[:input], title: title, date: d
|
190
|
+
|
191
|
+
OpenStruct.new input: params[:input], title: title, date: d,
|
192
|
+
recurring: recurring
|
181
193
|
#[2, title, date].inspect
|
182
194
|
end
|
183
195
|
|
@@ -185,13 +197,19 @@ class RemindersTxt
|
|
185
197
|
get /(\d[^\s]+)\s+([^\*]+)(\*)?/ do |raw_date, title, annualar|
|
186
198
|
|
187
199
|
d = Chronic.parse(raw_date)
|
200
|
+
recurring = nil
|
188
201
|
|
189
|
-
if annualar
|
190
|
-
|
202
|
+
if annualar then
|
203
|
+
|
204
|
+
recurring = 'yearly'
|
205
|
+
if d < @now then
|
206
|
+
d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
|
207
|
+
end
|
191
208
|
end
|
192
209
|
|
193
210
|
|
194
|
-
OpenStruct.new input: params[:input], title: title, date: d
|
211
|
+
OpenStruct.new input: params[:input], title: title, date: d,
|
212
|
+
recurring: recurring
|
195
213
|
#[3, title, date].inspect
|
196
214
|
end
|
197
215
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reminders_txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
n+SSd9dm8JjhZ2pqHtX+bgMZ18hrN06xfR+UPtk5BKC8v1PC0FWxaVR4lom39rFU
|
32
32
|
seDxJNsJgamAKg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-11-
|
34
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|