event_nlp 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed04654bfc6e7e852dcce5fc00c55b1428f2bb7468f1bd1934895dab9239403c
4
- data.tar.gz: 9df3b5db5d7f473766b27efe0c2da3e599b4061e98fb5eec851c6570600f14a6
3
+ metadata.gz: 006b95206123489efd7a4af7281c94cf04f9c87e2767b66f64ac8dfabf997935
4
+ data.tar.gz: c24fa71f8468feea1740737afa65c1f37b338601a2bb483705f55ea636b7a6da
5
5
  SHA512:
6
- metadata.gz: 958c73c2bd2eed4a4937c8f8a269d758a92cc632ab366c78f00ee23cb19d6923bf99587fb53c649983397866bd5d55f2d34c7cb5d5656ebf61ace1e1ade83d4b
7
- data.tar.gz: 6445772034c43de1489b0d8749ce53608554784f56d8bf20a7c58bf0938a87591d0ec80e4515a4bb787217bfd334d4f7844d1f39c2eddfc90c0b403eed0edd1e
6
+ metadata.gz: c27fc480731c2eb471bc80933f460a18c62ae6512b82336cd455c0733d267704959de4c0e37ee7a59d1918d8fd5971a3966bf15dd87886feff9dd48aacfaf472
7
+ data.tar.gz: ab4d7de64261e1dfd3afd0ea29c4d84184ed8be70d6120340ba4959738838bbbd73126a8de992eb99809887ffe355c089628b426066a5603ddaa3ef1d886303b
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/event_nlp.rb CHANGED
@@ -55,14 +55,27 @@ class EventNlp
55
55
  #
56
56
  def project(s, year: Time.now.year)
57
57
 
58
- r = parse s
58
+ r0 = parse s
59
+ r = parse r0.input
59
60
  dates = []
60
61
  now = @now
61
62
 
63
+ if @debug then
64
+ puts 'r.date: ' + r.date.inspect
65
+ puts 'r.input: ' + r.input.inspect
66
+ end
67
+
68
+ return [r.date] if (r.date == EventNlp.new(r.date+1).parse(r.input).date)
69
+
62
70
  while r.date.year == year.to_i do
63
71
 
64
72
  dates << r.date
65
- @now = r.date + 1
73
+ @now = if r.recurring == 'month' then
74
+ (r.date.to_datetime >> 1).to_time
75
+ else
76
+ r.date + 1
77
+ end
78
+ #@now = r.date + 1
66
79
  r = parse(r.input)
67
80
 
68
81
  end
@@ -125,10 +138,11 @@ class EventNlp
125
138
 
126
139
  # e.g. electricity bill on the 28th of every month
127
140
 
128
- get /(.*) on the (#{days}) of every (#{periods})/i do |title, day, recurring|
141
+ get /(.*) on the #{days} of every (month)/i do |title, day, recurring|
129
142
 
130
143
 
131
- raw_d = Chronic.parse(day)
144
+ puts 'day: ' + day.inspect if @debug
145
+ raw_d = Chronic.parse(day + ' ' + Date::MONTHNAMES[@now.month])
132
146
 
133
147
  # if the date is less than now then increment it by a month
134
148
  d = raw_d < @now ? (raw_d.to_date >> 1).to_time : raw_d
@@ -349,10 +363,11 @@ class EventNlp
349
363
 
350
364
  # hall 2 friday at 11am
351
365
 
352
- get /^(.*)\s+#{weekdays}\b(?: \(([^\)]+)\))?(#{times})?/i \
353
- do |title, raw_day, actual_date, time|
366
+ get /^(.*)\s+#{weekdays}\b(?: \(([^\)]+)\))?(?:#{times})? *(weekly)?/i \
367
+ do |title, raw_day, actual_date, time, recurring|
354
368
 
355
369
  if @debug then
370
+ puts ('recurring: ' + recurring.inspect).debug
356
371
  puts ('actual_date: ' + actual_date.inspect).debug
357
372
  puts ('raw_day: ' + raw_day.inspect).debug
358
373
  puts ('time: ' + time.inspect).debug
@@ -360,9 +375,9 @@ class EventNlp
360
375
 
361
376
  input = params[:input].clone
362
377
 
363
- if actual_date then
364
- d = Chronic.parse(raw_day + ' ' + time.to_s)
365
- else
378
+ d = Chronic.parse(raw_day + ' ' + time.to_s)
379
+
380
+ if recurring.nil?
366
381
  d = Chronic.parse(raw_day + ' ' + time.to_s)
367
382
  input.sub!(/#{weekdays}/i,
368
383
  %Q(#{raw_day} (#{d.strftime("#{d.day.ordinal} %b %Y")})))
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_nlp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file