fugit 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CREDITS.md +1 -0
- data/README.md +28 -1
- data/lib/fugit/cron.rb +26 -12
- data/lib/fugit.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea7cc032d87a0f7ae6b3d1c10b78b3a51ed489db18a1c8dd63f52ef05cfb165f
|
4
|
+
data.tar.gz: 737984c5dfc4898ce0db368b63ddc8768feb5a88a02406dcb2ba17990e6e04ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f17852170b61062dabba069888f8e6323a9f58df21fb00855b151f9312c15bbc8dbcfdad9afc3704a5c0033ff753880c8cbc89b0886be620766637bc934486
|
7
|
+
data.tar.gz: 47381199f997c6ad29d65eb1364fe5f931f025f32ef94c2c9c07badfa34a29aad9b8854c97b36151db7d0b976d053079e14f1411050107920cf15928c6d97300
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
# CHANGELOG.md
|
3
3
|
|
4
4
|
|
5
|
+
## fugit 1.7.0 released 2022-09-15
|
6
|
+
|
7
|
+
* Introduce the & cron syntax (day-of-month AND day-of-week), gh-78
|
8
|
+
* Change how cron deals with modulo and offset, gh-76
|
9
|
+
* Be liberal with extra commas, gh-77
|
10
|
+
|
11
|
+
|
5
12
|
## fugit 1.6.0 release 2022-08-25
|
6
13
|
|
7
14
|
* Ensure input strings are stripped before parsing, gh-74
|
data/CREDITS.md
CHANGED
data/README.md
CHANGED
@@ -160,7 +160,34 @@ The man page says:
|
|
160
160
|
|
161
161
|
Fugit follows this specification.
|
162
162
|
|
163
|
-
|
163
|
+
Since fugit 1.7.0, by adding `&` right after a day specifier, the `day-of-month OR day-of-week` becomes `day-of-month AND day-of-week`.
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
# standard cron
|
167
|
+
|
168
|
+
p Fugit.parse_cron('0 0 */2 * 1-5').next_time('2022-08-09').to_s
|
169
|
+
# ==> "2022-08-10 00:00:00 +0900"
|
170
|
+
|
171
|
+
# with an &
|
172
|
+
|
173
|
+
p Fugit.parse_cron('0 0 */2 * 1-5&').next_time('2022-08-09').to_s # or
|
174
|
+
p Fugit.parse_cron('0 0 */2& * 1-5').next_time('2022-08-09').to_s
|
175
|
+
p Fugit.parse_cron('0 0 */2& * 1-5&').next_time('2022-08-09').to_s
|
176
|
+
# ==> "2022-08-11 00:00:00 +0900"
|
177
|
+
|
178
|
+
|
179
|
+
# standard cron
|
180
|
+
|
181
|
+
p Fugit.parse_cron('59 6 1-7 * 2').next_time('2020-03-15').to_s
|
182
|
+
# ==> "2020-03-17 06:59:00 +0900"
|
183
|
+
|
184
|
+
# with an &
|
185
|
+
|
186
|
+
p Fugit.parse_cron('59 6 1-7 * 2&').next_time('2020-03-15').to_s
|
187
|
+
p Fugit.parse_cron('59 6 1-7& * 2').next_time('2020-03-15').to_s
|
188
|
+
p Fugit.parse_cron('59 6 1-7& * 2&').next_time('2020-03-15').to_s
|
189
|
+
# ==> "2020-04-07 06:59:00 +0900"
|
190
|
+
```
|
164
191
|
|
165
192
|
### the hash extension
|
166
193
|
|
data/lib/fugit/cron.rb
CHANGED
@@ -167,7 +167,7 @@ module Fugit
|
|
167
167
|
|
168
168
|
def weekday_modulo_match?(nt, mod)
|
169
169
|
|
170
|
-
(nt.rweek
|
170
|
+
(nt.rweek % mod[0]) == (mod[1] % mod[0])
|
171
171
|
end
|
172
172
|
|
173
173
|
def weekday_match?(nt)
|
@@ -199,8 +199,14 @@ module Fugit
|
|
199
199
|
|
200
200
|
def day_match?(nt)
|
201
201
|
|
202
|
-
|
203
|
-
|
202
|
+
if @weekdays && @monthdays
|
203
|
+
|
204
|
+
return weekday_match?(nt) && monthday_match?(nt) \
|
205
|
+
if @day_and
|
206
|
+
#
|
207
|
+
# extension for fugit, gh-78
|
208
|
+
|
209
|
+
return weekday_match?(nt) || monthday_match?(nt)
|
204
210
|
#
|
205
211
|
# From `man 5 crontab`
|
206
212
|
#
|
@@ -212,6 +218,8 @@ module Fugit
|
|
212
218
|
# at 4:30 am on the 1st and 15th of each month, plus every Friday.
|
213
219
|
#
|
214
220
|
# as seen in gh-5 and gh-35
|
221
|
+
end
|
222
|
+
|
215
223
|
|
216
224
|
return false unless weekday_match?(nt)
|
217
225
|
return false unless monthday_match?(nt)
|
@@ -482,6 +490,7 @@ module Fugit
|
|
482
490
|
|
483
491
|
@original = original
|
484
492
|
@cron_s = nil # just to be sure
|
493
|
+
@day_and = h[:&]
|
485
494
|
|
486
495
|
determine_seconds(h[:sec])
|
487
496
|
determine_minutes(h[:min])
|
@@ -660,7 +669,9 @@ module Fugit
|
|
660
669
|
def s(i); rex(nil, i, /[ \t]+/); end
|
661
670
|
def star(i); str(nil, i, '*'); end
|
662
671
|
def hyphen(i); str(nil, i, '-'); end
|
663
|
-
def comma(i);
|
672
|
+
def comma(i); rex(nil, i, /,([ \t]*,)*/); end
|
673
|
+
def comma?(i); rex(nil, i, /([ \t]*,)*/); end
|
674
|
+
def and?(i); rex(nil, i, /&?/); end
|
664
675
|
|
665
676
|
def slash(i); rex(:slash, i, /\/\d\d?/); end
|
666
677
|
|
@@ -720,12 +731,12 @@ module Fugit
|
|
720
731
|
def list_mon(i); jseq(:mon, i, :mon_elt, :comma); end
|
721
732
|
def list_dow(i); jseq(:dow, i, :dow_elt_, :comma); end
|
722
733
|
|
723
|
-
def lsec_(i); seq(nil, i, :list_sec, :s); end
|
724
|
-
def lmin_(i); seq(nil, i, :list_min, :s); end
|
725
|
-
def lhou_(i); seq(nil, i, :list_hou, :s); end
|
726
|
-
def ldom_(i); seq(nil, i, :list_dom, :s); end
|
727
|
-
def lmon_(i); seq(nil, i, :list_mon, :s); end
|
728
|
-
|
734
|
+
def lsec_(i); seq(nil, i, :comma?, :list_sec, :comma?, :s); end
|
735
|
+
def lmin_(i); seq(nil, i, :comma?, :list_min, :comma?, :s); end
|
736
|
+
def lhou_(i); seq(nil, i, :comma?, :list_hou, :comma?, :s); end
|
737
|
+
def ldom_(i); seq(nil, i, :comma?, :list_dom, :comma?, :and?, :s); end
|
738
|
+
def lmon_(i); seq(nil, i, :comma?, :list_mon, :comma?, :s); end
|
739
|
+
def ldow(i); seq(nil, i, :comma?, :list_dow, :comma?, :and?); end
|
729
740
|
|
730
741
|
def _tz_name(i)
|
731
742
|
rex(nil, i, / +[A-Z][a-zA-Z0-9+\-]+(\/[A-Z][a-zA-Z0-9+\-_]+){0,2}/)
|
@@ -736,10 +747,12 @@ module Fugit
|
|
736
747
|
def _tz(i); alt(:tz, i, :_tz_delta, :_tz_name); end
|
737
748
|
|
738
749
|
def classic_cron(i)
|
739
|
-
seq(:ccron, i,
|
750
|
+
seq(:ccron, i,
|
751
|
+
:lmin_, :lhou_, :ldom_, :lmon_, :ldow, :_tz, '?')
|
740
752
|
end
|
741
753
|
def second_cron(i)
|
742
|
-
seq(:scron, i,
|
754
|
+
seq(:scron, i,
|
755
|
+
:lsec_, :lmin_, :lhou_, :ldom_, :lmon_, :ldow, :_tz, '?')
|
743
756
|
end
|
744
757
|
|
745
758
|
def cron(i)
|
@@ -821,6 +834,7 @@ module Fugit
|
|
821
834
|
.inject({}) { |h, tt|
|
822
835
|
h[tt.name] = tt.name == :tz ? rewrite_tz(tt) : rewrite_entry(tt)
|
823
836
|
h }
|
837
|
+
hcron[:&] = true if t.string.index('&')
|
824
838
|
|
825
839
|
z, tz = hcron[:tz]; return nil if z && ! tz
|
826
840
|
|
data/lib/fugit.rb
CHANGED
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.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|