fugit 1.5.3 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd6f6af6264734f4eb10d5aa8e88cbcfbca029fb697f20b7a0ae37d220c55653
4
- data.tar.gz: 25606c4f975d71350a360f4feb092a54f88bbb022fef31e4eb13c22d98b36b8f
3
+ metadata.gz: 318e360c503855580a65262f188ae07d02a17c1e833aeb5d8d21e25a67a9805c
4
+ data.tar.gz: 54b9eaeba60e6c1a64db0ca2b5e86ed09e74d8c4afeb32677314946f8b1d5211
5
5
  SHA512:
6
- metadata.gz: 253c2fc474a22ff93caa8b1f465af16565ab8b69037f7e83dc1e42719085d95342ee9d7a43200bdb05bcc9815dc29f590c5d86df51b7f526e25bb6d96dd4ef02
7
- data.tar.gz: '0951e692d8026d3a66c374e99f872bd03270f77e93232bbbecefac44c8b9b17253b46218dbb36f9f009441bb6d602c04f40dad7782df31674e26244c1ce59055'
6
+ metadata.gz: c2813ab3974e9dcc7b3b6552bc8a5855617ac40b26190f84a3cbd413108d4b2ebc6a8c9418389a873844161289f60d48bece8fc10ca25295414e2e04c1da1474
7
+ data.tar.gz: 6e8587a3894c801bc220f967e3f5b0fed6e1bdea0bc606841fe188f890c8a0f6756f4b5357fd4cd887ff7d9bfd0a6bde68a1405ff369f7b4d41b8ec3e14c1c4b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.7.1 released 2022-09-21
6
+
7
+ * Change behaviour for "0 0/5 * * *", gh-79
8
+ go "every 5h start hour 0", previous behaviour only triggered at hour 0
9
+
10
+
11
+ ## fugit 1.7.0 released 2022-09-15
12
+
13
+ * Introduce the & cron syntax (day-of-month AND day-of-week), gh-78
14
+ * Change how cron deals with modulo and offset, gh-76
15
+ * Be liberal with extra commas, gh-77
16
+
17
+
18
+ ## fugit 1.6.0 release 2022-08-25
19
+
20
+ * Ensure input strings are stripped before parsing, gh-74
21
+
22
+
5
23
  ## fugit 1.5.3 released 2022-04-02
6
24
 
7
25
  * Fix Fugit::Cron.to_s vs "0 13 * * wed%2", gh-68
data/CREDITS.md CHANGED
@@ -1,7 +1,11 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
- * Peter Goldstein, https://github.com/petergoldstein GHA 3.3 j9.3, gh-65
4
+ * Joseph Halter, https://github.com/JosephHalter, gh-79
5
+ * James Healy, https://github.com/yob, gh-76
6
+ * John Bachir, https://github.com/jjb, gh-74
7
+ * Vivek Miyani, https://github.com/vivekmiyani, gh-71
8
+ * Peter Goldstein, https://github.com/petergoldstein infra, gh-65, -72
5
9
  * Pascal Zumkehr https://github.com/codez gh-62, Santiago into DST vs Time.zone
6
10
  * Ggallardoh https://github.com/Ggallardoh gh-60, America/Santiago into DST
7
11
  * 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
- * [sideqik-cron](https://github.com/ondrejbartas/sidekiq-cron) - recent versions of Sideqik-Cron use fugit to parse cron strings
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
- There is a solution though, please read on.
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/fugit.gemspec CHANGED
@@ -32,7 +32,7 @@ Time tools for flor and the floraison project. Cron parsing and occurrence compu
32
32
  s.files = Dir[
33
33
  'README.{md,txt}',
34
34
  'CHANGELOG.{md,txt}', 'CREDITS.{md,txt}', 'LICENSE.{md,txt}',
35
- 'Makefile',
35
+ #'Makefile',
36
36
  'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
37
37
  "#{s.name}.gemspec",
38
38
  ]
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 + mod[1]) % mod[0] == 0
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
- return weekday_match?(nt) || monthday_match?(nt) \
203
- if @weekdays && @monthdays
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])
@@ -500,8 +509,6 @@ module Fugit
500
509
 
501
510
  sta, edn, sla = r
502
511
 
