rufus-scheduler 3.0.8 → 3.1.0
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.
- data/CHANGELOG.txt +13 -0
- data/CREDITS.txt +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +73 -13
- data/lib/rufus/scheduler/cronline.rb +78 -74
- data/lib/rufus/scheduler/job_array.rb +2 -1
- data/lib/rufus/scheduler/jobs.rb +30 -28
- data/lib/rufus/scheduler/locks.rb +95 -0
- data/lib/rufus/scheduler/util.rb +2 -25
- data/lib/rufus/scheduler/zones.rb +174 -0
- data/lib/rufus/scheduler/zotime.rb +154 -0
- data/lib/rufus/scheduler.rb +61 -61
- data/rufus-scheduler.gemspec +2 -27
- data/spec/basics_spec.rb +16 -11
- data/spec/cronline_spec.rb +152 -103
- data/spec/job_cron_spec.rb +22 -0
- data/spec/job_every_spec.rb +14 -0
- data/spec/job_repeat_spec.rb +1 -0
- data/spec/lock_flock_spec.rb +47 -0
- data/spec/lock_spec.rb +59 -0
- data/spec/parse_spec.rb +29 -27
- data/spec/schedule_at_spec.rb +1 -1
- data/spec/scheduler_spec.rb +5 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/zotime_spec.rb +396 -0
- metadata +20 -20
- /data/spec/{custom_locks_spec.rb → lock_custom_spec.rb} +0 -0
- /data/spec/{lockfile_spec.rb → lock_lockfile_spec.rb} +0 -0
data/spec/parse_spec.rb
CHANGED
|
@@ -12,49 +12,51 @@ describe Rufus::Scheduler do
|
|
|
12
12
|
|
|
13
13
|
describe '.parse' do
|
|
14
14
|
|
|
15
|
-
def
|
|
16
|
-
Rufus::Scheduler.parse(s, opts)
|
|
17
|
-
end
|
|
15
|
+
def pa(s, opts={}); Rufus::Scheduler.parse(s, opts); end
|
|
18
16
|
|
|
19
17
|
it 'parses duration strings' do
|
|
20
18
|
|
|
21
|
-
expect(
|
|
19
|
+
expect(pa('1.0d1.0w1.0d')).to eq(777600.0)
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
it 'parses datetimes' do
|
|
25
23
|
|
|
26
24
|
# local
|
|
27
25
|
|
|
28
|
-
expect(
|
|
26
|
+
expect(pa('Sun Nov 18 16:01:00 2012').strftime('%c')).to eq(
|
|
29
27
|
'Sun Nov 18 16:01:00 2012'
|
|
30
28
|
)
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
it 'parses datetimes with timezones' do
|
|
34
32
|
|
|
35
|
-
expect(
|
|
36
|
-
'Sun Nov 18
|
|
37
|
-
)
|
|
33
|
+
expect(
|
|
34
|
+
pa('Sun Nov 18 16:01:00 2012 Asia/Singapore').getutc.strftime('%c %z')
|
|
35
|
+
).to eq('Sun Nov 18 08:01:00 2012 +0000')
|
|
38
36
|
|
|
39
|
-
expect(
|
|
37
|
+
expect(pa('Sun Nov 18 16:01:00 2012 Zulu').getutc.strftime('%c')).to eq(
|
|
40
38
|
'Sun Nov 18 16:01:00 2012'
|
|
41
39
|
)
|
|
42
40
|
|
|
43
|
-
expect(
|
|
44
|
-
'Sun Nov 18
|
|
45
|
-
)
|
|
41
|
+
expect(
|
|
42
|
+
pa('Sun Nov 18 16:01:00 Asia/Singapore 2012').getutc.strftime('%c %z')
|
|
43
|
+
).to eq('Sun Nov 18 08:01:00 2012 +0000')
|
|
46
44
|
|
|
47
|
-
expect(
|
|
48
|
-
'Sun Nov 18
|
|
49
|
-
)
|
|
45
|
+
expect(
|
|
46
|
+
pa('Asia/Singapore Sun Nov 18 16:01:00 2012').getutc.strftime('%c %z')
|
|
47
|
+
).to eq('Sun Nov 18 08:01:00 2012 +0000')
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
pa('Sun Nov 18 16:01:00 2012 America/New_York').getutc.strftime('%c %z')
|
|
51
|
+
).to eq('Sun Nov 18 21:01:00 2012 +0000')
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
it 'parses datetimes with named timezones' do
|
|
53
55
|
|
|
54
|
-
expect(
|
|
56
|
+
expect(pa(
|
|
55
57
|
'Sun Nov 18 16:01:00 2012 Europe/Berlin'
|
|
56
58
|
).strftime('%c %z')).to eq(
|
|
57
|
-
'Sun Nov 18
|
|
59
|
+
'Sun Nov 18 16:01:00 2012 +0100'
|
|
58
60
|
)
|
|
59
61
|
end
|
|
60
62
|
|
|
@@ -62,32 +64,32 @@ describe Rufus::Scheduler do
|
|
|
62
64
|
|
|
63
65
|
localzone = Time.now.strftime('%z')
|
|
64
66
|
|
|
65
|
-
expect(
|
|
66
|
-
|
|
67
|
-
)
|
|
67
|
+
expect(
|
|
68
|
+
pa('Nov 18 16:01:00 2012').strftime('%c %z')
|
|
69
|
+
).to eq("Sun Nov 18 16:01:00 2012 #{localzone}")
|
|
68
70
|
end
|
|
69
71
|
|
|
70
72
|
it 'parses cronlines' do
|
|
71
73
|
|
|
72
|
-
out =
|
|
74
|
+
out = pa('* * * * *')
|
|
73
75
|
|
|
74
76
|
expect(out.class).to eq(Rufus::Scheduler::CronLine)
|
|
75
77
|
expect(out.original).to eq('* * * * *')
|
|
76
78
|
|
|
77
|
-
expect(
|
|
78
|
-
expect(
|
|
79
|
+
expect(pa('10 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
|
|
80
|
+
expect(pa('* 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
it 'raises on unparseable input' do
|
|
82
84
|
|
|
83
85
|
expect {
|
|
84
|
-
|
|
86
|
+
pa('nada')
|
|
85
87
|
}.to raise_error(ArgumentError, 'couldn\'t parse "nada"')
|
|
86
88
|
end
|
|
87
89
|
|
|
88
90
|
it 'does not use Chronic if not present' do
|
|
89
91
|
|
|
90
|
-
t =
|
|
92
|
+
t = pa('next monday 7 PM')
|
|
91
93
|
|
|
92
94
|
n = Time.now
|
|
93
95
|
|
|
@@ -100,7 +102,7 @@ describe Rufus::Scheduler do
|
|
|
100
102
|
|
|
101
103
|
with_chronic do
|
|
102
104
|
|
|
103
|
-
t =
|
|
105
|
+
t = pa('next monday 7 PM')
|
|
104
106
|
|
|
105
107
|
expect(t.wday).to eq(1)
|
|
106
108
|
expect(t.hour).to eq(19)
|
|
@@ -113,7 +115,7 @@ describe Rufus::Scheduler do
|
|
|
113
115
|
|
|
114
116
|
with_chronic do
|
|
115
117
|
|
|
116
|
-
t =
|
|
118
|
+
t = pa('monday', :context => :past)
|
|
117
119
|
|
|
118
120
|
expect(t.wday).to eq(1)
|
|
119
121
|
expect(t).to be < Time.now
|
data/spec/schedule_at_spec.rb
CHANGED
|
@@ -107,7 +107,7 @@ describe Rufus::Scheduler do
|
|
|
107
107
|
|
|
108
108
|
job = @scheduler.at('2050-12-12 20:30 Europe/Berlin', :job => true) {}
|
|
109
109
|
|
|
110
|
-
expect(job.time.strftime('%c %z')).to eq('Mon Dec 12
|
|
110
|
+
expect(job.time.strftime('%c %z')).to eq('Mon Dec 12 20:30:00 2050 +0100')
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'accepts a Chronic string (if Chronic is present)' do
|
data/spec/scheduler_spec.rb
CHANGED
|
@@ -540,7 +540,7 @@ describe Rufus::Scheduler do
|
|
|
540
540
|
sleep 3
|
|
541
541
|
end
|
|
542
542
|
|
|
543
|
-
sleep 0.
|
|
543
|
+
sleep 0.49
|
|
544
544
|
|
|
545
545
|
expect(@scheduler.running_jobs(:tag => 't0').map(&:original)).to eq(
|
|
546
546
|
%w[ 0.1s ]
|
|
@@ -602,7 +602,10 @@ describe Rufus::Scheduler do
|
|
|
602
602
|
|
|
603
603
|
j0 = @scheduler.schedule_every '1m', :times => 10 do; end
|
|
604
604
|
|
|
605
|
-
|
|
605
|
+
t0 = Time.parse((Time.now + 5 * 60).strftime('%Y-%m-%d %H:%M:01'))
|
|
606
|
+
t1 = t0 + 12 * 60 - 1
|
|
607
|
+
|
|
608
|
+
h = @scheduler.occurrences(t0, t1)
|
|
606
609
|
|
|
607
610
|
expect(h[j0].size).to eq(6)
|
|
608
611
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -107,7 +107,7 @@ RSpec::Matchers.define :be_within_1s_of do |expected|
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
failure_message do |actual|
|
|
111
111
|
|
|
112
112
|
if actual.respond_to?(:asctime)
|
|
113
113
|
"expected #{actual.inspect} to be within 1 second of #{expected}"
|
data/spec/zotime_spec.rb
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
|
|
2
|
+
#
|
|
3
|
+
# Specifying rufus-scheduler
|
|
4
|
+
#
|
|
5
|
+
# Wed Mar 11 21:17:36 JST 2015, quatre ans...
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
require 'spec_helper'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
describe Rufus::Scheduler::ZoTime do
|
|
12
|
+
|
|
13
|
+
describe '.new' do
|
|
14
|
+
|
|
15
|
+
it 'accepts an integer' do
|
|
16
|
+
|
|
17
|
+
zt = Rufus::Scheduler::ZoTime.new(1234567890, 'America/Los_Angeles')
|
|
18
|
+
|
|
19
|
+
expect(zt.seconds.to_i).to eq(1234567890)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'accepts a float' do
|
|
23
|
+
|
|
24
|
+
zt = Rufus::Scheduler::ZoTime.new(1234567890.1234, 'America/Los_Angeles')
|
|
25
|
+
|
|
26
|
+
expect(zt.seconds.to_i).to eq(1234567890)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'accepts a Time instance' do
|
|
30
|
+
|
|
31
|
+
zt =
|
|
32
|
+
Rufus::Scheduler::ZoTime.new(
|
|
33
|
+
Time.utc(2007, 11, 1, 15, 25, 0),
|
|
34
|
+
'America/Los_Angeles')
|
|
35
|
+
|
|
36
|
+
expect(zt.seconds.to_i).to eq(1193930700)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
#it "flips burgers" do
|
|
41
|
+
# puts "---"
|
|
42
|
+
# t0 = ltz('America/New_York', 2004, 10, 31, 0, 30, 0)
|
|
43
|
+
# t1 = ltz('America/New_York', 2004, 10, 31, 1, 30, 0)
|
|
44
|
+
# p t0
|
|
45
|
+
# p t1
|
|
46
|
+
# puts "---"
|
|
47
|
+
# zt0 = Rufus::Scheduler::ZoTime.new(t0, 'America/New_York')
|
|
48
|
+
# zt1 = Rufus::Scheduler::ZoTime.new(t1, 'America/New_York')
|
|
49
|
+
# p zt0.time
|
|
50
|
+
# p zt1.time
|
|
51
|
+
# puts "---"
|
|
52
|
+
# zt0.add(3600)
|
|
53
|
+
# p [ zt0.time, zt0.time.zone ]
|
|
54
|
+
# p [ zt1.time, zt1.time.zone ]
|
|
55
|
+
# #puts "---"
|
|
56
|
+
# #zt0.add(3600)
|
|
57
|
+
# #zt1.add(3600)
|
|
58
|
+
# #p [ zt0.time, zt0.time.zone ]
|
|
59
|
+
# #p [ zt1.time, zt1.time.zone ]
|
|
60
|
+
#end
|
|
61
|
+
|
|
62
|
+
describe '#time' do
|
|
63
|
+
|
|
64
|
+
it 'returns a Time instance in with the right offset' do
|
|
65
|
+
|
|
66
|
+
zt = Rufus::Scheduler::ZoTime.new(1193898300, 'America/Los_Angeles')
|
|
67
|
+
t = zt.time
|
|
68
|
+
|
|
69
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z')
|
|
70
|
+
).to eq('2007/10/31 23:25:00 PDT')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# New York EST: UTC-5
|
|
74
|
+
# summer (dst) EDT: UTC-4
|
|
75
|
+
|
|
76
|
+
it 'chooses the non DST time when there is ambiguity' do
|
|
77
|
+
|
|
78
|
+
t = ltz('America/New_York', 2004, 10, 31, 0, 30, 0)
|
|
79
|
+
zt = Rufus::Scheduler::ZoTime.new(t, 'America/New_York')
|
|
80
|
+
zt.add(3600)
|
|
81
|
+
ztt = zt.time
|
|
82
|
+
|
|
83
|
+
expect(ztt.to_i).to eq(1099204200)
|
|
84
|
+
|
|
85
|
+
if ruby18?
|
|
86
|
+
expect(ztt.strftime('%Y/%m/%d %H:%M:%S %Z %z')
|
|
87
|
+
).to eq('2004/10/31 01:30:00 EST -0500')
|
|
88
|
+
else
|
|
89
|
+
expect(ztt.strftime('%Y/%m/%d %H:%M:%S %Z %z')
|
|
90
|
+
).to eq('2004/10/31 01:30:00 EST -0500')
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe '#utc' do
|
|
96
|
+
|
|
97
|
+
it 'returns an UTC Time instance' do
|
|
98
|
+
|
|
99
|
+
zt = Rufus::Scheduler::ZoTime.new(1193898300, 'America/Los_Angeles')
|
|
100
|
+
t = zt.utc
|
|
101
|
+
|
|
102
|
+
expect(t.to_i).to eq(1193898300)
|
|
103
|
+
|
|
104
|
+
if ruby18?
|
|
105
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z')
|
|
106
|
+
).to eq('2007/11/01 06:25:00 GMT +0000')
|
|
107
|
+
else
|
|
108
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z')
|
|
109
|
+
).to eq('2007/11/01 06:25:00 UTC +0000')
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe '#add' do
|
|
115
|
+
|
|
116
|
+
it 'adds seconds' do
|
|
117
|
+
|
|
118
|
+
zt = Rufus::Scheduler::ZoTime.new(1193898300, 'Europe/Paris')
|
|
119
|
+
zt.add(111)
|
|
120
|
+
|
|
121
|
+
expect(zt.seconds).to eq(1193898300 + 111)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'goes into DST' do
|
|
125
|
+
|
|
126
|
+
zt =
|
|
127
|
+
Rufus::Scheduler::ZoTime.new(
|
|
128
|
+
Time.gm(2015, 3, 8, 9, 59, 59),
|
|
129
|
+
'America/Los_Angeles')
|
|
130
|
+
|
|
131
|
+
t0 = zt.time
|
|
132
|
+
zt.add(1)
|
|
133
|
+
t1 = zt.time
|
|
134
|
+
|
|
135
|
+
st0 = t0.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t0.isdst}"
|
|
136
|
+
st1 = t1.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t1.isdst}"
|
|
137
|
+
|
|
138
|
+
expect(t0.to_i).to eq(1425808799)
|
|
139
|
+
expect(t1.to_i).to eq(1425808800)
|
|
140
|
+
expect(st0).to eq('2015/03/08 01:59:59 PST false')
|
|
141
|
+
expect(st1).to eq('2015/03/08 03:00:00 PDT true')
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'goes out of DST' do
|
|
145
|
+
|
|
146
|
+
zt =
|
|
147
|
+
Rufus::Scheduler::ZoTime.new(
|
|
148
|
+
ltz('Europe/Berlin', 2014, 10, 26, 01, 59, 59),
|
|
149
|
+
'Europe/Berlin')
|
|
150
|
+
|
|
151
|
+
t0 = zt.time
|
|
152
|
+
zt.add(1)
|
|
153
|
+
t1 = zt.time
|
|
154
|
+
zt.add(3600)
|
|
155
|
+
t2 = zt.time
|
|
156
|
+
zt.add(1)
|
|
157
|
+
t3 = zt.time
|
|
158
|
+
|
|
159
|
+
st0 = t0.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t0.isdst}"
|
|
160
|
+
st1 = t1.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t1.isdst}"
|
|
161
|
+
st2 = t2.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t2.isdst}"
|
|
162
|
+
st3 = t3.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t3.isdst}"
|
|
163
|
+
|
|
164
|
+
expect(t0.to_i).to eq(1414281599)
|
|
165
|
+
expect(t1.to_i).to eq(1414285200)
|
|
166
|
+
expect(t2.to_i).to eq(1414285200)
|
|
167
|
+
expect(t3.to_i).to eq(1414285201)
|
|
168
|
+
|
|
169
|
+
expect(st0).to eq('2014/10/26 01:59:59 CEST true')
|
|
170
|
+
expect(st1).to eq('2014/10/26 02:00:00 CET false')
|
|
171
|
+
expect(st2).to eq('2014/10/26 02:00:00 CET false')
|
|
172
|
+
expect(st3).to eq('2014/10/26 02:00:01 CET false')
|
|
173
|
+
|
|
174
|
+
expect(t1 - t0).to eq(3601)
|
|
175
|
+
expect(t2 - t1).to eq(0)
|
|
176
|
+
expect(t3 - t2).to eq(1)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe '#to_f' do
|
|
181
|
+
|
|
182
|
+
it 'returns the @seconds' do
|
|
183
|
+
|
|
184
|
+
zt = Rufus::Scheduler::ZoTime.new(1193898300, 'Europe/Paris')
|
|
185
|
+
|
|
186
|
+
expect(zt.to_f).to eq(1193898300)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe '.envtzable?' do
|
|
191
|
+
|
|
192
|
+
def etza?(s); Rufus::Scheduler::ZoTime.envtzable?(s); end
|
|
193
|
+
|
|
194
|
+
it 'matches' do
|
|
195
|
+
|
|
196
|
+
expect(etza?('Asia/Tokyo')).to eq(true)
|
|
197
|
+
expect(etza?('America/Los_Angeles')).to eq(true)
|
|
198
|
+
expect(etza?('Europe/Paris')).to eq(true)
|
|
199
|
+
expect(etza?('UTC')).to eq(true)
|
|
200
|
+
|
|
201
|
+
expect(etza?('Japan')).to eq(true)
|
|
202
|
+
expect(etza?('Turkey')).to eq(true)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'does not match' do
|
|
206
|
+
|
|
207
|
+
expect(etza?('14:00')).to eq(false)
|
|
208
|
+
expect(etza?('14:00:14')).to eq(false)
|
|
209
|
+
expect(etza?('2014/12/11')).to eq(false)
|
|
210
|
+
expect(etza?('2014-12-11')).to eq(false)
|
|
211
|
+
expect(etza?('+25:00')).to eq(false)
|
|
212
|
+
|
|
213
|
+
expect(etza?('+09:00')).to eq(false)
|
|
214
|
+
expect(etza?('-01:30')).to eq(false)
|
|
215
|
+
expect(etza?('-0200')).to eq(false)
|
|
216
|
+
|
|
217
|
+
expect(etza?('Wed')).to eq(false)
|
|
218
|
+
expect(etza?('Sun')).to eq(false)
|
|
219
|
+
expect(etza?('Nov')).to eq(false)
|
|
220
|
+
|
|
221
|
+
expect(etza?('PST')).to eq(false)
|
|
222
|
+
expect(etza?('Z')).to eq(false)
|
|
223
|
+
|
|
224
|
+
expect(etza?('YTC')).to eq(false)
|
|
225
|
+
expect(etza?('Asia/Paris')).to eq(false)
|
|
226
|
+
expect(etza?('Nada/Nada')).to eq(false)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
#it 'returns true for all entries in the tzinfo list' do
|
|
230
|
+
# File.readlines(
|
|
231
|
+
# File.join(File.dirname(__FILE__), '../misc/tz_all.txt')
|
|
232
|
+
# ).each do |tz|
|
|
233
|
+
# tz = tz.strip
|
|
234
|
+
# if tz.length > 0 && tz.match(/^[^#]/)
|
|
235
|
+
# p tz
|
|
236
|
+
# expect(llat?(tz)).to eq(true)
|
|
237
|
+
# end
|
|
238
|
+
# end
|
|
239
|
+
#end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe '.is_timezone?' do
|
|
243
|
+
|
|
244
|
+
def is_timezone?(o); Rufus::Scheduler::ZoTime.is_timezone?(o); end
|
|
245
|
+
|
|
246
|
+
it 'returns true when passed a string describing a timezone' do
|
|
247
|
+
|
|
248
|
+
expect(is_timezone?('Asia/Tokyo')).to eq(true)
|
|
249
|
+
expect(is_timezone?('Europe/Paris')).to eq(true)
|
|
250
|
+
expect(is_timezone?('UTC')).to eq(true)
|
|
251
|
+
expect(is_timezone?('GMT')).to eq(true)
|
|
252
|
+
expect(is_timezone?('Z')).to eq(true)
|
|
253
|
+
expect(is_timezone?('Zulu')).to eq(true)
|
|
254
|
+
expect(is_timezone?('PST')).to eq(true)
|
|
255
|
+
expect(is_timezone?('+09:00')).to eq(true)
|
|
256
|
+
expect(is_timezone?('-01:30')).to eq(true)
|
|
257
|
+
expect(is_timezone?('Japan')).to eq(true)
|
|
258
|
+
expect(is_timezone?('Turkey')).to eq(true)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
it 'returns false when it cannot make sense of the timezone' do
|
|
262
|
+
|
|
263
|
+
expect(is_timezone?('Asia/Paris')).to eq(false)
|
|
264
|
+
#expect(is_timezone?('YTC')).to eq(false)
|
|
265
|
+
expect(is_timezone?('Nada/Nada')).to eq(false)
|
|
266
|
+
expect(is_timezone?('7')).to eq(false)
|
|
267
|
+
expect(is_timezone?('06')).to eq(false)
|
|
268
|
+
expect(is_timezone?('sun#3')).to eq(false)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
#it 'returns true for all entries in the tzinfo list' do
|
|
272
|
+
# File.readlines(
|
|
273
|
+
# File.join(File.dirname(__FILE__), '../misc/tz_all.txt')
|
|
274
|
+
# ).each do |tz|
|
|
275
|
+
# tz = tz.strip
|
|
276
|
+
# if tz.length > 0 && tz.match(/^[^#]/)
|
|
277
|
+
# #p tz
|
|
278
|
+
# expect(is_timezone?(tz)).to eq(true)
|
|
279
|
+
# end
|
|
280
|
+
# end
|
|
281
|
+
#end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe '.parse' do
|
|
285
|
+
|
|
286
|
+
it 'parses a time string without a timezone' do
|
|
287
|
+
|
|
288
|
+
zt =
|
|
289
|
+
in_zone('Europe/Moscow') {
|
|
290
|
+
Rufus::Scheduler::ZoTime.parse('2015/03/08 01:59:59')
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
t = zt.time
|
|
294
|
+
u = zt.utc
|
|
295
|
+
|
|
296
|
+
expect(t.to_i).to eq(1425769199)
|
|
297
|
+
expect(u.to_i).to eq(1425769199)
|
|
298
|
+
|
|
299
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
|
|
300
|
+
).to eq('2015/03/08 01:59:59 MSK +0300 false')
|
|
301
|
+
|
|
302
|
+
if ruby18?
|
|
303
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
304
|
+
).to eq('2015/03/07 22:59:59 GMT +0000 false')
|
|
305
|
+
else
|
|
306
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
307
|
+
).to eq('2015/03/07 22:59:59 UTC +0000 false')
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
it 'parses a time string with a full name timezone' do
|
|
312
|
+
|
|
313
|
+
zt =
|
|
314
|
+
Rufus::Scheduler::ZoTime.parse(
|
|
315
|
+
'2015/03/08 01:59:59 America/Los_Angeles')
|
|
316
|
+
|
|
317
|
+
t = zt.time
|
|
318
|
+
u = zt.utc
|
|
319
|
+
|
|
320
|
+
expect(t.to_i).to eq(1425808799)
|
|
321
|
+
expect(u.to_i).to eq(1425808799)
|
|
322
|
+
|
|
323
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
|
|
324
|
+
).to eq('2015/03/08 01:59:59 PST -0800 false')
|
|
325
|
+
|
|
326
|
+
if ruby18?
|
|
327
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
328
|
+
).to eq('2015/03/08 09:59:59 GMT +0000 false')
|
|
329
|
+
else
|
|
330
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
331
|
+
).to eq('2015/03/08 09:59:59 UTC +0000 false')
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
it 'parses a time string with a delta timezone' do
|
|
336
|
+
|
|
337
|
+
zt =
|
|
338
|
+
in_zone('Europe/Berlin') {
|
|
339
|
+
Rufus::Scheduler::ZoTime.parse('2015-12-13 12:30 -0200')
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
t = zt.time
|
|
343
|
+
u = zt.utc
|
|
344
|
+
|
|
345
|
+
expect(t.to_i).to eq(1450017000)
|
|
346
|
+
expect(u.to_i).to eq(1450017000)
|
|
347
|
+
|
|
348
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
|
|
349
|
+
).to eq('2015/12/13 15:30:00 CET +0100 false')
|
|
350
|
+
|
|
351
|
+
if ruby18?
|
|
352
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
353
|
+
).to eq('2015/12/13 14:30:00 GMT +0000 false')
|
|
354
|
+
else
|
|
355
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
356
|
+
).to eq('2015/12/13 14:30:00 UTC +0000 false')
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
it 'parses a time string with a delta (:) timezone' do
|
|
361
|
+
|
|
362
|
+
zt =
|
|
363
|
+
in_zone('Europe/Berlin') {
|
|
364
|
+
Rufus::Scheduler::ZoTime.parse('2015-12-13 12:30 -02:00')
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
t = zt.time
|
|
368
|
+
u = zt.utc
|
|
369
|
+
|
|
370
|
+
expect(t.to_i).to eq(1450017000)
|
|
371
|
+
expect(u.to_i).to eq(1450017000)
|
|
372
|
+
|
|
373
|
+
expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
|
|
374
|
+
).to eq('2015/12/13 15:30:00 CET +0100 false')
|
|
375
|
+
|
|
376
|
+
if ruby18?
|
|
377
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
378
|
+
).to eq('2015/12/13 14:30:00 GMT +0000 false')
|
|
379
|
+
else
|
|
380
|
+
expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
|
|
381
|
+
).to eq('2015/12/13 14:30:00 UTC +0000 false')
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
it 'takes the local TZ when it does not know the timezone' do
|
|
386
|
+
|
|
387
|
+
in_zone 'Europe/Moscow' do
|
|
388
|
+
|
|
389
|
+
zt = Rufus::Scheduler::ZoTime.parse('2015/03/08 01:59:59 Nada/Nada')
|
|
390
|
+
|
|
391
|
+
expect(zt.time.zone).to eq('MSK')
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rufus-scheduler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,17 +9,17 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
15
|
+
name: rake
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '0'
|
|
22
|
-
type: :
|
|
22
|
+
type: :development
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
none: false
|
|
@@ -28,13 +28,13 @@ dependencies:
|
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0'
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
|
-
name:
|
|
31
|
+
name: rspec
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
33
33
|
none: false
|
|
34
34
|
requirements:
|
|
35
35
|
- - ! '>='
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version:
|
|
37
|
+
version: 2.13.0
|
|
38
38
|
type: :development
|
|
39
39
|
prerelease: false
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,15 +42,15 @@ dependencies:
|
|
|
42
42
|
requirements:
|
|
43
43
|
- - ! '>='
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version:
|
|
45
|
+
version: 2.13.0
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name:
|
|
47
|
+
name: chronic
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
49
|
none: false
|
|
50
50
|
requirements:
|
|
51
51
|
- - ! '>='
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: '0'
|
|
54
54
|
type: :development
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -58,9 +58,9 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - ! '>='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: '0'
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
|
63
|
-
name:
|
|
63
|
+
name: tzinfo
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
|
65
65
|
none: false
|
|
66
66
|
requirements:
|
|
@@ -85,32 +85,38 @@ files:
|
|
|
85
85
|
- Rakefile
|
|
86
86
|
- lib/rufus-scheduler.rb
|
|
87
87
|
- lib/rufus/scheduler.rb
|
|
88
|
+
- lib/rufus/scheduler/locks.rb
|
|
89
|
+
- lib/rufus/scheduler/zotime.rb
|
|
88
90
|
- lib/rufus/scheduler/cronline.rb
|
|
89
91
|
- lib/rufus/scheduler/util.rb
|
|
90
92
|
- lib/rufus/scheduler/jobs.rb
|
|
93
|
+
- lib/rufus/scheduler/zones.rb
|
|
91
94
|
- lib/rufus/scheduler/job_array.rb
|
|
92
95
|
- spec/job_spec.rb
|
|
93
96
|
- spec/schedule_in_spec.rb
|
|
97
|
+
- spec/zotime_spec.rb
|
|
94
98
|
- spec/spec_helper.rb
|
|
95
99
|
- spec/job_array_spec.rb
|
|
96
100
|
- spec/schedule_interval_spec.rb
|
|
97
101
|
- spec/job_at_spec.rb
|
|
98
102
|
- spec/schedule_at_spec.rb
|
|
99
103
|
- spec/error_spec.rb
|
|
104
|
+
- spec/lock_spec.rb
|
|
100
105
|
- spec/schedule_cron_spec.rb
|
|
101
106
|
- spec/job_interval_spec.rb
|
|
102
107
|
- spec/job_repeat_spec.rb
|
|
103
|
-
- spec/lockfile_spec.rb
|
|
104
108
|
- spec/schedule_every_spec.rb
|
|
105
109
|
- spec/threads_spec.rb
|
|
106
110
|
- spec/cronline_spec.rb
|
|
111
|
+
- spec/lock_lockfile_spec.rb
|
|
107
112
|
- spec/job_in_spec.rb
|
|
108
113
|
- spec/parse_spec.rb
|
|
109
114
|
- spec/scheduler_spec.rb
|
|
110
|
-
- spec/
|
|
115
|
+
- spec/lock_custom_spec.rb
|
|
111
116
|
- spec/basics_spec.rb
|
|
112
117
|
- spec/job_cron_spec.rb
|
|
113
118
|
- spec/job_every_spec.rb
|
|
119
|
+
- spec/lock_flock_spec.rb
|
|
114
120
|
- rufus-scheduler.gemspec
|
|
115
121
|
- CHANGELOG.txt
|
|
116
122
|
- TODO.txt
|
|
@@ -120,13 +126,7 @@ files:
|
|
|
120
126
|
homepage: http://github.com/jmettraux/rufus-scheduler
|
|
121
127
|
licenses:
|
|
122
128
|
- MIT
|
|
123
|
-
post_install_message:
|
|
124
|
-
might not be 100% compatible with rufus-scheduler 2.x.\n\nIf you encounter issues
|
|
125
|
-
with this new rufus-scheduler, especially\nif your app worked fine with previous
|
|
126
|
-
versions of it, you can\n\nA) Forget it and peg your Gemfile to rufus-scheduler
|
|
127
|
-
2.0.24\n\nand / or\n\nB) Take some time to carefully report the issue at\n https://github.com/jmettraux/rufus-scheduler/issues\n\nFor
|
|
128
|
-
general help about rufus-scheduler, ask via:\nhttp://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby\n\nCheers.\n\n***\n
|
|
129
|
-
\ "
|
|
129
|
+
post_install_message:
|
|
130
130
|
rdoc_options: []
|
|
131
131
|
require_paths:
|
|
132
132
|
- lib
|
|
File without changes
|
|
File without changes
|