chronic_cron 0.2.28 → 0.2.29

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: 18ca6b9986162d123d81aaa8dbe1da0dd7d0eb5f
4
- data.tar.gz: a0dfb41b5ce09016b721dc86240dc179b2620fcb
3
+ metadata.gz: 0726ffc63935eadf82e49459e993bf8b1eda96eb
4
+ data.tar.gz: c22145d48434cc7c048561ee1f34efcff3eb7724
5
5
  SHA512:
6
- metadata.gz: 793e7397772cafeee53ace1978cae1eeb3b315247fa14b4d8291fb3b398648c6148a65b8b4579985a351fa18dbea5455fc46516d8b8a89e9e368e5c29fd94279
7
- data.tar.gz: 809a78a5b889d2506bc897133d7dc66d17441dada9dbaed57d14e76a176630468fe011d866984a3ab5176afdda5a976b42216b96ffebb28ef7673c0d9ba0ae69
6
+ metadata.gz: 0e0563354945b408a5996c84af4e5777d32a7d2b395d39f0b8db7627a16b1d81bc7b0f7673b64765e87068ece1628c54a13a655d27190966d4ec4007ca81a681
7
+ data.tar.gz: 4403940917553f50065674d72849f07330e0e162d8db88a5c83ce660cce3ae3490a0a981eb2f3d9dd5bb71ca357ef08e84120bbe08bcc7bc81b51b1277bbb075
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/chronic_cron.rb CHANGED
@@ -8,8 +8,6 @@ require 'cron_format'
8
8
  require 'timetoday'
9
9
 
10
10
 
11
- WEEK = DAY * 7
12
-
13
11
  class ChronicCron
14
12
  include AppRoutes
15
13
 
@@ -24,8 +22,7 @@ class ChronicCron
24
22
  expressions(@params)
25
23
 
26
24
  expression = find_expression(s.sub(/^(?:on|at|from|starting)\s+/,''))
27
-
28
- @cf = CronFormat.new(expression, now)
25
+ @cf = CronFormat.new(expression, now)
29
26
  @to_expression = @cf.to_expression
30
27
 
31
28
  end
@@ -238,33 +235,25 @@ class ChronicCron
238
235
  # e.g. first thursday of each month at 7:30pm
239
236
  nday = '(\w+(?:st|rd|nd))\s+' + weekday + '\s+'
240
237
  get /#{nday}(?:of\s+)?(?:the|each|every)\s+month(?:\s+at\s+([^\s]+))?/i do
241
- |nth_week, day_of_week, time|
238
+ |nth_week, day_of_week, raw_time|
242
239
 
243
240
  month = @now.month
244
241
 
245
242
  h = {
246
- /first|1st/ => 0,
247
- /second|2nd/ => 1,
248
- /third|3rd/ => 2,
249
- /fourth|4th|last/ => 3
243
+ /first|1st/ => '1-7',
244
+ /second|2nd/ => '8-14',
245
+ /third|3rd/ => '15-21',
246
+ /fourth|4th|last/ => '22-28'
250
247
  }
251
248
 
252
- _, nweek = h.find{|k,_| nth_week[k]}
249
+ _, day_range = h.find{|k,_| nth_week[k]}
250
+ a = %w(sunday monday tuesday wednesday thursday friday saturday)
251
+ wday = a.index(a.grep(/#{day_of_week}/).first)
253
252
 
254
- def make_date(day_of_week, month, time, nweek)
253
+ raw_time ||= '6:00am'
254
+ minute, hour = Chronic.parse(raw_time).to_a[1,2]
255
255
 
256
- Chronic.parse([day_of_week,month,time].join(' '), :now => @now) \
257
- + WEEK * nweek
258
- end
259
-
260
- months = Date::MONTHNAMES
261
- t = make_date day_of_week, months[month], time, nweek
262
-
263
- if t < @now
264
- t = make_date(day_of_week, months.rotate[month], time, nweek)
265
- end
266
-
267
- "%s %s %s %s * %s" % t.to_a.values_at(1,2,3,4,5)
256
+ "%s %s %s * %s" % [minute, hour, day_range, wday]
268
257
  end
269
258
 
270
259
  # e.g. 04-Aug@12:34
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.28
4
+ version: 0.2.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  aYYwh4InyS/QZr4LG0nh0TuYVP5vwm1cCSlLlo4dlv7bl7Q4y815j70z8O4oUrT8
30
30
  5oSIzmlVDEDmwAibYqdf+aHqmum1mkYW
31
31
  -----END CERTIFICATE-----
32
- date: 2014-01-11 00:00:00.000000000 Z
32
+ date: 2014-01-14 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: app-routes
metadata.gz.sig CHANGED
Binary file