fugit 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/CREDITS.md +7 -6
- data/lib/fugit.rb +1 -1
- data/lib/fugit/cron.rb +26 -2
- data/lib/fugit/nat.rb +20 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d3106a9c17929e0c4a556c304acea5ab9e29f1
|
4
|
+
data.tar.gz: 8890359912e32ca52e1022a5b6aa25b9fcce04d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd3550d81071658ef4cba1ef2699e9949fbb7455ee1cb0bcd2a80412339993bcfad20cbd93358e1b5328df506c401ca114624d6c48288feff643acf65cc44592
|
7
|
+
data.tar.gz: 3f8864b05feb8f7383ac4a149f34c0de604137b05b284c6ce1871f57f3e165d290943cf42229de8ef1944cc9808583533a441abb5c4fc94630a7c535a9c3d8ad
|
data/CHANGELOG.md
CHANGED
data/CREDITS.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
4
|
+
* Fabio Pitino https://github.com/hspazio nil on February 30 gh-21
|
5
|
+
* Cristian Oneț https://github.com/conet #previous_time vs 1/-1 endless loop gh-15
|
6
|
+
* Wenhui Wang https://github.com/w11th #next_time vs Chronic+ActiveSupport gh-11
|
7
|
+
* Lin-Jen Shin https://github.com/godfat #next_time untamed loop gh-13
|
8
|
+
* Nils Mueller https://github.com/Tolsto missing Olson timezone names gh-9
|
9
|
+
* jakemack https://github.com/jakemack issue when going out of DST gh-6
|
10
|
+
* Cristian Bica https://github.com/cristianbica Nat improvements gh-7
|
10
11
|
* Utilum https://github.com/utilum silenced Ruby warnings
|
11
12
|
* Tero Marttila https://github.com/SpComb added missing Cron#seconds
|
12
13
|
* Harry Lascelles https://github.com/hlascelles timezone reminder and more
|
data/lib/fugit.rb
CHANGED
data/lib/fugit/cron.rb
CHANGED
@@ -12,9 +12,13 @@ module Fugit
|
|
12
12
|
'@daily' => '0 0 * * *',
|
13
13
|
'@midnight' => '0 0 * * *',
|
14
14
|
'@hourly' => '0 * * * *' }
|
15
|
+
MAXDAYS = [
|
16
|
+
nil, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
15
17
|
|
16
|
-
attr_reader
|
17
|
-
|
18
|
+
attr_reader(
|
19
|
+
:original, :zone)
|
20
|
+
attr_reader(
|
21
|
+
:seconds, :minutes, :hours, :monthdays, :months, :weekdays, :timezone)
|
18
22
|
|
19
23
|
class << self
|
20
24
|
|
@@ -224,6 +228,7 @@ module Fugit
|
|
224
228
|
|
225
229
|
fail RuntimeError.new(
|
226
230
|
"too many loops for #{@original.inspect} #next_time, breaking, " +
|
231
|
+
"cron expression most likely invalid (Feb 30th like?), " +
|
227
232
|
"please fill an issue at https://git.io/fjJC9"
|
228
233
|
) if (i += 1) > MAX_ITERATION_COUNT
|
229
234
|
|
@@ -260,6 +265,7 @@ module Fugit
|
|
260
265
|
|
261
266
|
fail RuntimeError.new(
|
262
267
|
"too many loops for #{@original.inspect} #previous_time, breaking, " +
|
268
|
+
"cron expression most likely invalid (Feb 30th like?), " +
|
263
269
|
"please fill an issue at https://git.io/fjJCQ"
|
264
270
|
) if (i += 1) > MAX_ITERATION_COUNT
|
265
271
|
|
@@ -396,6 +402,22 @@ module Fugit
|
|
396
402
|
|
397
403
|
protected
|
398
404
|
|
405
|
+
def compact_month_days
|
406
|
+
|
407
|
+
return true if @months == nil || @monthdays == nil
|
408
|
+
|
409
|
+
ms, ds =
|
410
|
+
@months.inject([ [], [] ]) { |a, m|
|
411
|
+
@monthdays.each { |d|
|
412
|
+
next if d > MAXDAYS[m]
|
413
|
+
a[0] << m; a[1] << d }
|
414
|
+
a }
|
415
|
+
@months = ms.uniq
|
416
|
+
@monthdays = ds.uniq
|
417
|
+
|
418
|
+
@months.any? && @monthdays.any?
|
419
|
+
end
|
420
|
+
|
399
421
|
def rough_days
|
400
422
|
|
401
423
|
return nil if @weekdays == nil && @monthdays == nil
|
@@ -436,6 +458,8 @@ module Fugit
|
|
436
458
|
determine_weekdays(h[:dow])
|
437
459
|
determine_timezone(h[:tz])
|
438
460
|
|
461
|
+
return nil unless compact_month_days
|
462
|
+
|
439
463
|
self
|
440
464
|
end
|
441
465
|
|
data/lib/fugit/nat.rb
CHANGED
@@ -32,20 +32,21 @@ module Fugit
|
|
32
32
|
|
33
33
|
def parse_cron(a)
|
34
34
|
|
35
|
-
h = { min: nil, hou: [], dom:
|
35
|
+
h = { min: nil, hou: [], dom: nil, mon: nil, dow: nil }
|
36
|
+
hkeys = h.keys
|
36
37
|
|
37
38
|
a.each do |key, val|
|
38
39
|
if key == :biz_day
|
39
|
-
h[:dow]
|
40
|
+
(h[:dow] ||= []) << '1-5'
|
40
41
|
elsif key == :simple_hour || key == :numeral_hour
|
41
|
-
|
42
|
+
h[:hou] << val
|
42
43
|
elsif key == :digital_hour
|
43
|
-
h[:hou] = [ val[0
|
44
|
-
h[:min] = [ val[1
|
44
|
+
h[:hou] = [ val[0] ]
|
45
|
+
h[:min] = [ val[1] ]
|
45
46
|
elsif key == :name_day
|
46
|
-
(h[:dow] ||= []) <<
|
47
|
+
(h[:dow] ||= []) << val
|
47
48
|
elsif key == :flag && val == 'pm' && h[:hou]
|
48
|
-
h[:hou][-1] =
|
49
|
+
h[:hou][-1] = h[:hou][-1] + 12
|
49
50
|
elsif key == :tz
|
50
51
|
h[:tz] = val
|
51
52
|
elsif key == :duration
|
@@ -53,9 +54,18 @@ module Fugit
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
h[:min] ||= [ 0 ]
|
56
|
-
h[:
|
57
|
-
|
58
|
-
|
57
|
+
h[:hou].sort! if h[:hou]
|
58
|
+
h[:dow].sort! if h[:dow]
|
59
|
+
|
60
|
+
a = hkeys
|
61
|
+
.collect { |k|
|
62
|
+
v = h[k]
|
63
|
+
(v && v.any?) ? v.collect(&:to_s).join(',') : '*' }
|
64
|
+
a.insert(0, h[:sec]) if h[:sec]
|
65
|
+
a << h[:tz].first if h[:tz]
|
66
|
+
s = a.join(' ')
|
67
|
+
|
68
|
+
Fugit::Cron.parse(s)
|
59
69
|
end
|
60
70
|
|
61
71
|
def process_duration(h, interval, value)
|
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.2.
|
4
|
+
version: 1.2.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: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.5.2.3
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: time tools for flor
|