fugit 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: beb66d9d6eedbe579f1c5ee04d70cd10af36b2be
4
- data.tar.gz: cc83ab367d09e4af91cc1fc82d43077eab81285b
3
+ metadata.gz: 29d3106a9c17929e0c4a556c304acea5ab9e29f1
4
+ data.tar.gz: 8890359912e32ca52e1022a5b6aa25b9fcce04d9
5
5
  SHA512:
6
- metadata.gz: 5abf2492c6a49f7ce5ae70cd49b769f597d363aefee055d806676b5b0d45078cd6e03291f06bbf1e04eed2f4052692413b0450bce7d5fc85a851592ee7bdd7d8
7
- data.tar.gz: fac490d0d5deea7d429001b7ee9e9420b5855679d2bc2bb8b1db2d5a919cf045065b7751d41673e5db1276526ec4206a651a8bb22df16be16e40be6ff2edf52e
6
+ metadata.gz: fd3550d81071658ef4cba1ef2699e9949fbb7455ee1cb0bcd2a80412339993bcfad20cbd93358e1b5328df506c401ca114624d6c48288feff643acf65cc44592
7
+ data.tar.gz: 3f8864b05feb8f7383ac4a149f34c0de604137b05b284c6ce1871f57f3e165d290943cf42229de8ef1944cc9808583533a441abb5c4fc94630a7c535a9c3d8ad
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.2.1 released 2019-05-04
6
+
7
+ * Return nil when parsing a cron with February 30 and friend, gh-21
8
+
9
+
5
10
  ## fugit 1.2.0 released 2019-04-22
6
11
 
7
12
  * Accept "/15 * * * *" et al, gh-19 and resque/resque-scheduler#649
data/CREDITS.md CHANGED
@@ -1,12 +1,13 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
- * Cristian Oneț https://githbu.com/conet #previous_time vs 1/-1 endless loop #15
5
- * Wenhui Wang https://github.com/w11th #next_time vs Chronic+ActiveSupport #11
6
- * Lin-Jen Shin https://github.com/godfat #next_time untamed loop, #13
7
- * Nils Mueller https://github.com/Tolsto missing Olson timezone names, #9
8
- * jakemack https://github.com/jakemack issue when going out of DST, #6
9
- * Cristian Bica https://github.com/cristianbica Nat improvements, #7
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
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Fugit
3
3
 
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
6
6
 
7
7
  require 'time'
@@ -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 :original, :zone
17
- attr_reader :seconds, :minutes, :hours, :monthdays, :months, :weekdays, :timezone
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
 
@@ -32,20 +32,21 @@ module Fugit
32
32
 
33
33
  def parse_cron(a)
34
34
 
35
- h = { min: nil, hou: [], dom: [ nil ], mon: [ nil ], dow: [ nil ] }
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] = [ [ 1, 5 ] ]
40
+ (h[:dow] ||= []) << '1-5'
40
41
  elsif key == :simple_hour || key == :numeral_hour
41
- (h[:hou] ||= []) << [ val ]
42
+ h[:hou] << val
42
43
  elsif key == :digital_hour
43
- h[:hou] = [ val[0, 1] ]
44
- h[:min] = [ val[1, 1] ]
44
+ h[:hou] = [ val[0] ]
45
+ h[:min] = [ val[1] ]
45
46
  elsif key == :name_day
46
- (h[:dow] ||= []) << [ val ]
47
+ (h[:dow] ||= []) << val
47
48
  elsif key == :flag && val == 'pm' && h[:hou]
48
- h[:hou][-1] = [ h[:hou][-1].first + 12 ]
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[:dow].sort_by! { |d, _| d || 0 }
57
-
58
- Fugit::Cron.allocate.send(:init, nil, h)
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.0
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-04-21 00:00:00.000000000 Z
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.6.14.3
121
+ rubygems_version: 2.5.2.3
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: time tools for flor