503
- sla = nil if sla == 1 # don't get fooled by /1
504
-
505
512
  edn = max if sla && edn.nil?
506
513
 
507
514
  return [ nil ] if sta.nil? && edn.nil? && sla.nil?
@@ -516,6 +523,8 @@ module Fugit
516
523
 
517
524
  def range(min, max, sta, edn, sla)
518
525
 
526
+ return [ nil ] if sta == min && edn == max && sla == 1
527
+
519
528
  fail ArgumentError.new(
520
529
  'both start and end must be negative in ' +
521
530
  { min: min, max: max, sta: sta, edn: edn, sla: sla }.inspect
@@ -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); str(nil, i, ','); end
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
- alias ldow list_dow
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, :lmin_, :lhou_, :ldom_, :lmon_, :ldow, :_tz, '?')
750
+ seq(:ccron, i,
751
+ :lmin_, :lhou_, :ldom_, :lmon_, :ldow, :_tz, '?')
740
752
  end
741
753
  def second_cron(i)
742
- seq(:scron, i, :lsec_, :lmin_, :lhou_, :ldom_, :lmon_, :ldow, :_tz, '?')
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
@@ -15,6 +15,8 @@ module Fugit
15
15
 
16
16
  return nil unless s.is_a?(String)
17
17
 
18
+ s = s.strip
19
+
18
20
  #p s; Raabro.pp(Parser.parse(s, debug: 3), colours: true)
19
21
  #(p s; Raabro.pp(Parser.parse(s, debug: 1), colours: true)) rescue nil
20
22
 
data/lib/fugit.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Fugit
5
5
 
6
- VERSION = '1.5.3'
6
+ VERSION = '1.7.1'
7
7
  end
8
8
 
9
9
  require 'time'
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.5.3
4
+ version: 1.7.1
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-04-02 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
@@ -83,7 +83,6 @@ files:
83
83
  - CHANGELOG.md
84
84
  - CREDITS.md
85
85
  - LICENSE.txt
86
- - Makefile
87
86
  - README.md
88
87
  - fugit.gemspec
89
88
  - lib/fugit.rb
@@ -117,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
116
  - !ruby/object:Gem::Version
118
117
  version: '0'
119
118
  requirements: []
120
- rubygems_version: 3.1.2
119
+ rubygems_version: 3.1.6
121
120
  signing_key:
122
121
  specification_version: 4
123
122
  summary: time tools for flor
data/Makefile DELETED
@@ -1,55 +0,0 @@
1
-
2
- ## gem tasks ##
3
-
4
- NAME = \
5
- $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name")
6
- VERSION = \
7
- $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
8
-
9
- count_lines:
10
- find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
11
- find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
12
- cl: count_lines
13
-
14
- scan:
15
- scan lib/**/*.rb
16
-
17
- gemspec_validate:
18
- @echo "---"
19
- ruby -e "s = eval(File.read(Dir['*.gemspec'].first)); p s.validate"
20
- @echo "---"
21
-
22
- name: gemspec_validate
23
- @echo "$(NAME) $(VERSION)"
24
-
25
- cw:
26
- find lib -name "*.rb" -exec ruby -cw {} \;
27
-
28
- build: gemspec_validate
29
- gem build $(NAME).gemspec
30
- mkdir -p pkg
31
- mv $(NAME)-$(VERSION).gem pkg/
32
-
33
- push: build
34
- gem push --otp "$(OTP)" pkg/$(NAME)-$(VERSION).gem
35
-
36
- spec:
37
- bundle exec rspec
38
- test: spec
39
-
40
-
41
- ## specific to project ##
42
-
43
- info:
44
- uname -a
45
- bundle exec ruby -v
46
- bundle exec ruby -Ilib -r et-orbi -e "EtOrbi._make_info"
47
-
48
- tzones:
49
- bundle exec ruby -r tzinfo -e "TZInfo::Timezone.all.each { |tz| p tz.name }"
50
- #tzonesd:
51
- # bundle exec ruby -r tzinfo -r tzinfo-data -e "::TZInfo::Timezone.all.each { |tz| p tz.name }"
52
-
53
-
54
- .PHONY: count_lines scan gemspec_validate name cw build push spec info tzones
55
-