fugit 1.11.0 → 1.11.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 +1 -0
- data/README.md +2 -0
- data/lib/fugit/cron.rb +14 -1
- data/lib/fugit/nat.rb +13 -1
- data/lib/fugit/parse.rb +4 -4
- data/lib/fugit.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da93feee9bdfd44a793ce2b45b81109c0f7cd08ff9a930d15629a29c6a381e07
|
4
|
+
data.tar.gz: 32d9b447734805d3b58ae64c70a6699b931ef4fb4e6a76d8f279e66d4b5cb7df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7ac7afec4cfdcfdac22e5d2113892a0c7cb1f790d205bc32ecaea75c30f6ceb73af811824712c6781b480831f2a09479a6344af0d9b3c0ee92ae5cff7ef6c38
|
7
|
+
data.tar.gz: d87ecc490a49f19680891a82979903987843b5853ecfdc9ebee57d0b047fa4dffa96dfbbde43ef5d3011dbd07d492ac8f7a151fa6354478050c18efae9b911e4
|
data/CHANGELOG.md
CHANGED
data/CREDITS.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
+
* https://github.com/personnumber3377, gh-104 Fugit.parse choke on long input
|
4
5
|
* Michael Scrivo, https://github.com/mscrivo, gh-103
|
5
6
|
* Benjamin Darcet, https://github.com/bdarcet gh-95 gh-96 et-orbi #rweek
|
6
7
|
* https://github.com/franckduche gh-95 gh-96 et-orbi #rweek
|
data/README.md
CHANGED
@@ -474,6 +474,8 @@ Fugit::Nat.parse('every day at 16:15 nada 18:30', multi: true)
|
|
474
474
|
|
475
475
|
`multi: false` is the default behaviour, return a single `Fugit::Cron` instance or nil when it cannot parse.
|
476
476
|
|
477
|
+
Please note that "nat" input is limited to 256 characters (fugit 1.11.1).
|
478
|
+
|
477
479
|
### Nat Midnight
|
478
480
|
|
479
481
|
`"Every day at midnight"` is supported, but `"Every monday at midnight"` will be interpreted (as of Fugit <= 1.4.x) as `"Every monday at 00:00"`. Sorry about that.
|
data/lib/fugit/cron.rb
CHANGED
@@ -46,7 +46,20 @@ module Fugit
|
|
46
46
|
def do_parse(s)
|
47
47
|
|
48
48
|
parse(s) ||
|
49
|
-
fail(ArgumentError.new("invalid cron string #{s
|
49
|
+
fail(ArgumentError.new("invalid cron string #{trunc(s)}"))
|
50
|
+
end
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def trunc(s)
|
55
|
+
|
56
|
+
if s.is_a?(String)
|
57
|
+
r = s.length > 28 ? s[0, 28] + "... len #{s.length}" : s
|
58
|
+
r.inspect
|
59
|
+
else
|
60
|
+
r = s.inspect
|
61
|
+
r.length > 35 ? s[0, 35] + '...' : r
|
62
|
+
end
|
50
63
|
end
|
51
64
|
end
|
52
65
|
|
data/lib/fugit/nat.rb
CHANGED
@@ -7,6 +7,8 @@ module Fugit
|
|
7
7
|
#
|
8
8
|
module Nat
|
9
9
|
|
10
|
+
MAX_INPUT_LENGTH = 256
|
11
|
+
|
10
12
|
class << self
|
11
13
|
|
12
14
|
def parse(s, opts={})
|
@@ -17,6 +19,16 @@ module Fugit
|
|
17
19
|
|
18
20
|
s = s.strip
|
19
21
|
|
22
|
+
if s.length > MAX_INPUT_LENGTH
|
23
|
+
|
24
|
+
fail ArgumentError.new(
|
25
|
+
"input too long for a nat string, " +
|
26
|
+
"#{s.length} > #{MAX_INPUT_LENGTH}"
|
27
|
+
) if opts[:do_parse]
|
28
|
+
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
|
20
32
|
#p s; Raabro.pp(Parser.parse(s, debug: 3), colours: true)
|
21
33
|
#(p s; Raabro.pp(Parser.parse(s, debug: 1), colours: true)) rescue nil
|
22
34
|
|
@@ -29,7 +41,7 @@ module Fugit
|
|
29
41
|
|
30
42
|
def do_parse(s, opts={})
|
31
43
|
|
32
|
-
parse(s, opts) ||
|
44
|
+
parse(s, opts.merge(do_parse: true)) ||
|
33
45
|
fail(ArgumentError.new("could not parse a nat #{s.inspect}"))
|
34
46
|
end
|
35
47
|
end
|
data/lib/fugit/parse.rb
CHANGED
@@ -20,10 +20,10 @@ module Fugit
|
|
20
20
|
|
21
21
|
opts[:at] = opts[:in] if opts.has_key?(:in)
|
22
22
|
|
23
|
-
(opts[:cron] != false && parse_cron(s)) ||
|
24
|
-
(opts[:duration] != false && parse_duration(s)) ||
|
25
|
-
(opts[:nat] != false && parse_nat(s, opts)) ||
|
26
|
-
(opts[:at] != false && parse_at(s)) ||
|
23
|
+
(opts[:cron] != false && parse_cron(s)) || # 542ms 616ms
|
24
|
+
(opts[:duration] != false && parse_duration(s)) || # 645ms # 534ms
|
25
|
+
(opts[:nat] != false && parse_nat(s, opts)) || # 2s # 35s
|
26
|
+
(opts[:at] != false && parse_at(s)) || # 568ms 622ms
|
27
27
|
nil
|
28
28
|
end
|
29
29
|
|
data/lib/fugit.rb
CHANGED
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.11.
|
4
|
+
version: 1.11.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: 2024-
|
11
|
+
date: 2024-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|