fugit 1.5.1 → 1.6.0

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: 8ea3f936965644ad47a2baf7b60d8a16825e8a92966bb5d4ca205f6f77205b0b
4
- data.tar.gz: 00d9608f82444554090bf4839b93b8e2a5196ed6fab378770d06de49bf478a41
3
+ metadata.gz: fe81053d0e3bb0538a7ca7bc780aaa639101ffcaffc990269e1ae3444a159758
4
+ data.tar.gz: 1e3ff923022521df2db2eca790fa6f61d688e06925a0d73aeda3b7dead09f898
5
5
  SHA512:
6
- metadata.gz: 1fe5f2034b40d4441c76e36075d9c9a6a31a54ac5c82e9c2961304f58875f75a2d63acd91a264f175b4ec16b74e98e46bd82bbd6e79619c2bd8f469804a4119b
7
- data.tar.gz: 1668baf1ece5ab7d1a8198c67b4d659ab0f900113c7511761cb68242b13f9e4af581d109e46a523260aa9b55ec9d2442da47f680cd5c1794d03efebf5a81ba84
6
+ metadata.gz: 4e6be88654cfcd12a9cf58e9aedc9ceafa1128c28589c72c878aa610624891d9f1cbd8185e17dd71e127449ab57ba08eda0f07e500a73ca4e293e2a925877e6b
7
+ data.tar.gz: 1730c644df07fd0bb2453b8a5964904eac450cbffcdf48ae0002d37a5c5dca378740c54e2581b1becca42b1a1a64ad6dc1d47da940efabe338bea10c9d9508d3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.6.0 release 2022-08-25
6
+
7
+ * Ensure input strings are stripped before parsing, gh-74
8
+
9
+
10
+ ## fugit 1.5.3 released 2022-04-02
11
+
12
+ * Fix Fugit::Cron.to_s vs "0 13 * * wed%2", gh-68
13
+
14
+
15
+ ## fugit 1.5.2 released 2021-09-18
16
+
17
+ * Simplify inc_day, gh-62
18
+
19
+
5
20
  ## fugit 1.5.1 released 2021-08-18
6
21
 
7
22
  * Fix #next_time break issue for America/Santiago into DST, gh-60
data/CREDITS.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * John Bachir, https://github.com/jjb, gh-74
5
+ * Vivek Miyani, https://github.com/vivekmiyani, gh-71
6
+ * Peter Goldstein, https://github.com/petergoldstein infra, gh-65, -72
7
+ * Pascal Zumkehr https://github.com/codez gh-62, Santiago into DST vs Time.zone
4
8
  * Ggallardoh https://github.com/Ggallardoh gh-60, America/Santiago into DST
5
9
  * Khaled AbuShqear https://github.com/shqear93 gh-57, "12pm"
6
10
  * John W Higgins https://github.com/wishdev gh-56, 15/30 cron decision
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2017-2021, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2017-2022, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -32,11 +32,12 @@ 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)
39
39
  * [serial_scheduler](https://github.com/grosser/serial_scheduler) - ruby task scheduler without threading
40
+ * [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
40
41
  * ...
41
42
 
42
43
  ## `Fugit.parse(s)`
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', '>= 1.1.8'
44
+ s.add_runtime_dependency 'et-orbi', '~> 1', '>= 1.2.7'
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
@@ -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
 
@@ -60,7 +60,7 @@ module Fugit
60
60
  (@hours || [ '*' ]).join(','),
61
61
  (@monthdays || [ '*' ]).join(','),
62
62
  (@months || [ '*' ]).join(','),
63
- (@weekdays || [ [ '*' ] ]).map { |d| d.compact.join('#') }.join(','),
63
+ weekdays_to_cron_s,
64
64
  @timezone ? @timezone.name : nil
65
65
  ].compact.join(' ')
66
66
  end
@@ -74,6 +74,8 @@ module Fugit
74
74
  end
75
75
 
76
76
  def time; @t; end
77
+ def to_t; @t; end
78
+ #
77
79
  def to_i; @t.to_i; end
78
80
 
79
81
  %w[ year month day wday hour min sec wday_in_month rweek rday ]
@@ -97,14 +99,14 @@ module Fugit
97
99
 
98
100
  inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec)
99
101
 
100
- #inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
101
- #inc( - @t.hour * 3600) if @t.hour > 0 && @t.hour < 7
102
- # leads to gh-60...
102
+ return if @t.hour == 0
103
103
 
104
- if @t.hour == 0
105
- # it's good, carry on...
106
- elsif @t.hour < 12
107
- @t = ::EtOrbi.make(@t.year, @t.month, @t.day, @t.zone)
104
+ if @t.hour < 12
105
+ begin
106
+ @t = ::EtOrbi.make(@t.year, @t.month, @t.day, @t.zone)
107
+ rescue ::TZInfo::PeriodNotFound
108
+ inc((24 - @t.hour) * 3600)
109
+ end
108
110
  else
109
111
  inc((24 - @t.hour) * 3600)
110
112
  end
@@ -620,6 +622,24 @@ module Fugit
620
622
  @zone, @timezone = z
621
623
  end
622
624
 
625
+ def weekdays_to_cron_s
626
+
627
+ return '*' unless @weekdays
628
+
629
+ @weekdays
630
+ .collect { |a|
631
+ if a.length == 1
632
+ a[0].to_s
633
+ elsif a[1].is_a?(Array)
634
+ a11 = a[1][1]
635
+ off = (a11 < 0) ? a11.to_s : (a11 > 0) ? "+#{a11}" : ''
636
+ "#{a[0]}%#{a[1][0]}" + off
637
+ else
638
+ a.collect(&:to_s).join('#')
639
+ end }
640
+ .join(',')
641
+ end
642
+
623
643
  module Parser include Raabro
624
644
 
625
645
  WEEKDAYS =
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
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+
3
4
  module Fugit
4
5
 
5
- VERSION = '1.5.1'
6
+ VERSION = '1.6.0'
6
7
  end
7
8
 
8
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.1
4
+ version: 1.6.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: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2022-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '1'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.1.8
36
+ version: 1.2.7
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '1.1'
43
+ version: '1'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.1.8
46
+ version: 1.2.7
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -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.2
120
+ rubygems_version: 3.1.6
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: time tools for flor