fugit 1.8.1 → 1.9.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 +6 -0
- data/CREDITS.md +1 -0
- data/README.md +0 -1
- data/lib/fugit/cron.rb +36 -29
- data/lib/fugit/nat.rb +33 -5
- 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: '0099e4aa474e4886e99da33f4b76abd19f259d3a6eb64cd2bfe12f99f6256a23'
|
4
|
+
data.tar.gz: 38c3fbe7b620cc6460f1b7b7d3e96298400c82d7dec7ef9d4b543925dff6e74a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75e41e393e779e06ec6280e6e2065877b4771fcca8b63307af13f7fe2407fc9a1fef75eca5a690fe9f3cec6b791deaa4c8b23c925326b24753c5ae8197d5a5bd
|
7
|
+
data.tar.gz: e9ac1c2b0412a9e2549257b1d73490f4319335c847a6faff212dd8c8a9cbaa52787617491d76648763efbd24caffc39a91e08f06910970905dc810ef9fec36cc
|
data/CHANGELOG.md
CHANGED
data/CREDITS.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
+
* Marcos Belluci, https://github.com/delbetu, gh-88 , 1st and last nat
|
4
5
|
* Michael Reinsch, https://github.com/mreinsch, gh-84 and gh-85
|
5
6
|
* Marc Anguera, https://github.com/markets, gh-70 and Sidekiq-Cron
|
6
7
|
* ski-nine, https://github.com/ski-nine, gh-81
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
[![tests](https://github.com/floraison/fugit/workflows/test/badge.svg)](https://github.com/floraison/fugit/actions)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/fugit.svg)](http://badge.fury.io/rb/fugit)
|
6
|
-
[![Join the chat at https://gitter.im/floraison/fugit](https://badges.gitter.im/floraison/fugit.svg)](https://gitter.im/floraison/fugit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
6
|
|
8
7
|
Time tools for [flor](https://github.com/floraison/flor) and the floraison group.
|
9
8
|
|
data/lib/fugit/cron.rb
CHANGED
@@ -40,8 +40,6 @@ module Fugit
|
|
40
40
|
#p s; Raabro.pp(Parser.parse(s, debug: 3), colors: true)
|
41
41
|
h = Parser.parse(s.strip)
|
42
42
|
|
43
|
-
return nil unless h
|
44
|
-
|
45
43
|
self.allocate.send(:init, s, h)
|
46
44
|
end
|
47
45
|
|
@@ -488,18 +486,22 @@ module Fugit
|
|
488
486
|
|
489
487
|
def init(original, h)
|
490
488
|
|
489
|
+
return nil unless h
|
490
|
+
|
491
491
|
@original = original
|
492
492
|
@cron_s = nil # just to be sure
|
493
493
|
@day_and = h[:&]
|
494
494
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
495
|
+
valid =
|
496
|
+
determine_seconds(h[:sec]) &&
|
497
|
+
determine_minutes(h[:min]) &&
|
498
|
+
determine_hours(h[:hou]) &&
|
499
|
+
determine_monthdays(h[:dom]) &&
|
500
|
+
determine_months(h[:mon]) &&
|
501
|
+
determine_weekdays(h[:dow]) &&
|
502
|
+
determine_timezone(h[:tz])
|
502
503
|
|
504
|
+
return nil unless valid
|
503
505
|
return nil unless compact_month_days
|
504
506
|
|
505
507
|
self
|
@@ -509,10 +511,12 @@ module Fugit
|
|
509
511
|
|
510
512
|
sta, edn, sla = r
|
511
513
|
|
514
|
+
return false if sla && sla > max
|
515
|
+
|
512
516
|
edn = max if sla && edn.nil?
|
513
517
|
|
514
|
-
return
|
515
|
-
return
|
518
|
+
return nil if sta.nil? && edn.nil? && sla.nil?
|
519
|
+
return sta if sta && edn.nil?
|
516
520
|
|
517
521
|
sla = 1 if sla == nil
|
518
522
|
sta = min if sta == nil
|
@@ -563,42 +567,41 @@ module Fugit
|
|
563
567
|
.uniq
|
564
568
|
end
|
565
569
|
|
566
|
-
def
|
570
|
+
def do_determine(key, arr, min, max)
|
567
571
|
|
568
|
-
|
572
|
+
null = false
|
569
573
|
|
570
|
-
|
571
|
-
|
574
|
+
r = arr
|
575
|
+
.collect { |v|
|
576
|
+
expand(min, max, v) }
|
577
|
+
.flatten(1)
|
578
|
+
.collect { |e|
|
579
|
+
return false if e == false
|
580
|
+
null = null || e == nil
|
581
|
+
(key == :hours && e == 24) ? 0 : e }
|
572
582
|
|
573
|
-
|
574
|
-
|
583
|
+
return nil if null
|
584
|
+
r.uniq.sort
|
575
585
|
end
|
576
586
|
|
577
587
|
def determine_seconds(arr)
|
578
|
-
@seconds = (arr || [ 0 ]
|
579
|
-
compact(:@seconds)
|
588
|
+
(@seconds = do_determine(:seconds, arr || [ 0 ], 0, 59)) != false
|
580
589
|
end
|
581
590
|
|
582
591
|
def determine_minutes(arr)
|
583
|
-
@minutes =
|
584
|
-
compact(:@minutes)
|
592
|
+
(@minutes = do_determine(:minutes, arr, 0, 59)) != false
|
585
593
|
end
|
586
594
|
|
587
595
|
def determine_hours(arr)
|
588
|
-
@hours = arr
|
589
|
-
.inject([]) { |a, h| a.concat(expand(0, 23, h)) }
|
590
|
-
.collect { |h| h == 24 ? 0 : h }
|
591
|
-
compact(:@hours)
|
596
|
+
(@hours = do_determine(:hours, arr, 0, 23)) != false
|
592
597
|
end
|
593
598
|
|
594
599
|
def determine_monthdays(arr)
|
595
|
-
@monthdays =
|
596
|
-
compact(:@monthdays)
|
600
|
+
(@monthdays = do_determine(:monthdays, arr, 1, 31)) != false
|
597
601
|
end
|
598
602
|
|
599
603
|
def determine_months(arr)
|
600
|
-
@months =
|
601
|
-
compact(:@months)
|
604
|
+
(@months = do_determine(:months, arr, 1, 12)) != false
|
602
605
|
end
|
603
606
|
|
604
607
|
def determine_weekdays(arr)
|
@@ -624,11 +627,15 @@ module Fugit
|
|
624
627
|
@weekdays.uniq!
|
625
628
|
@weekdays.sort!
|
626
629
|
@weekdays = nil if @weekdays.empty?
|
630
|
+
|
631
|
+
true
|
627
632
|
end
|
628
633
|
|
629
634
|
def determine_timezone(z)
|
630
635
|
|
631
636
|
@zone, @timezone = z
|
637
|
+
|
638
|
+
true
|
632
639
|
end
|
633
640
|
|
634
641
|
def weekdays_to_cron_s
|
data/lib/fugit/nat.rb
CHANGED
@@ -642,9 +642,9 @@ module Fugit
|
|
642
642
|
fail(ArgumentError.new(
|
643
643
|
"multiple crons in #{opts[:_s].inspect} - #{@slots.inspect}"))
|
644
644
|
elsif multi == true
|
645
|
-
hms.collect { |hm| parse_cron(hm) }
|
645
|
+
hms.collect { |hm| parse_cron(hm, opts) }
|
646
646
|
else
|
647
|
-
parse_cron(hms.first)
|
647
|
+
parse_cron(hms.first, opts)
|
648
648
|
end
|
649
649
|
end
|
650
650
|
|
@@ -678,7 +678,7 @@ module Fugit
|
|
678
678
|
.to_a
|
679
679
|
end
|
680
680
|
|
681
|
-
def parse_cron(hm)
|
681
|
+
def parse_cron(hm, opts)
|
682
682
|
|
683
683
|
a = [
|
684
684
|
slot(:second, '0'),
|
@@ -691,11 +691,39 @@ module Fugit
|
|
691
691
|
a << tz.data0 if tz
|
692
692
|
a.shift if a.first == [ '0' ]
|
693
693
|
|
694
|
+
letters_last = lambda { |x| x.is_a?(Numeric) ? x : 999_999 }
|
695
|
+
|
694
696
|
s = a
|
695
|
-
.collect { |e|
|
697
|
+
.collect { |e|
|
698
|
+
e.uniq.sort_by(&letters_last).collect(&:to_s).join(',') }
|
696
699
|
.join(' ')
|
697
700
|
|
698
|
-
Fugit::Cron.parse(s)
|
701
|
+
c = Fugit::Cron.parse(s)
|
702
|
+
|
703
|
+
if opts[:strict]
|
704
|
+
restrict(a, c)
|
705
|
+
else
|
706
|
+
c
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
# Return nil if the cron is "not strict"
|
711
|
+
#
|
712
|
+
# For example, "0 0/17 * * *" (gh-86) is a perfectly valid
|
713
|
+
# cron string, but makes not much sense when derived via `.parse_nat`
|
714
|
+
# from "every 17 hours".
|
715
|
+
#
|
716
|
+
# It happens here because it's nat being strict, not cron.
|
717
|
+
#
|
718
|
+
def restrict(a, cron)
|
719
|
+
|
720
|
+
if m = ((a[1] && a[1][0]) || '').match(/^(\d+|\*)\/(\d+)$/)
|
721
|
+
#p m
|
722
|
+
sla = m[1].to_i
|
723
|
+
return nil unless [ 1, 2, 3, 4, 5, 6, 8, 12 ].include?(sla)
|
724
|
+
end
|
725
|
+
|
726
|
+
cron
|
699
727
|
end
|
700
728
|
|
701
729
|
def slot(key, default)
|
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.9.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: 2023-
|
11
|
+
date: 2023-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.2.33
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: time tools for flor
|