chronic_cron 0.2.26 → 0.2.27

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: 66daab1a72dc3f45d8d1df42be0c6b78d874b662
4
- data.tar.gz: e2a927a2a7a829653c26681d1b5521d3c2076be0
3
+ metadata.gz: 690f3ee1c70a006717b4a76bd21812930979de24
4
+ data.tar.gz: ece3e04aa6302da8f134b56e1ed11934803bf08d
5
5
  SHA512:
6
- metadata.gz: 6ff659dd0c467a203da283097413e54c55ba595e71e768b52b24af92fccfab6edca0a20f03444095c77f39cae3ac923171dc5e7ecd0d3b40f6d1d290962e41dc
7
- data.tar.gz: 64c9cf0cbbc65948522004745f32b54ba465f818c65284e8845f09291e8b669a0acca4153c8200adcd4f05a4b85c133f0f9b92cdd070de41d7752b5c1d149dd6
6
+ metadata.gz: 0c373e11011f6e15de9608da63384870e4a4bdbf81749ceb003b9b9a963cc86c3d42eba6c7067d1127eab76cddeeb8d748453f3d8f35ecc6250edceac079beec
7
+ data.tar.gz: b6d63f2c70be57268aa6bca911ed1a2e116b674a518840610f7947be6be68dce758a5c5292381199f011b13e50ce584f37de2b8c298885bc925f9936d508d108
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- M'�i��4n���G -c)�-�YsS+���Y \�)0ؑ!M7VF=�‹>�hl�]�Ү��j�)=E���OMKb����P>�U�4���k33XA8�������Oc��텉�(p
1
+ 'E7��f�ܐ��Eh��h��Фs'�����ܐۭ���]L~�/�j�Ո����c8o,�^��f%��ӫّXP<��@bltMf�S�h��ҭQ]f��y�>�=Si��'��l�I�В3�j�kA�F��NuIKL���Ŭ6�+ٴ�u$��xW���fs��t�="������/{ [��I8U��AJ����z6Ϫ��w����� ����w��Z*�R�ܾ��� �(;��ZǢ |5U% �60�V
data/lib/chronic_cron.rb CHANGED
@@ -160,13 +160,64 @@ class ChronicCron
160
160
  "%s %s * * %s" % [mins, hrs , wday]
161
161
  end
162
162
 
163
+
164
+
165
+ # e.g. every 2nd week at 6am starting from 7th Jan
166
+ get /every (\w+) week\s+(?:at\s+(\w+)\s+starting\s+)?(?:from\s+)?(.*)/ do
167
+ |nth_week, raw_time, raw_date|
168
+
169
+ # |nth_week, day_of_week, time|
170
+
171
+
172
+
173
+ h = {
174
+ /first|1st/ => 0,
175
+ /second|2nd/ => 1,
176
+ /third|3rd/ => 2,
177
+ /fourth|4th|last/ => 3
178
+ }
179
+
180
+ _, nweek = h.find{|k,_| nth_week[k]}
181
+
182
+ month = @now.month
183
+ date = Time.local(@now.year, month, 1)
184
+ t = Chronic.parse(raw_date + ' ' + raw_time, :now => date)
185
+
186
+ def make_date(day_of_week, month, time, nweek)
187
+
188
+ Chronic.parse([day_of_week,month,time].join(' '), :now => @now) \
189
+ + WEEK * nweek
190
+ end
191
+
192
+ if t < @now
193
+ day_of_week = Date::DAYNAMES[t.wday]
194
+ months = Date::MONTHNAMES
195
+ t = make_date(day_of_week, months.rotate[month], raw_time, nweek)
196
+ end
197
+
198
+ "%s %s %s %s * %s" % t.to_a.values_at(1,2,3,4,5)
199
+
200
+ end
201
+
202
+ # e.g. every 2 weeks at 6am starting from 7th Jan
203
+ get /every (\w+) weeks\s+(?:at\s+(\w+)\s+starting\s+)?(?:from\s+)?(.*)/ do
204
+ |interval, raw_time, raw_date|
205
+
206
+ t = Chronic.parse(raw_date + ' ' + raw_time, :now => @now)
207
+ t += WEEK * interval.to_i until t > @now
208
+ mins, hrs, day, month, year = t.to_a.values_at(1,2,3,4,5)
209
+
210
+ "%s %s %s %s %s/%s %s" % [mins, hrs, day, month, t.wday, interval, year]
211
+ end
212
+
213
+
163
214
  # e.g. starting 05-Aug@15:03 every 2 weeks
164
215
  get /(.*) every (\d) weeks/ do |raw_date, interval|
165
216
 
166
217
  t = Chronic.parse(raw_date, :now => @now)
167
218
  mins, hrs, day, month, year = t.to_a.values_at(1,2,3,4,5)
168
219
  "%s %s %s %s %s/%s %s" % [mins, hrs, day, month, t.wday, interval, year]
169
- end
220
+ end
170
221
 
171
222
  # e.g. from 05-Aug@12:34 fortnightly
172
223
  get /(.*)\s+(?:biweekly|fortnightly)/ do |raw_date|
@@ -205,12 +256,12 @@ class ChronicCron
205
256
  Chronic.parse([day_of_week,month,time].join(' '), :now => @now) \
206
257
  + WEEK * nweek
207
258
  end
259
+
260
+ months = Date::MONTHNAMES
261
+ t = make_date day_of_week, months[month], time, nweek
208
262
 
209
- months = %w(jan feb mar apr may jun jul aug sep oct nov dec)
210
- t = make_date day_of_week, months[month-1], time, nweek
211
-
212
- if t < Time.now
213
- t = make_date(day_of_week, months.rotate[month-1], time, nweek)
263
+ if t < @now
264
+ t = make_date(day_of_week, months.rotate[month], time, nweek)
214
265
  end
215
266
 
216
267
  "%s %s %s %s * %s" % t.to_a.values_at(1,2,3,4,5)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronic_cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.26
4
+ version: 0.2.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file