cron2english 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/cron2english/all.rb +6 -1
- data/lib/cron2english/version.rb +1 -1
- data/spec/parse_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b236d44027a4d50bf559893ebf8ae87cb0c4f248
|
4
|
+
data.tar.gz: 5d2f02db75a40f95f3f95fe8b35d017e8e8d39c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b900e08c5073587555f0aab42af39f053ec70e764ff582fc4149d895a11c3e50bf235348a52376e3a2f2899ac8be9a57dd4b31c5157045dda7a248e682d76c06
|
7
|
+
data.tar.gz: a6e29b4551d6d3f21e9c7019ec2b9149724c020e89e5b06f899a4d60cce82d51374b8275a344c230cb2ff93fca00c7ee54c2a1439ecac972f4201df778ebcfe2
|
data/lib/cron2english/all.rb
CHANGED
@@ -9,6 +9,7 @@ module Cron2English
|
|
9
9
|
NUM2MONTH = Hash[(1..12).zip(MONTHS)]
|
10
10
|
# unshift @months, ''; # What is this about??
|
11
11
|
DOW_REGEX = %r{^(#{DAYS_OF_WEEK.join("|")})$}i
|
12
|
+
DOW_RANGE_REGEX = %r{^(#{DAYS_OF_WEEK.join("|")})-(#{DAYS_OF_WEEK.join("|")})$}i
|
12
13
|
MONTH_REGEX = %r{^(#{MONTHS.join("|")}|)$}i
|
13
14
|
NUM2MONTH_LONG = Hash[(1..12).zip(%w{January February March April May June July August September October November December})]
|
14
15
|
NUM2DOW_LONG = %w{Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday}
|
@@ -65,7 +66,11 @@ module Cron2English
|
|
65
66
|
def process_trad(m, h, day_of_month, month, dow)
|
66
67
|
month = MONTH2NUM[$1.downcase] if month =~ MONTH_REGEX
|
67
68
|
month = month.to_s if month
|
68
|
-
|
69
|
+
if dow =~ DOW_REGEX
|
70
|
+
dow = DOW2NUM[$1.downcase]
|
71
|
+
elsif dow =~ DOW_RANGE_REGEX
|
72
|
+
dow = [$1, $2].map{|d| DOW2NUM[d.downcase]}.join('-')
|
73
|
+
end
|
69
74
|
dow = dow.to_s if dow
|
70
75
|
bits = [m, h, day_of_month, month, dow]
|
71
76
|
unparseable = []
|
data/lib/cron2english/version.rb
CHANGED
data/spec/parse_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe Cron2English do
|
|
9
9
|
["40 5 * * *", ["5:40am", "every day"]],
|
10
10
|
["50 6 * * 1", ["6:50am", "every Monday"]],
|
11
11
|
["1 2 * apr mOn", ["2:01am", "every Monday in", "April"]],
|
12
|
+
["1 2 * apr mon-fri", ["2:01am", "every Monday through Friday in", "April"]],
|
12
13
|
["1 2 3 4 7", ["2:01am on", "the third of -- or every Sunday in --", "April"]],
|
13
14
|
["1-20/3 * * * *", ["every 3 minutes from 1 to 20 past", "every hour of", "every day"]],
|
14
15
|
["1,2,3 * * * *", ["1, 2, and 3 minutes past", "every hour of", "every day"]],
|