fugit 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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: 43d809bb38ebcb6023200f72d6805c838582c2e5
4
- data.tar.gz: 487f5c3dd2da3a7a6607432c8350012278bf3fa9
3
+ metadata.gz: 06b510a4263280ff9bccbc45da080d66aaceeedc
4
+ data.tar.gz: db42c613d90cb57152159bab92a0c6175df06872
5
5
  SHA512:
6
- metadata.gz: a22e4bf53a63a6bf12fa219a0aeb862e13adc21f48fb0c4ae429873057c57a29a238b42d95aad0ea3717003ed7235c329f98248a01ccdec78d8a911f5d8b7faa
7
- data.tar.gz: 5607348dd17a19e43c39f62497c1b9c224f02ad693a7c6cce3edb19285010fc669cc131ffcfa2454f186405b6fdf17d82680dd6a7baa8bed530ca89cd313b8c5
6
+ metadata.gz: a430e9a966158192af7d58658a96841e838f9c1a5c36c640552d4a3681c3126a33589be6591863d093af444727a8a53a49cdead95e71648bbf875451f6355d85
7
+ data.tar.gz: ddfb07e67ed544e8bbe2c4d4f18c44f4f681399f1ab8726b86eed1a23b73947895437bc5d200b11f14fa57bfc7beeb127e61e91ec9855dcb2b8e7a23a6b4f084
@@ -2,6 +2,13 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.1.7 released 2019-01-15
6
+
7
+ * Add breaker to Cron #next_time / #previous_time, gh-13
8
+ * Prevent 0 as a month in crons, gh-10
9
+ * Prevent 0 as a day of month in crons, gh-10
10
+
11
+
5
12
  ## fugit 1.1.6 released 2018-09-05
6
13
 
7
14
  * Ensure `Etc/GMT-11` and all Olson timezone names are recognized
data/CREDITS.md CHANGED
@@ -1,12 +1,14 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
- * Nils Mueller https://github.com/Tolsto missing Olson timezone names, gh-9
5
- * jakemack https://github.com/jakemack issue when going out of DST, gh-6
6
- * Cristian Bica https://github.com/cristianbica Nat improvements, gh-7
4
+ * Wenhui Wang https://github.com/w11th #next_time vs Chronic+ActiveSupport #11
5
+ * Lin-Jen Shin https://github.com/godfat #next_time untamed loop, #13
6
+ * Nils Mueller https://github.com/Tolsto missing Olson timezone names, #9
7
+ * jakemack https://github.com/jakemack issue when going out of DST, #6
8
+ * Cristian Bica https://github.com/cristianbica Nat improvements, #7
7
9
  * Utilum https://github.com/utilum silenced Ruby warnings
8
10
  * Tero Marttila https://github.com/SpComb added missing Cron#seconds
9
- * Harry Lascelles https://github.com/hlascelles timezone reminder
11
+ * Harry Lascelles https://github.com/hlascelles timezone reminder and more
10
12
  * John Mettraux https://github.com/jmettraux author and maintainer
11
13
 
12
14
 
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2017-2018, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2017-2019, 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/Makefile CHANGED
@@ -35,5 +35,18 @@ spec:
35
35
  test: spec
36
36
 
37
37
 
38
- .PHONY: count_lines gemspec_validate name cw build push spec
38
+ ## specific to project ##
39
+
40
+ info:
41
+ uname -a
42
+ bundle exec ruby -v
43
+ bundle exec ruby -Ilib -r et-orbi -e "EtOrbi._make_info"
44
+
45
+ tzones:
46
+ bundle exec ruby -r tzinfo -e "TZInfo::Timezone.all.each { |tz| p tz.name }"
47
+ #tzonesd:
48
+ # bundle exec ruby -r tzinfo -r tzinfo-data -e "::TZInfo::Timezone.all.each { |tz| p tz.name }"
49
+
50
+
51
+ .PHONY: count_lines gemspec_validate name cw build push spec info tzones
39
52
 
@@ -41,9 +41,10 @@ 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.1'
44
- s.add_runtime_dependency 'et-orbi', '~> 1.1', '>= 1.1.6'
44
+ s.add_runtime_dependency 'et-orbi', '~> 1.1', '>= 1.1.7'
45
45
 
46
46
  s.add_development_dependency 'rspec', '~> 3.7'
47
+ s.add_development_dependency 'chronic', '~> 0.10'
47
48
 
48
49
  s.require_path = 'lib'
49
50
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Fugit
3
3
 
4
- VERSION = '1.1.6'
4
+ VERSION = '1.1.7'
5
5
  end
6
6
 
7
7
  require 'time'
@@ -43,7 +43,7 @@ module Fugit
43
43
  def do_parse(s)
44
44
 
45
45
  parse(s) ||
46
- fail(ArgumentError.new("not a cron string #{s.inspect}"))
46
+ fail(ArgumentError.new("invalid cron string #{s.inspect}"))
47
47
  end
48
48
  end
49
49
 
@@ -166,19 +166,39 @@ module Fugit
166
166
  hour_match?(t) && min_match?(t) && sec_match?(t)
