fugit 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d28dc94bc31e025df55b67c79f2f59eed365940872e287479e788cb9023178dd
4
- data.tar.gz: 6f8d62b8d8921831a4de92d60a23c4cf83cfe79eea852c625744951156cb3d05
3
+ metadata.gz: fe369cec5c3fb690ead6f7638fcd430db71fd6525070c45aa48a8c7b3c3d4171
4
+ data.tar.gz: ce486e692afb9bf796122005314c89185373b07d596684b8c7a3f395bf36d1b4
5
5
  SHA512:
6
- metadata.gz: 3afc5fd6553abed3c73d7526e25b871ba0f5f26b8f415fccfec183b261e5ccb4e9f3fc6b176b550fa47de385f8991efe08936d2d96d6951a15dba81533f2ebcc
7
- data.tar.gz: e5cbdb64a9f6ee28e8f938c76dcdf44211ce751ca0dc1834d669b8494e40424fb7c5e8e98f7eb608e8855c29648b9c99e9faf06436ab05a795a87bffc771118c
6
+ metadata.gz: 94b9b504e574dbff1f6b0abab21028c97c0303533a8b45747ae6250c6d866c83c7b1999c5cce4680f5015f62946e9ba2f0a2e28af0faf5dc6194c3649b615b97
7
+ data.tar.gz: a70bdcd045774d4290cc7d014c62793e28f4a322bf8a3f93d7ee5ce2b2d37744481d32896ce5c88ff89cd3fddfe7ec37bf41c5d3b480dafea45a0d246e1636bd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.8.0 released 2022-12-06
6
+
7
+ * Introduce Fugit.parse_cronish and .do_parse_cronish, gh-70
8
+
9
+
5
10
  ## fugit 1.7.2 released 2022-11-03
6
11
 
7
12
  * Fix 'every day at 12:15 am', gh-81
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
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Fugit
5
5
 
6
- VERSION = '1.7.2'
6
+ VERSION = '1.8.0'
7
7
  end
8
8
 
9
9
  require 'time'
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.7.2
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-03 00:00:00.000000000 Z
11
+ date: 2022-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro