parse-cron-ext 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -3
- data/Gemfile.lock +1 -1
- data/README.md +18 -3
- data/lib/cron_parse.rb +4 -2
- data/lib/parse-cron-ext/version.rb +1 -1
- data/parse-cron-ext.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db764d04c5274b466fb075cb04185d709091c69434078c8b052166eaafbc854c
|
4
|
+
data.tar.gz: 6fdb5eee236c9a750bdbb4137dec00bd8a07978925f93e2d6be39674c5d67dda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0246ef91c0379146ad95c5055cd509cbe61e0ccc0f75b05ecec991b05cde9ccad8e8196f2240a561a406300b4f2e3e4b7e4d33b418e8be42cfd67b0eae6bb923
|
7
|
+
data.tar.gz: 07a5dcc145a0f37be7590d7da5ac80bdd0938dbe0a4119fb217108c53e9fee04744ed0a914d8dcdf42a4737f081783037c510cb8b48478d0b7e70cf0b12ef5f8
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# parse-cron-ext
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/parse-cron-ext.svg)](https://badge.fury.io/rb/parse-cron-ext)
|
3
|
+
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
|
2
4
|
|
3
5
|
parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which is the latest version.
|
4
6
|
siebertm/parse-cron: https://github.com/siebertm/parse-cron
|
@@ -23,8 +25,9 @@ Or install it yourself as:
|
|
23
25
|
|
24
26
|
## Usage
|
25
27
|
These notations are inspired by [AWS Cron Expressions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html).
|
26
|
-
|
27
|
-
|
28
|
+
|
29
|
+
|
30
|
+
You can express...
|
28
31
|
### End of the month by using L notation
|
29
32
|
```ruby
|
30
33
|
cron_parser = CronParser.new('0 9 L * *')
|
@@ -61,8 +64,20 @@ Or install it yourself as:
|
|
61
64
|
|
62
65
|
time = Time.local(2022, 1, 3, 12, 0)
|
63
66
|
cron_parser.next(time)
|
64
|
-
# => 2022-03-
|
67
|
+
# => 2022-03-13 09:00
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
### Weekday by using W notation
|
72
|
+
```ruby
|
73
|
+
# next weekday
|
74
|
+
cron_parser = CronParser.new('0 0 * * W')
|
75
|
+
|
76
|
+
time = Time.local(2022, 2, 11, 12, 0)
|
77
|
+
cron_parser.next(time)
|
78
|
+
# => 2022-02-14 00:00
|
65
79
|
```
|
80
|
+
https://www.timeanddate.com/calendar/
|
66
81
|
|
67
82
|
## Development
|
68
83
|
|
data/lib/cron_parse.rb
CHANGED
@@ -3,7 +3,7 @@ require 'date'
|
|
3
3
|
require 'parse-cron'
|
4
4
|
|
5
5
|
class CronParser
|
6
|
-
SUBELEMENT_REGEX = %r{^(\d+|l)((-(\d+)(/(\d+))?)?|#(\d+))$}
|
6
|
+
SUBELEMENT_REGEX = %r{^(\d+|l|w)((-(\d+)(/(\d+))?)?|#(\d+))$}
|
7
7
|
|
8
8
|
def parse_element(elem, allowed_range, time_specs_key=nil)
|
9
9
|
values = elem.split(',').map do |subel|
|
@@ -18,6 +18,8 @@ class CronParser
|
|
18
18
|
stepped_range($1.to_i..$4.to_i, 1)
|
19
19
|
elsif $1 == "l" && time_specs_key == :dom
|
20
20
|
[$1]
|
21
|
+
elsif $1 == "w" && time_specs_key == :dow
|
22
|
+
[1, 2, 3, 4, 5]
|
21
23
|
else # just a numeric
|
22
24
|
@dow_offset = $7.to_i if $7
|
23
25
|
[$1.to_i]
|
@@ -91,7 +93,7 @@ class CronParser
|
|
91
93
|
:hour => parse_element(tokens[1], 0..23), #hour
|
92
94
|
:dom => parse_element(tokens[2], 1..31, :dom), #DOM
|
93
95
|
:month => parse_element(tokens[3], 1..12), #mon
|
94
|
-
:dow => parse_element(tokens[4], 0..6)
|
96
|
+
:dow => parse_element(tokens[4], 0..6, :dow) #DOW
|
95
97
|
}
|
96
98
|
end
|
97
99
|
end
|
data/parse-cron-ext.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ["sh07e1916@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = %q{parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which is the latest version.}
|
10
|
-
spec.description = %q{enable to specify "end of the month in March"
|
11
|
-
spec.homepage = "https://
|
10
|
+
spec.description = %q{enable to specify "end of the month", "end of the month in March", "Third Monday", and so on... in cron by extending of parse-cron.}
|
11
|
+
spec.homepage = "https://github.com/a5-stable/parse-cron-ext"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parse-cron-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a5-stable
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parse-cron
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.1.4
|
27
|
-
description: enable to specify "end of the month in March"
|
28
|
-
by extending of parse-cron.
|
27
|
+
description: enable to specify "end of the month", "end of the month in March", "Third
|
28
|
+
Monday", and so on... in cron by extending of parse-cron.
|
29
29
|
email:
|
30
30
|
- sh07e1916@gmail.com
|
31
31
|
executables: []
|
@@ -46,7 +46,7 @@ files:
|
|
46
46
|
- lib/cron_parse.rb
|
47
47
|
- lib/parse-cron-ext/version.rb
|
48
48
|
- parse-cron-ext.gemspec
|
49
|
-
homepage: https://
|
49
|
+
homepage: https://github.com/a5-stable/parse-cron-ext
|
50
50
|
licenses:
|
51
51
|
- MIT
|
52
52
|
metadata:
|