cronspeak 0.1.5 → 0.1.6
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cronspeak.rb +48 -34
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b48ca04c5db37a5257d2ea8cc6f1ba312a87a4f6
|
4
|
+
data.tar.gz: 87b13a3016a874fb2fde426160aab10b1f1c7e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d79fb18d64a2a53c8128cc8cf904b808548d0be2c196c0a97a3b9d85214b37132008c748221c6f3483eae2924c3735d6a318808b440e9cfab78c6a1dedbf12
|
7
|
+
data.tar.gz: b8388d7c30bd5d5d1578efcebbc7c24a530ef0b80d44ae09e521bb76ed1c619f99303d9bd8e69d7e13653bf7735ff3b8360ee50708ce2aaf1f020b2ba233f6c4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cronspeak.rb
CHANGED
@@ -40,14 +40,15 @@ class CronSpeak
|
|
40
40
|
|
41
41
|
def mins(m='*')
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
return 'every minute of ' if m == '*'
|
44
|
+
|
45
|
+
r = case m
|
46
|
+
when /^\*\//
|
46
47
|
m = m[/^\*\/(\d+)/,1]
|
47
48
|
"every %s minute of " % [m.to_i.ordinal]
|
48
|
-
|
49
|
+
when /,/
|
49
50
|
"%s minutes of " % m.split(/,/).map {|x| x.to_i.ordinal }.join(' and ')
|
50
|
-
|
51
|
+
when /\-/
|
51
52
|
"the %s minutes of " % m.split('-',2)\
|
52
53
|
.map {|x| x.to_i.ordinal }.join(' through ')
|
53
54
|
else
|
@@ -59,43 +60,43 @@ class CronSpeak
|
|
59
60
|
|
60
61
|
def hrs(h='*')
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
return 'every hour' if h == '*'
|
64
|
+
|
65
|
+
@count += 2
|
66
|
+
|
67
|
+
return case h
|
68
|
+
when /^\*\//
|
65
69
|
h = h[/^\*\/(\d+)/,1]
|
66
70
|
" of every %s hour" % [h.to_i.ordinal]
|
67
|
-
|
68
|
-
|
71
|
+
when /,/
|
72
|
+
h.split(/,/)\
|
69
73
|
.map {|x| Time.parse(x+':00').strftime("%l%P").lstrip }.join(' and ')
|
70
|
-
|
74
|
+
when /,/
|
71
75
|
"%s of " % h.split(/,/).map {|x| x.to_i.ordinal }.join(' and ')
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end.join(' through ')
|
76
|
+
when /\-/
|
77
|
+
h.split('-',2).map {|x| Time.parse(x+':00').strftime("%l%P").lstrip }\
|
78
|
+
.join(' through ')
|
76
79
|
else
|
77
|
-
|
80
|
+
[Time.parse(h+':00').strftime("%l%P").lstrip]
|
78
81
|
end
|
79
82
|
|
80
|
-
@count += 2
|
81
|
-
|
82
|
-
return r
|
83
83
|
end
|
84
84
|
|
85
85
|
def days(d='*')
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
return " %s in " % @dow if @count >= 8
|
88
|
+
|
89
|
+
return case d
|
90
|
+
when /^\*$/ then
|
90
91
|
' every day'
|
91
|
-
|
92
|
+
when/^\*\//
|
92
93
|
d = d[/^\*\/(\d+)/,1]
|
93
94
|
@count += 4
|
94
95
|
" of every %s day" % [d.to_i.ordinal]
|
95
|
-
|
96
|
+
when /,/
|
96
97
|
@count += 8
|
97
98
|
"the %s of " % d.split(/,/).map {|x| x.to_i.ordinal }.join(' and ')
|
98
|
-
|
99
|
+
when /\-/
|
99
100
|
@count += 8
|
100
101
|
" the %s " % d.split('-',2).map {|x| x.to_i.ordinal }.join(' through ')
|
101
102
|
else
|
@@ -103,12 +104,12 @@ class CronSpeak
|
|
103
104
|
" the %s" % [d.to_i.ordinal]
|
104
105
|
end
|
105
106
|
|
106
|
-
return r
|
107
107
|
end
|
108
108
|
|
109
109
|
def months(mon='*')
|
110
110
|
|
111
|
-
r =
|
111
|
+
r = case mon
|
112
|
+
when /^\*$/
|
112
113
|
|
113
114
|
if @count < 4 then
|
114
115
|
''
|
@@ -117,14 +118,14 @@ class CronSpeak
|
|
117
118
|
s + 'every month'
|
118
119
|
end
|
119
120
|
|
120
|
-
|
121
|
+
when /^\*\//
|
121
122
|
mon = mon[/^\*\/(\d+)/,1]
|
122
123
|
@count += 16
|
123
124
|
" of every %s month" % [mon.to_i.ordinal]
|
124
|
-
|
125
|
+
when /,/
|
125
126
|
" of %s" % mon.split(/,/)\
|
126
127
|
.map {|x| Date::MONTHNAMES[x.to_i] }.join(' and ')
|
127
|
-
|
128
|
+
when /\-/
|
128
129
|
" of %s" % mon.split('-',2).map {|x| Date::MONTHNAMES[x.to_i] }.join(' through ')
|
129
130
|
else
|
130
131
|
s = @count < 8 ? 'of ' : ''
|
@@ -136,10 +137,23 @@ class CronSpeak
|
|
136
137
|
return r
|
137
138
|
end
|
138
139
|
|
139
|
-
def dow(raw_dow='*')
|
140
|
-
|
141
|
-
@
|
142
|
-
|
140
|
+
def dow(raw_dow='*')
|
141
|
+
|
142
|
+
@dow = case raw_dow
|
143
|
+
when /^\*$/
|
144
|
+
''
|
145
|
+
when /,/
|
146
|
+
@count += 8
|
147
|
+
raw_dow.split(/,/).map {|x| Date::DAYNAMES[x.to_i] + 's' }.join(' and ')
|
148
|
+
when /\-/
|
149
|
+
@count += 8
|
150
|
+
raw_dow.split('-',2).map {|x| Date::DAYNAMES[x.to_i] + 's' }\
|
151
|
+
.join(' through ')
|
152
|
+
else
|
153
|
+
@count += 8
|
154
|
+
Date::DAYNAMES[raw_dow.to_i] + 's'
|
155
|
+
end
|
156
|
+
|
143
157
|
end
|
144
158
|
|
145
159
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|