fugit 1.5.3 → 1.7.0
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/CREDITS.md +4 -1
- data/README.md +29 -2
- data/lib/fugit/cron.rb +27 -13
- data/lib/fugit/nat.rb +2 -0
- data/lib/fugit.rb +1 -1
- metadata +3 -3
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,18 @@
|
|
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
|
+
|
12
|
+
## fugit 1.6.0 release 2022-08-25
|
13
|
+
|
14
|
+
* Ensure input strings are stripped before parsing, gh-74
|
15
|
+
|
16
|
+
|
5
17
|
## fugit 1.5.3 released 2022-04-02
|
6
18
|
|
7
19
|
* Fix Fugit::Cron.to_s vs "0 13 * * wed%2", gh-68
|
data/CREDITS.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
-
*
|
4
|
+
* James Healy, https://github.com/yob, gh-76
|
5
|
+
* John Bachir, https://github.com/jjb, gh-74
|
6
|
+
* Vivek Miyani, https://github.com/vivekmiyani, gh-71
|
7
|
+
* Peter Goldstein, https://github.com/petergoldstein infra, gh-65, -72
|
5
8
|
* Pascal Zumkehr https://github.com/codez gh-62, Santiago into DST vs Time.zone
|
6
9
|
* Ggallardoh https://github.com/Ggallardoh gh-60, America/Santiago into DST
|
7
10
|
* Khaled AbuShqear https://github.com/shqear93 gh-57, "12pm"
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ The intersection of those two projects is where fugit is born:
|
|
32
32
|
### Projects using fugit
|
33
33
|
|
34
34
|
* [arask](https://github.com/Ebbe/arask) - "Automatic RAils taSKs" uses fugit to parse cron strings
|
35
|
-
* [
|
35
|
+
* [sidekiq-cron](https://github.com/ondrejbartas/sidekiq-cron) - recent versions of Sidekiq-Cron use fugit to parse cron strings
|
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)
|
@@ -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
@@ -38,7 +38,7 @@ module Fugit
|
|
38
38
|
return nil unless s.is_a?(String)
|
39
39
|
|
40
40
|
#p s; Raabro.pp(Parser.parse(s, debug: 3), colors: true)
|
41
|
-
h = Parser.parse(s)
|
41
|
+
h = Parser.parse(s.strip)
|
42
42
|
|
43
43
|
return nil unless h
|
44
44
|
|
@@ -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/nat.rb
CHANGED
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
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.1.
|
120
|
+
rubygems_version: 3.1.6
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: time tools for flor
|