fugit 1.10.1 → 1.11.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 +5 -0
- data/CREDITS.md +3 -0
- data/README.md +10 -1
- data/fugit.gemspec +1 -1
- data/lib/fugit/cron.rb +8 -1
- data/lib/fugit/duration.rb +1 -1
- data/lib/fugit/parse.rb +19 -2
- data/lib/fugit.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85c52688755255cf02f4dde422a66df260a9e9b1e13d7aebc08ff48e4c3fd158
|
4
|
+
data.tar.gz: bf29e925bda6258e55e25208cfacff5ad82dfd9bd28683bb65c79ec95c5e37f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6754049a51e4886bd806fe7d97ea64e5e0fc74851c579a7e8d46b7b42dedaa08aea04a9a8bec2f6c560df8a5cf57977dfdc6f8f33a73675dad885ad95b22c73f
|
7
|
+
data.tar.gz: 03b507d208bee88cae70f7d85875e931600576a2e048fd8523d8c7ed58b8d34ea40423ff93be04cab42e73bb67ed5580e41e89e0bae1363c9a624a8865979d4f
|
data/CHANGELOG.md
CHANGED
data/CREDITS.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
+
* Michael Scrivo, https://github.com/mscrivo, gh-103
|
5
|
+
* Benjamin Darcet, https://github.com/bdarcet gh-95 gh-96 et-orbi #rweek
|
6
|
+
* https://github.com/franckduche gh-95 gh-96 et-orbi #rweek
|
4
7
|
* https://hithub.com/aunghtain, gh-93, include oneliner vs Ruby 2.6.6
|
5
8
|
* Marcos Belluci, https://github.com/delbetu, gh-88, 1st and last nat
|
6
9
|
* Michael Reinsch, https://github.com/mreinsch, gh-84 and gh-85
|
data/README.md
CHANGED
@@ -34,13 +34,14 @@ The intersection of those two projects is where fugit is born:
|
|
34
34
|
### Projects using fugit
|
35
35
|
|
36
36
|
* [arask](https://github.com/Ebbe/arask) - "Automatic RAils taSKs" uses fugit to parse cron strings
|
37
|
-
* [sidekiq-cron](https://github.com/ondrejbartas/sidekiq-cron) -
|
37
|
+
* [sidekiq-cron](https://github.com/ondrejbartas/sidekiq-cron) - uses fugit to parse cron strings since version 1.0.0, it was using rufus-scheduler previously
|
38
38
|
* [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) - as seen above
|
39
39
|
* [flor](https://github.com/floraison/flor) - used in the [cron](https://github.com/floraison/flor/blob/master/doc/procedures/cron.md) procedure
|
40
40
|
* [que-scheduler](https://github.com/hlascelles/que-scheduler) - a reliable job scheduler for [que](https://github.com/chanks/que)
|
41
41
|
* [serial_scheduler](https://github.com/grosser/serial_scheduler) - ruby task scheduler without threading
|
42
42
|
* [delayed_cron_job](https://github.com/codez/delayed_cron_job) - an extension to Delayed::Job that allows you to set cron expressions for your jobs
|
43
43
|
* [GoodJob](https://github.com/bensheldon/good_job) - a multithreaded, Postgres-based, Active Job backend for Ruby on Rails
|
44
|
+
* [Solid Queue](https://github.com/rails/solid_queue) - a DB-based queuing backend for Active Job, designed with simplicity and performance in mind
|
44
45
|
* ...
|
45
46
|
|
46
47
|
## `Fugit.parse(s)`
|
@@ -140,6 +141,8 @@ c = Fugit.parse_cron('0 12 * * mon#2')
|
|
140
141
|
|
141
142
|
# `#next` and `#prev` return Enumerable instances
|
142
143
|
#
|
144
|
+
# These two methods are available since fugit 1.10.0.
|
145
|
+
#
|
143
146
|
c.next(Time.parse('2024-02-16 12:00:00'))
|
144
147
|
.take(3)
|
145
148
|
.map(&:to_s)
|
@@ -157,6 +160,8 @@ c.prev(Time.parse('2024-02-16 12:00:00'))
|
|
157
160
|
# instances that correspond to the occurrences of the cron within
|
158
161
|
# the time range
|
159
162
|
#
|
163
|
+
# This method is available since fugit 1.10.0.
|
164
|
+
#
|
160
165
|
c.within(Time.parse('2024-02-16 12:00')..Time.parse('2024-08-01 12:00'))
|
161
166
|
.map(&:to_s)
|
162
167
|
# => [ '2024-03-11 12:00:00',
|
@@ -251,6 +256,8 @@ p Fugit.parse_cron('59 6 1-7& * 2&').next_time('2020-03-15').to_s
|
|
251
256
|
|
252
257
|
Fugit understands `0 5 * * 1#1` or `0 5 * * mon#1` as "each first Monday of the month, at 05:00".
|
253
258
|
|
259
|
+
The hash extension can only be used in the day-of-week field.
|
260
|
+
|
254
261
|
```ruby
|
255
262
|
'0 5 * * 1#1' #
|
256
263
|
'0 5 * * mon#1' # the first Monday of the month at 05:00
|
@@ -273,6 +280,8 @@ Fugit understands `0 5 * * 1#1` or `0 5 * * mon#1` as "each first Monday of the
|
|
273
280
|
|
274
281
|
Fugit, since 1.1.10, also understands cron strings like "`9 0 * * sun%2`" which can be read as "every other Sunday at 9am".
|
275
282
|
|
283
|
+
The modulo extension can only be used in the day-of-week field.
|
284
|
+
|
276
285
|
For odd Sundays, one can write `9 0 * * sun%2+1`.
|
277
286
|
|
278
287
|
It can be combined, as in `9 0 * * sun%2,tue%3+2`
|
data/fugit.gemspec
CHANGED
@@ -41,7 +41,7 @@ Time tools for flor and the floraison project. Cron parsing and occurrence compu
|
|
41
41
|
# this dependency appears in 'et-orbi'
|
42
42
|
|
43
43
|
s.add_runtime_dependency 'raabro', '~> 1.4'
|
44
|
-
s.add_runtime_dependency 'et-orbi', '~> 1', '>= 1.2.
|
44
|
+
s.add_runtime_dependency 'et-orbi', '~> 1', '>= 1.2.11'
|
45
45
|
|
46
46
|
s.add_development_dependency 'rspec', '~> 3.8'
|
47
47
|
s.add_development_dependency 'chronic', '~> 0.10'
|
data/lib/fugit/cron.rb
CHANGED
@@ -264,6 +264,8 @@ module Fugit
|
|
264
264
|
"please fill an issue at https://git.io/fjJC9"
|
265
265
|
) if (i += 1) > MAX_ITERATION_COUNT
|
266
266
|
|
267
|
+
#tt = t.time;
|
268
|
+
#puts " #{tt.strftime('%F %T %:z %A')} #{tt.rweek} #{tt.rweek % 2}"
|
267
269
|
(ifrom == t.to_i) && (t.inc(1); next)
|
268
270
|
month_match?(t) || (t.inc_month; next)
|
269
271
|
day_match?(t) || (t.inc_day; next)
|
@@ -307,6 +309,8 @@ module Fugit
|
|
307
309
|
"please fill an issue at https://git.io/fjJCQ"
|
308
310
|
) if (i += 1) > MAX_ITERATION_COUNT
|
309
311
|
|
312
|
+
#tt = t.time;
|
313
|
+
#puts " #{tt.strftime('%F %T %:z %A')} #{tt.rweek} #{tt.rweek % 4}"
|
310
314
|
month_match?(t) || (t.dec_month; next)
|
311
315
|
day_match?(t) || (t.dec_day; next)
|
312
316
|
hour_match?(t) || (t.dec_hour; next)
|
@@ -565,7 +569,10 @@ module Fugit
|
|
565
569
|
|
566
570
|
sta, edn, sla = r
|
567
571
|
|
568
|
-
return false if sla && sla > max
|
572
|
+
#return false if sla && sla > max
|
573
|
+
#
|
574
|
+
# let it go, "* */24 * * *" and "* */27 * * *" are okay
|
575
|
+
# gh-86 and gh-103
|
569
576
|
|
570
577
|
edn = max if sla && edn.nil?
|
571
578
|
|
data/lib/fugit/duration.rb
CHANGED
@@ -258,7 +258,7 @@ module Fugit
|
|
258
258
|
when Numeric then add_numeric(a)
|
259
259
|
when Fugit::Duration then add_duration(a)
|
260
260
|
when String then add_duration(self.class.parse(a))
|
261
|
-
when ::Time, EtOrbi::EoTime then add_to_time(a)
|
261
|
+
when ::Time, ::EtOrbi::EoTime then add_to_time(a)
|
262
262
|
else fail ArgumentError.new(
|
263
263
|
"cannot add #{a.class} instance to a Fugit::Duration")
|
264
264
|
end
|
data/lib/fugit/parse.rb
CHANGED
@@ -29,8 +29,25 @@ module Fugit
|
|
29
29
|
|
30
30
|
def do_parse(s, opts={})
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
opts[:at] = opts[:in] if opts.has_key?(:in)
|
33
|
+
|
34
|
+
result = nil
|
35
|
+
errors = []
|
36
|
+
|
37
|
+
%i[ cron duration nat at ]
|
38
|
+
.each { |k|
|
39
|
+
begin
|
40
|
+
result ||= (opts[k] != false && self.send("do_parse_#{k}", s))
|
41
|
+
rescue => err
|
42
|
+
errors << err
|
43
|
+
end }
|
44
|
+
|
45
|
+
return result if result
|
46
|
+
|
47
|
+
raise(
|
48
|
+
errors.find { |r| r.class != ArgumentError } ||
|
49
|
+
errors.first ||
|
50
|
+
ArgumentError.new("found no time information in #{s.inspect}"))
|
34
51
|
end
|
35
52
|
|
36
53
|
def parse_cronish(s, opts={})
|
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.11.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: 2024-
|
11
|
+
date: 2024-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '1'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.2.
|
36
|
+
version: 1.2.11
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '1'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.2.
|
46
|
+
version: 1.2.11
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|