167
167
  end
168
168
 
169
+ BREAKER_S = 41 * (365 + 1) * 24 * 3600
170
+ # 41 years and a few days... there wont'be a next or a previous time
171
+
169
172
  def next_time(from=::EtOrbi::EoTime.now)
170
173
 
171
174
  from = ::EtOrbi.make_time(from)
172
175
  sfrom = from.strftime('%F/%T')
176
+ ifrom = from.to_i
173
177
 
174
178
  t = TimeCursor.new(from.translate(@timezone))
175
179
  #
176
180
  # the translation occurs in the timezone of
177
181
  # this Fugit::Cron instance
178
182
 
183
+ ti = 0
184
+ stalling = false
185
+
179
186
  loop do
180
187
 
181
- (from.to_i == t.to_i) && (t.inc(1); next)
188
+ ti1 = t.to_i
189
+
190
+ fail RuntimeError.new(
191
+ "loop stalled for #{@original.inspect} #next_time, breaking"
192
+ ) if stalling && ti == ti1
193
+
194
+ stalling = (ti == ti1)
195
+ ti = ti1
196
+
197
+ fail RuntimeError.new(
198
+ "too many loops for #{@original.inspect} #next_time, breaking"
199
+ ) if (ti - ifrom).abs > BREAKER_S
200
+
201
+ (ifrom == ti) && (t.inc(1); next)
182
202
  month_match?(t) || (t.inc_month; next)
183
203
  day_match?(t) || (t.inc_day; next)
184
204
  hour_match?(t) || (t.inc_hour; next)
@@ -186,7 +206,7 @@ module Fugit
186
206
  sec_match?(t) || (t.inc_sec(@seconds); next)
187
207
 
188
208
  st = t.time.strftime('%F/%T')
189
- (from, sfrom = t.time, st; next) if st == sfrom
209
+ (from, sfrom, ifrom = t.time, st, t.time.to_i; next) if st == sfrom
190
210
  #
191
211
  # when transitioning out of DST, this prevents #next_time from
192
212
  # yielding the same literal time twice in a row, see gh-6
@@ -203,11 +223,28 @@ module Fugit
203
223
  def previous_time(from=::EtOrbi::EoTime.now)
204
224
 
205
225
  from = ::EtOrbi.make_time(from)
226
+ ti = 0
227
+ ifrom = from.to_i
228
+
206
229
  t = TimeCursor.new(from.translate(@timezone))
230
+ stalling = false
207
231
 
208
232
  loop do
209
- #p [ :l, Fugit.time_to_s(t.time) ]
210
- (from.to_i == t.to_i) && (t.inc(-1); next)
233
+
234
+ ti1 = t.to_i
235
+
236
+ fail RuntimeError.new(
237
+ "loop stalled for #{@original.inspect} #previous_time, breaking"
238
+ ) if stalling && ti == ti1
239
+
240
+ stalling = (ti == ti1)
241
+ ti = ti1
242
+
243
+ fail RuntimeError.new(
244
+ "too many loops for #{@original.inspect} #previous_time, breaking"
245
+ ) if (ifrom - ti).abs > BREAKER_S
246
+
247
+ (ifrom == ti) && (t.inc(-1); next)
211
248
  month_match?(t) || (t.dec_month; next)
212
249
  day_match?(t) || (t.dec_day; next)
213
250
  hour_match?(t) || (t.dec_hour; next)
@@ -237,6 +274,7 @@ module Fugit
237
274
  t = EtOrbi.make_time("#{year}-01-01") - 1
238
275
  t0 = nil
239
276
  t1 = nil
277
+
240
278
  loop do
241
279
  t1 = next_time(t)
242
280
  deltas << (t1 - t).to_i if t0
@@ -484,8 +522,8 @@ module Fugit
484
522
 
485
523
  def core_mos(i); rex(:mos, i, /[0-5]?\d/); end # min or sec
486
524
  def core_hou(i); rex(:hou, i, /(2[0-4]|[01]?[0-9])/); end
487
- def core_dom(i); rex(:dom, i, /(-?(3[01]|[012]?[0-9])|last|l)/i); end
488
- def core_mon(i); rex(:mon, i, /(1[0-2]|0?[0-9]|#{MONTHS[1..-1].join('|')})/i); end
525
+ def core_dom(i); rex(:dom, i, /(-?(3[01]|[12][0-9]|0?[1-9])|last|l)/i); end
526
+ def core_mon(i); rex(:mon, i, /(1[0-2]|0?[1-9]|#{MONTHS[1..-1].join('|')})/i); end
489
527
  def core_dow(i); rex(:dow, i, /([0-7]|#{WEEKDS.join('|')})/i); end
490
528
 
491
529
  def dow_hash(i); rex(:hash, i, /#(-?[1-5]|last|l)/i); end
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.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '1.1'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.1.6
36
+ version: 1.1.7
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '1.1'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.1.6
46
+ version: 1.1.7
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: chronic
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.10'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.10'
61
75
  description: Time tools for flor and the floraison project. Cron parsing and occurrence
62
76
  computing. Timestamps and more.
63
77
  email: