cron_format 0.1.2 → 0.1.3
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/cron_format.rb +21 -17
- metadata +2 -2
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d7f091de5a9dd5f4c75422b84c041db74258c9
|
4
|
+
data.tar.gz: 071ecfa7aad169c864ce1a67ffd5424c0227b302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0062418d22527232e7d93a9a3294963d8c42924f0bb81139754a12f82e07bbb590e0402735145478eb4377a29c2ee95cc36855f31c91ffdc5c7e77ef0eaa2f6b
|
7
|
+
data.tar.gz: 7c3306a11ba674ac0b5017f79874b8dd08f51b0cb3dba4523aa8aa29fab62fea6de4961c3de74980c1fa5ae1e0dfa2dab829e022b2b29bbbbe30078ae2e37247
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cron_format.rb
CHANGED
@@ -9,6 +9,8 @@ require 'time'
|
|
9
9
|
MINUTE = 60
|
10
10
|
HOUR = MINUTE * 60
|
11
11
|
DAY = HOUR * 24
|
12
|
+
TF = "%s-%s-%s %s:%s"
|
13
|
+
|
12
14
|
|
13
15
|
class Array
|
14
16
|
|
@@ -51,7 +53,7 @@ class CronFormat
|
|
51
53
|
month_proc = lambda {|t1,n|
|
52
54
|
a = t1.to_a
|
53
55
|
a[4] = a[4] + n <= 12 ? a[4] + n : a[4] + n - 12
|
54
|
-
t = Time.parse(
|
56
|
+
t = Time.parse(TF % a.values_at(5,4,3,2,1,0))
|
55
57
|
t -= DAY until t.month == a[4]
|
56
58
|
return t
|
57
59
|
}
|
@@ -78,17 +80,17 @@ class CronFormat
|
|
78
80
|
units = @to_time.to_a.values_at(1..4) + [nil, @to_time.year]
|
79
81
|
|
80
82
|
procs = {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
month: lambda{|x, interval|
|
83
|
+
min: lambda {|x, interval| x += (interval * MINUTE).to_i},
|
84
|
+
hour: lambda {|x, interval| x += (interval * HOUR).to_i},
|
85
|
+
day: lambda {|x, interval| x += (interval * DAY).to_i},
|
86
|
+
month: lambda {|x, interval|
|
85
87
|
date = x.to_a.values_at(1..5)
|
86
88
|
interval.times { date[3].succ! }
|
87
|
-
Time.parse(
|
88
|
-
|
89
|
+
Time.parse(TF % date.reverse)},
|
90
|
+
year: lambda {|x, interval|
|
89
91
|
date = x.to_a.values_at(1..5)
|
90
92
|
interval.times { date[4].succ! }
|
91
|
-
Time.parse(
|
93
|
+
Time.parse(TF % date.reverse)}
|
92
94
|
}
|
93
95
|
|
94
96
|
dt = units.map do |start|
|
@@ -113,12 +115,13 @@ class CronFormat
|
|
113
115
|
raw_units << v1
|
114
116
|
repeaters << v2
|
115
117
|
end
|
116
|
-
|
117
|
-
|
118
|
+
|
119
|
+
r = /(sun|mon|tues|wed|thurs|fri|satur|sun)(day)?|tue|thu|sat/i
|
120
|
+
raw_units[4].gsub!(r) do |x|
|
118
121
|
a = %w(sunday monday tuesday wednesday thursday friday saturday)
|
119
122
|
a.index a.grep(/#{x}/i).first
|
120
123
|
end
|
121
|
-
|
124
|
+
|
122
125
|
raw_date = raw_units.map.with_index {|x,i| dt[i].call(x) }
|
123
126
|
|
124
127
|
# expand the repeater
|
@@ -137,6 +140,7 @@ class CronFormat
|
|
137
140
|
end
|
138
141
|
end
|
139
142
|
|
143
|
+
|
140
144
|
dates = raw_date.inflate
|
141
145
|
|
142
146
|
a = dates.map do |date|
|
@@ -147,11 +151,11 @@ class CronFormat
|
|
147
151
|
d << year
|
148
152
|
|
149
153
|
next unless day_valid? d.reverse.take 3
|
150
|
-
t = Time.parse(
|
154
|
+
t = Time.parse(TF % d.reverse)
|
151
155
|
|
152
156
|
if t < @to_time and wday and wday != t.wday then
|
153
157
|
d[2], d[3] = @to_time.to_a.values_at(3,4).map(&:to_s)
|
154
|
-
t = Time.parse(
|
158
|
+
t = Time.parse(TF % d.reverse)
|
155
159
|
t += DAY until t.wday == wday.to_i
|
156
160
|
end
|
157
161
|
|
@@ -159,7 +163,7 @@ class CronFormat
|
|
159
163
|
while t < @to_time and i >= 0 and raw_a[i][/\*/]
|
160
164
|
|
161
165
|
d[i] = @to_time.to_a[i+1].to_s
|
162
|
-
t = Time.parse(
|
166
|
+
t = Time.parse(TF % d.reverse)
|
163
167
|
i -= 1
|
164
168
|
end
|
165
169
|
|
@@ -169,11 +173,11 @@ class CronFormat
|
|
169
173
|
# increment the year
|
170
174
|
|
171
175
|
d[4].succ!
|
172
|
-
t = Time.parse(
|
176
|
+
t = Time.parse(TF % d.reverse)
|
173
177
|
|
174
178
|
if repeaters[4] then
|
175
179
|
d[4].succ!
|
176
|
-
t = Time.parse(
|
180
|
+
t = Time.parse(TF % d.reverse)
|
177
181
|
end
|
178
182
|
elsif t.day < @to_time.day and raw_a[3] == '*' then
|
179
183
|
|
@@ -184,7 +188,7 @@ class CronFormat
|
|
184
188
|
d[3] = '1'
|
185
189
|
d[4].succ!
|
186
190
|
end
|
187
|
-
t = Time.parse(
|
191
|
+
t = Time.parse(TF % d.reverse)
|
188
192
|
elsif (t.hour < @to_time.hour or (t.hour == @to_time.hour \
|
189
193
|
and t.min < @to_time.min and raw_a[1] != '*') ) \
|
190
194
|
and raw_a[2] == '*' then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cron_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
9DFxFCS6sgAw21S+V+ym9ft8kbqgy7zOGdPRRNlwgb/V+UWqH4yaCtk7yJT+n8vm
|
32
32
|
LHkRlhnm0ScZYw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2013-07-
|
34
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
35
35
|
dependencies: []
|
36
36
|
description:
|
37
37
|
email:
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
��G�shw���k��@.�H�9b��I:��x����{q\�����)߇�y~��tA(���4�
|
1
|
+
��@�#v�N%�ng�3�In���\<4���MTF�L�Ԟ�o��5i��['�
|