fugit 1.7.2 → 1.8.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -0
- data/lib/fugit/parse.rb +13 -0
- 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: fe369cec5c3fb690ead6f7638fcd430db71fd6525070c45aa48a8c7b3c3d4171
|
4
|
+
data.tar.gz: ce486e692afb9bf796122005314c89185373b07d596684b8c7a3f395bf36d1b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94b9b504e574dbff1f6b0abab21028c97c0303533a8b45747ae6250c6d866c83c7b1999c5cce4680f5015f62946e9ba2f0a2e28af0faf5dc6194c3649b615b97
|
7
|
+
data.tar.gz: a70bdcd045774d4290cc7d014c62793e28f4a322bf8a3f93d7ee5ce2b2d37744481d32896ce5c88ff89cd3fddfe7ec37bf41c5d3b480dafea45a0d246e1636bd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -89,6 +89,25 @@ Fugit.parse_nat('every day at noon').class # ==> ::Fugit::Cron
|
|
89
89
|
|
90
90
|
As `Fugit.parse(s)` returns nil when it doesn't grok its input, and `Fugit.do_parse(s)` fails when it doesn't grok, each of the `parse_` methods has its partner `do_parse_` method.
|
91
91
|
|
92
|
+
## parse_cronish and do_parse_cronish
|
93
|
+
|
94
|
+
Sometimes you know a cron expression or an "every" natural expression will come in and you want to discard the rest.
|
95
|
+
|
96
|
+
```
|
97
|
+
require 'fugit'
|
98
|
+
|
99
|
+
Fugit.parse_cronish('0 0 1 jan *').class # ==> ::Fugit::Cron
|
100
|
+
Fugit.parse_cronish('every saturday at noon').class # ==> ::Fugit::Cron
|
101
|
+
|
102
|
+
Fugit.parse_cronish('12y12M') # ==> nil
|
103
|
+
```
|
104
|
+
|
105
|
+
`.parse_cronish(s)` will return a `Fugit::Cron` instance or else nil.
|
106
|
+
|
107
|
+
`.do_parse_cronish(s)` will return a `Fugit::Cron` instance or else fail with an `ArgumentError`.
|
108
|
+
|
109
|
+
Introduced in fugit 1.8.0.
|
110
|
+
|
92
111
|
## `Fugit::Cron`
|
93
112
|
|
94
113
|
A class `Fugit::Cron` to parse cron strings and then `#next_time` and `#previous_time` to compute the next or the previous occurrence respectively.
|
data/lib/fugit/parse.rb
CHANGED
@@ -33,6 +33,19 @@ module Fugit
|
|
33
33
|
fail(ArgumentError.new("found no time information in #{s.inspect}"))
|
34
34
|
end
|
35
35
|
|
36
|
+
def parse_cronish(s, opts={})
|
37
|
+
|
38
|
+
r = parse_cron(s) || parse_nat(s, opts)
|
39
|
+
|
40
|
+
r.is_a?(::Fugit::Cron) ? r : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def do_parse_cronish(s, opts={})
|
44
|
+
|
45
|
+
parse_cronish(s) ||
|
46
|
+
fail(ArgumentError.new("not cron or 'natural' cron string: #{s.inspect}"))
|
47
|
+
end
|
48
|
+
|
36
49
|
def determine_type(s)
|
37
50
|
|
38
51
|
case self.parse(s)
|
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.
|
4
|
+
version: 1.8.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: 2022-
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|