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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd44103bf515012691e2fff7378b81a326d9e08f
4
- data.tar.gz: 7678b3c9318816e426fcc9dae236982a99cb35e7
3
+ metadata.gz: cdef8b14487344306d7c51cbca1b0c4762d84cca
4
+ data.tar.gz: 8a0834e882eff028e90948ee1578e6c47bd72eac
5
5
  SHA512:
6
- metadata.gz: b48d45ea0f0f09c7587ca73ea1f1d1bfbc57cb9038598532ff0b25edd8547948301491f1776a55212a86b66ef42a1a8a4d62c0075d411a32e2939b4ef2e93f88
7
- data.tar.gz: cd794f5ace08b52c1f5bab72d87a3d47acfd30c67e950fe79e91080e1e6ea54fc4b10cd02ba74bdf9c00972454a1bdf84d78a6aa3ed76bbbf4fc3a92dcf313ae
6
+ metadata.gz: 69c5d2c7f3d7894b3ab9092bebda0eef028ae0179f4574c89eda0b258ecc118b6088d046d53fc015302391340b3f70f38ac667373dc58003c0b83ea661a42d48
7
+ data.tar.gz: 3088b001e9cfa5aaaa13856f2265d1c2f862d1b49b992f74697dd56bf7e170a451353f9eccc9b9b75772cbab1052b21eb8cd91245f84e8a874e15e9ed69dbdf1
@@ -1,2 +1 @@
1
- V/�g�C� DHtbfFWy��1���� ���9HW�% z�*�i6�+��� a���gm]z(�J�]#sHh"g�>�<N�1�?
2
- �q��6j�� 2$�]N���{��4d�A����� Z6[@l�d��������vk|.6D�'ũ��b���F�=Y�>��l�գ,���B�7a �����Rx�\Tf
1
+ uL[�sUnIjN>$��6}��s5��F��܆���G��{�]���GT��ʖ}
data.tar.gz.sig CHANGED
Binary file
@@ -25,9 +25,10 @@ class RemindersTxt
25
25
  include AppRoutes
26
26
  using Ordinals
27
27
 
28
- attr_reader :expressions
28
+ attr_reader :reminders
29
29
 
30
- def initialize(filename='reminders.txt', now: Time.now, dxfilepath: 'reminders.xml')
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('reminders/reminder(input, title, recurring, date, end_date)')
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.map do |reminder|
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) : reminder.date.to_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
- |title, recurring, time, raw_date, end_date|
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).to_expression, d).to_time
152
- input.gsub!(raw_date, new_date.strftime("#{new_date.day.ordinal} %b %Y"))
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, date: d, end_date: end_date
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
- if annualar and d < @now then
177
- d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
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 and d < @now then
190
- d = Chronic.parse(raw_date, now: Time.local(@now.year + 1, 1, 1))
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.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-12 00:00:00.000000000 Z
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