cron_format 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cron_format.rb +14 -15
- metadata +5 -5
- 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: 41aa803c299e3bb85a89d8a8d5bc39d247f4a92c
|
4
|
+
data.tar.gz: ff24f9b8ac94bdf3669ea077b31541d72341183f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41983d908c390bb49591feb34f1432cebadb42dd02e995ef3a235fd0df395143dc9a06b2af4d6bdf474dfe35a2a53f9aba15aedb707cf49ab25af2e17c8b9c0f
|
7
|
+
data.tar.gz: c74f02a02c48ec1a44f294b1f4b2bb5f854fe4e9ed6bf8f76005742c115e0ba89f7b8e615dfe291b28ee221bead1fef2eba31a52aaed138a92ea6bd6e1ded1a6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cron_format.rb
CHANGED
@@ -9,19 +9,10 @@ require 'time'
|
|
9
9
|
MINUTE = 60
|
10
10
|
HOUR = MINUTE * 60
|
11
11
|
DAY = HOUR * 24
|
12
|
+
WEEK = DAY * 7
|
12
13
|
TF = "%s-%s-%s %s:%s"
|
13
14
|
|
14
15
|
|
15
|
-
class Array
|
16
|
-
|
17
|
-
def inflate()
|
18
|
-
Array.new(self.max_by {|x| x.length}.length).map do |x|
|
19
|
-
self.map{|x| x.length <= 1 ? x.first : x.shift}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
16
|
class CronFormat
|
26
17
|
|
27
18
|
attr_reader :to_time, :to_expression
|
@@ -73,7 +64,7 @@ class CronFormat
|
|
73
64
|
end
|
74
65
|
|
75
66
|
def parse()
|
76
|
-
|
67
|
+
|
77
68
|
raw_a = @cron_string.split
|
78
69
|
raw_a << '*' if raw_a.length <= 5 # add the year?
|
79
70
|
|
@@ -87,6 +78,7 @@ class CronFormat
|
|
87
78
|
date = x.to_a.values_at(1..5)
|
88
79
|
interval.times { date[3].succ! }
|
89
80
|
Time.parse(TF % date.reverse)},
|
81
|
+
week: lambda {|x, interval| x += (interval * WEEK).to_i},
|
90
82
|
year: lambda {|x, interval|
|
91
83
|
date = x.to_a.values_at(1..5)
|
92
84
|
interval.times { date[4].succ! }
|
@@ -148,7 +140,7 @@ class CronFormat
|
|
148
140
|
end
|
149
141
|
end
|
150
142
|
|
151
|
-
dates = raw_date
|
143
|
+
dates = inflate(raw_date)
|
152
144
|
|
153
145
|
a = dates.map do |date|
|
154
146
|
|
@@ -190,11 +182,11 @@ class CronFormat
|
|
190
182
|
|
191
183
|
if t.month < @to_time.month and raw_a[4] == '*' then
|
192
184
|
# increment the year
|
193
|
-
|
194
185
|
d[4].succ!
|
195
186
|
t = Time.parse(TF % d.reverse)
|
196
187
|
|
197
188
|
if repeaters[4] then
|
189
|
+
|
198
190
|
d[4].succ!
|
199
191
|
t = Time.parse(TF % d.reverse)
|
200
192
|
end
|
@@ -231,7 +223,7 @@ class CronFormat
|
|
231
223
|
if wday then
|
232
224
|
t += DAY until t.wday == wday.to_i
|
233
225
|
end
|
234
|
-
|
226
|
+
|
235
227
|
# finally, if the date is still less than the current time we can
|
236
228
|
# increment the date using any repeating intervals
|
237
229
|
if t <= @to_time and repeaters.any? then
|
@@ -239,6 +231,7 @@ class CronFormat
|
|
239
231
|
repeaters.each_with_index do |x,i|
|
240
232
|
|
241
233
|
if x then
|
234
|
+
|
242
235
|
t = procs.values[i].call(t, x.to_i)
|
243
236
|
end
|
244
237
|
end
|
@@ -257,5 +250,11 @@ class CronFormat
|
|
257
250
|
(month.to_i < 12 ? month.succ : 1), 1]) - 1
|
258
251
|
day.to_i <= last_day.day
|
259
252
|
end
|
253
|
+
|
254
|
+
def inflate(a)
|
255
|
+
Array.new(a.max_by {|x| x.length}.length).map do |x|
|
256
|
+
a.map{|x| x.length <= 1 ? x.first : x.shift}
|
257
|
+
end
|
258
|
+
end
|
260
259
|
|
261
|
-
end
|
260
|
+
end
|
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.11
|
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:
|
34
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
35
35
|
dependencies: []
|
36
36
|
description:
|
37
37
|
email: james@r0bertson.co.uk
|
@@ -50,17 +50,17 @@ require_paths:
|
|
50
50
|
- lib
|
51
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.1.11
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: cron_format
|
metadata.gz.sig
CHANGED
Binary file
|