event_nlp 0.8.0 → 0.8.1

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
  SHA256:
3
- metadata.gz: b7bd2a0880cb2646bfd8241934a3f295f2790d1c8a6912058bf26dbd12c2f5e4
4
- data.tar.gz: 1e62175f0137981d910a8e177f2f2ba6026e54e8f8306f17037f6f8d19d800aa
3
+ metadata.gz: e3cc81afc327dd3a3d2015b561a327fd7c0bd590690be494ae689effb6aa4958
4
+ data.tar.gz: 01ac801f9a5df6ac4e80fdaf21b9de3120873271fd2adc770a96a28f131ed569
5
5
  SHA512:
6
- metadata.gz: 803ba376567fd1693bbc3618bda094d46608ba293ca1d43dd93df305d017ce2403190fb8b33df128ef260e9210f33a530a4aa1fb1a62923d9f35c9bd77bed026
7
- data.tar.gz: 26385ac01d68d9162d57e822ec271c1993f214b2e5960198f5a13d30fbb2368e34d6db5ee6e13422a76cadeda6c06cc6f6072aac70f3733162cb0aada7aa3b8c
6
+ metadata.gz: '0026970aa8352d0ec613de80baf723400cdb79ed173989e632d48329985b69405c4f56d5448c8998d867c2c059ac402bd119b1faa216bfa9aa3d2367bba852b3'
7
+ data.tar.gz: d91e0d5d9ef57826fee3e24a6a9cc969e8a8206144c0adf2c6fda6e4bea339283f54092e13730f4f7aa164c0b64a8802401e9ce1234eecbdb42ea00abee6c11c
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/event_nlp.rb CHANGED
@@ -24,8 +24,8 @@ class EventNlp
24
24
  using ColouredText
25
25
 
26
26
  attr_accessor :params
27
-
28
- def initialize(now=Time.now, params: {}, debug: false)
27
+
28
+ def initialize(now=Time.now, params: {leap: :back}, debug: false)
29
29
 
30
30
  super()
31
31
 
@@ -45,6 +45,7 @@ class EventNlp
45
45
  #-----------------------------------------------------------
46
46
 
47
47
  @params[:input] = s
48
+ puts 'parse: about to execute run_route' if @debug
48
49
  r = run_route(s)
49
50
 
50
51
  return unless r.is_a? Hash
@@ -67,6 +68,7 @@ class EventNlp
67
68
  end_date = if raw_end_date then
68
69
  EventNlp.new().parse(raw_end_date).date
69
70
  else
71
+ puts 'before date parse' if @debug
70
72
  (Date.parse('1 Jan ' + (year+1).to_s) - 1).to_time
71
73
  end
72
74
 
@@ -93,6 +95,7 @@ class EventNlp
93
95
 
94
96
  while r.date <= end_date do
95
97
 
98
+ puts 'project/r.date: ' + r.date.inspect if @debug
96
99
  dates << r.date
97
100
  @now = if r.recurring == 'month' then
98
101
  (r.date.to_date >> 1).to_time
@@ -190,10 +193,29 @@ class EventNlp
190
193
  get /(.*) on the #{days} of every (month)/i do |title, day, recurring|
191
194
 
192
195
 
196
+ puts 'inside route 0.1' if @debug
193
197
  puts 'day: ' + day.inspect if @debug
194
- raw_d = Chronic.parse(day + ' ' + Date::MONTHNAMES[@now.month], now: @now)
198
+
199
+ month = @now.month
200
+
201
+ if @now.month == 2 then
202
+
203
+ if (!Date.leap?(@now.year) and day.to_i == 29) or day.to_i == 30 then
204
+ if params[:leap] == :back then
205
+ day = '28th'
206
+ else
207
+ day = '1st'
208
+ month += 1
209
+ end
210
+ end
211
+
212
+ end
213
+
214
+ raw_d = Chronic.parse(day + ' ' + Date::MONTHNAMES[month], now: @now)
215
+ puts 'raw_d: ' + raw_d.inspect if @debug
195
216
 
196
217
  # if the date is less than now then increment it by a month
218
+ puts '@now: ' + @now.inspect if @debug
197
219
  d = raw_d < @now ? (raw_d.to_date >> 1).to_time : raw_d
198
220
 
199
221
 
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file