reminders_txt 0.3.11 → 0.3.12

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: 115c753ddcc43b6b7c771d7bba580b2986518730
4
- data.tar.gz: 422b8921269476bede0a4e574a7f7b9c8e5b8806
3
+ metadata.gz: cbb33480f37472a926eafe65ff3ce3422a83c2be
4
+ data.tar.gz: 257b8dc0ce77dca22753f2901ae496721d2d1e36
5
5
  SHA512:
6
- metadata.gz: cd9c3409bd1aab401ea58e5df1aa07b43f023a17893d32f804ae5c2c62b42c3ecf244be143635f1640b276e28f0d4cdf03c78e4709438a9a003754a6b84f57ec
7
- data.tar.gz: 00dfe4f3f0022213f7f4663007647500f987fcef276820f79c7a33f5743dae45bca54a7cbd455ac801e3b2d1737a230c475c7b6e7b031018934024ff35afb495
6
+ metadata.gz: abe605a67c520962a4e02f4b2a3a460498959e668ba2a87ea37c62950db9349b3ec14e2f5ad38874a362d7ed4f39a057a800458bb576979db9c02b7630fe33b1
7
+ data.tar.gz: baa9b238c153f46623f31aa6c5a8f09a1085f7a1800a0ad2023bb9f38e922a89e915bd85903c4ec9aa521a7ced60393144715761a1d057d22ef0e2c5caa171f2
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -25,7 +25,7 @@ class RemindersTxt
25
25
  include AppRoutes
26
26
  using Ordinals
27
27
 
28
- attr_reader :reminders
28
+ attr_reader :reminders, :dx
29
29
 
30
30
  def initialize(raw_s='reminders.txt', now: Time.now)
31
31
 
@@ -35,14 +35,34 @@ class RemindersTxt
35
35
  @filepath = raw_s
36
36
 
37
37
  if raw_s.lines.length > 1 then
38
- @filepath = 'reminders.xml'
39
- @dx = Dynarex.new raw_s
38
+
39
+ if raw_s.lstrip[0] == '<' then
40
+
41
+ @filepath = 'reminders.xml'
42
+ @dx = Dynarex.new raw_s
43
+
44
+ else
45
+
46
+ @filepath = File.join(Dir.pwd, 'reminders.txt')
47
+ @dxfilepath = @filepath.sub(/.txt$/,'.xml')
48
+
49
+ @dx = Dynarex.new
50
+ import_txt(raw_s)
51
+
52
+ end
53
+
40
54
  elsif File.extname(@filepath) == '.txt'
41
55
 
42
- import_txt(@filepath)
43
- refresh()
56
+ s = File.read @filepath
57
+ @filename = File.basename(@filepath)
58
+ @dxfilepath = @filepath.sub(/.txt$/,'.xml')
59
+
60
+ import_txt(s)
61
+
44
62
  else
63
+
45
64
  @dx = Dynarex.new @filepath
65
+
46
66
  end
47
67
  end
48
68
 
@@ -129,7 +149,7 @@ class RemindersTxt
129
149
 
130
150
  # hall 2 friday at 11am
131
151
  # some important day 24th Mar
132
- get /(.*)\s+(\d+[^\*]+)(\*)?/ do |title, raw_date, annualar|
152
+ get /([^\d]+)\s+(\d+[^\*]+)(\*)?/ do |title, raw_date, annualar|
133
153
 
134
154
  d = Chronic.parse(raw_date)
135
155
 
@@ -181,16 +201,9 @@ class RemindersTxt
181
201
 
182
202
  private
183
203
 
184
- def import_txt(filepath)
185
-
186
- s = File.read filepath
187
- @file_contents, @filename = s, File.basename(filepath)
188
-
189
- #Dir.chdir File.dirname(filename)
190
-
191
- @dxfilepath = filepath.sub(/.txt$/,'.xml')
192
-
204
+ def import_txt(s)
193
205
 
206
+ @file_contents = s
194
207
  @params = {}
195
208
  expressions(@params)
196
209
  buffer = s.lines[2..-1]
@@ -214,10 +227,9 @@ class RemindersTxt
214
227
  #
215
228
  def refresh()
216
229
 
217
-
218
230
  reminders = @reminders.clone
219
231
  # if XML file doesn't exist, create it
220
-
232
+
221
233
  if File.exists? @dxfilepath then
222
234
 
223
235
  @dx = Dynarex.new @dxfilepath
@@ -233,6 +245,10 @@ class RemindersTxt
233
245
  reminder.date.to_date
234
246
 
235
247
  end
248
+
249
+ else
250
+
251
+ save_dx()
236
252
 
237
253
  end
238
254
 
@@ -247,7 +263,7 @@ class RemindersTxt
247
263
  h2 = (Digest::MD5.new << @file_contents).to_s
248
264
 
249
265
  b = h1 != h2
250
-
266
+
251
267
  if b or @reminders != reminders then
252
268
 
253
269
  save_dx()
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.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file