fugit 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fugit might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/CREDITS.md +1 -0
- data/LICENSE.txt +1 -1
- data/Makefile +1 -1
- data/README.md +45 -1
- data/lib/fugit.rb +1 -1
- data/lib/fugit/cron.rb +12 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a10a8afb99cf16856e53766a86b1f0d13ddb0d2784c756cb525ceea8fbae7bd1
|
4
|
+
data.tar.gz: dcd1d01a8f5f8fc819854f430e12fc6bf69850e64060cffbe93c595be78785a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b29f59bffe4f786b90c0f0a42c26c682e78b523183863f7cfc8c486ecca9056bb96f5eae92b2ee9446ece5c84a10aeddd9a52077eece5357af8985853da99ee
|
7
|
+
data.tar.gz: a32ac9539496ff7f4bc1949f97eeefcf836a8f1607569080acafd2d338befd7cb97e10179ffee06d2da3ebead95830147f5f418a883a4bd2a77f549455761788
|
data/CHANGELOG.md
CHANGED
data/CREDITS.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
+
* Dominik Sander https://github.com/dsander #rough_frequency 0, gh-36
|
4
5
|
* Milovan Zogovic https://github.com/assembler Cron#match? vs TZ, gh-31
|
5
6
|
* Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30
|
6
7
|
* Shai Coleman https://github.com/shaicoleman parse_nat enhancements, gh-24, gh-25, and gh-28
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
Copyright (c) 2017-
|
2
|
+
Copyright (c) 2017-2020, John Mettraux, jmettraux+flor@gmail.com
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
data/Makefile
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,7 @@ The intersection of those two projects is where fugit is born:
|
|
36
36
|
* [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) -
|
37
37
|
* [flor](https://github.com/floraison/flor) - used in the [cron](https://github.com/floraison/flor/blob/master/doc/procedures/cron.md) procedure
|
38
38
|
* [que-scheduler](https://github.com/hlascelles/que-scheduler) - a reliable job scheduler for [que](https://github.com/chanks/que)
|
39
|
+
* [serial_scheduler](https://github.com/grosser/serial_scheduler) - ruby task scheduler without threading
|
39
40
|
* ...
|
40
41
|
|
41
42
|
## `Fugit.parse(s)`
|
@@ -137,6 +138,49 @@ Example of cron strings understood by fugit:
|
|
137
138
|
# and more...
|
138
139
|
```
|
139
140
|
|
141
|
+
### the first Monday of the month
|
142
|
+
|
143
|
+
Fugit tries to follow the `man 5 crontab` documentation.
|
144
|
+
|
145
|
+
There is a surprising thing about this canon, all the columns are joined by ANDs, except for monthday and weekday which are joined together by OR if they are both set (they are not `*`).
|
146
|
+
|
147
|
+
Many people (me included) [are suprised](https://superuser.com/questions/428807/run-a-cron-job-on-the-first-monday-of-every-month) when they try to specify "at 05:00 on the first Monday of the month" as `0 5 1-7 * 1` or `0 5 1-7 * mon` and the results are off.
|
148
|
+
|
149
|
+
The man page says:
|
150
|
+
|
151
|
+
> Note: The day of a command's execution can be specified by
|
152
|
+
> two fields -- day of month, and day of week. If both fields
|
153
|
+
> are restricted (ie, are not *), the command will be run when
|
154
|
+
> either field matches the current time.
|
155
|
+
> For example, ``30 4 1,15 * 5'' would cause a command to be run
|
156
|
+
> at 4:30 am on the 1st and 15th of each month, plus every Friday.
|
157
|
+
|
158
|
+
Fugit follows this specification.
|
159
|
+
|
160
|
+
There is a solution though, please read on.
|
161
|
+
|
162
|
+
### the hash extension
|
163
|
+
|
164
|
+
Fugit understands `0 5 * * 1#1` or `0 5 * * mon#1` as "each first Monday of the month, at 05:00".
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
'0 5 * * 1#1' #
|
168
|
+
'0 5 * * mon#1' # the first Monday of the month at 05:00
|
169
|
+
|
170
|
+
'0 6 * * 5#4,5#5' #
|
171
|
+
'0 6 * * fri#4,fri#5' # the 4th and 5th Fridays of the month at 06:00
|
172
|
+
|
173
|
+
'0 7 * * 5#-1' #
|
174
|
+
'0 7 * * fri#-1' # the last Friday of the month at 07:00
|
175
|
+
|
176
|
+
'0 7 * * 5#L' #
|
177
|
+
'0 7 * * fri#L' #
|
178
|
+
'0 7 * * 5#last' #
|
179
|
+
'0 7 * * fri#last' # the last Friday of the month at 07:00
|
180
|
+
|
181
|
+
'0 23 * * mon#2,tue' # the 2nd Monday of the month and every Tuesday, at 23:00
|
182
|
+
```
|
183
|
+
|
140
184
|
### the modulo extension
|
141
185
|
|
142
186
|
Fugit, since 1.1.10, also understands cron strings like "`9 0 * * sun%2`" which can be read as "every other Sunday at 9am".
|
@@ -145,7 +189,7 @@ For odd Sundays, one can write `9 0 * * sun%2+1`.
|
|
145
189
|
|
146
190
|
It can be combined, as in `9 0 * * sun%2,tue%3+2`
|
147
191
|
|
148
|
-
But what does it
|
192
|
+
But what does it reference to? It starts at 1 on 2019-01-01.
|
149
193
|
|
150
194
|
```ruby
|
151
195
|
require 'et-orbi' # >= 1.1.8
|
data/lib/fugit.rb
CHANGED
data/lib/fugit/cron.rb
CHANGED
@@ -188,6 +188,17 @@ module Fugit
|
|
188
188
|
|
189
189
|
return weekday_match?(nt) || monthday_match?(nt) \
|
190
190
|
if @weekdays && @monthdays
|
191
|
+
#
|
192
|
+
# From `man 5 crontab`
|
193
|
+
#
|
194
|
+
# Note: The day of a command's execution can be specified
|
195
|
+
# by two fields -- day of month, and day of week.
|
196
|
+
# If both fields are restricted (ie, are not *), the command will be
|
197
|
+
# run when either field matches the current time.
|
198
|
+
# For example, ``30 4 1,15 * 5'' would cause a command to be run
|
199
|
+
# at 4:30 am on the 1st and 15th of each month, plus every Friday.
|
200
|
+
#
|
201
|
+
# as seen in gh-5 and gh-35
|
191
202
|
|
192
203
|
return false unless weekday_match?(nt)
|
193
204
|
return false unless monthday_match?(nt)
|
@@ -336,6 +347,7 @@ module Fugit
|
|
336
347
|
return (a + [ a.first + v1 ])
|
337
348
|
.each_cons(2)
|
338
349
|
.collect { |a0, a1| a1 - a0 }
|
350
|
+
.select { |d| d > 0 } # weed out zero deltas
|
339
351
|
.min * v0
|
340
352
|
end
|
341
353
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fugit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|
@@ -117,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.5.2.3
|
120
|
+
rubygems_version: 3.0.3
|
122
121
|
signing_key:
|
123
122
|
specification_version: 4
|
124
123
|
summary: time tools for flor
|