Skip to content

Commit 69eb860

Browse files
committed
Update references to deprecated methods
Setting IceCube.compatibility to the latest to avoid exporting old hash keys for round-trip specs. Adding a helper to capture warnings in specs that support older formats. Removing some older unsupported specs.
1 parent 752d5ec commit 69eb860

14 files changed

+238
-328
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ IceCube::Schedule.from_yaml(yaml)
137137

138138
hash = schedule.to_hash
139139
IceCube::Schedule.from_hash(hash)
140-
141-
IceCube::Schedule.from_yaml(yaml, :start_date_override => Time.now)
142-
IceCube::Schedule.from_hash(hash, :start_date_override => Time.now)
143140
```
144141

145142
---
@@ -231,7 +228,7 @@ schedule.add_recurrence_rule Rule.yearly(4).day_of_year(-1)
231228
### Yearly (by month of year)
232229

233230
```ruby
234-
# every year on the same day as start_date but in january and february
231+
# every year on the same day as start_time but in january and february
235232
schedule.add_recurrence_rule Rule.yearly.month_of_year(:january, :februrary)
236233

237234
# every third year in march

spec/data/issue40.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
:start_date: 2011-11-16 11:31:58.441381000 -05:00
2+
:start_time: 2011-11-16 11:31:58.441381000 -05:00
33
:rrules:
44
- :rule_type: IceCube::MinutelyRule
55
:interval: 60
@@ -14,7 +14,6 @@
1414
- 16
1515
:minute_of_hour:
1616
- 0
17-
:exrules: []
1817
:rdates: []
1918
:exdates: []
2019
:duration: 3600

spec/examples/dst_spec.rb

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# DST in 2010 is March 14th at 2am
66
it 'crosses a daylight savings time boundary with a recurrence rule in local time, by utc conversion' do
7-
start_date = Time.local(2010, 3, 13, 5, 0, 0)
8-
schedule = IceCube::Schedule.new(start_date)
7+
start_time = Time.local(2010, 3, 13, 5, 0, 0)
8+
schedule = IceCube::Schedule.new(start_time)
99
schedule.add_recurrence_rule IceCube::Rule.daily.count(20)
1010
dates = schedule.first(20)
1111
dates.size.should == 20
@@ -18,8 +18,8 @@
1818

1919
# DST in 2010 is November 7th at 2am
2020
it 'crosses a daylight savings time boundary (in the other direction) with a recurrence rule in local time, by utc conversion' do
21-
start_date = Time.local(2010, 11, 6, 5, 0, 0)
22-
schedule = IceCube::Schedule.new(start_date)
21+
start_time = Time.local(2010, 11, 6, 5, 0, 0)
22+
schedule = IceCube::Schedule.new(start_time)
2323
schedule.add_recurrence_rule IceCube::Rule.daily.count(20)
2424
dates = schedule.first(20)
2525
dates.size.should == 20
@@ -31,189 +31,189 @@
3131
end
3232

3333
it 'cross a daylight savings time boundary with a recurrence rule in local time' do
34-
start_date = Time.local(2010, 3, 14, 5, 0, 0)
35-
schedule = IceCube::Schedule.new(start_date)
34+
start_time = Time.local(2010, 3, 14, 5, 0, 0)
35+
schedule = IceCube::Schedule.new(start_time)
3636
schedule.add_recurrence_rule IceCube::Rule.daily
3737
# each occurrence MUST occur at 5pm, then we win
38-
dates = schedule.occurrences(start_date + 20 * IceCube::ONE_DAY)
39-
last = start_date
38+
dates = schedule.occurrences(start_time + 20 * IceCube::ONE_DAY)
39+
last = start_time
4040
dates.each do |date|
4141
date.hour.should == 5
4242
last = date
4343
end
4444
end
4545

4646
it 'every two hours over a daylight savings time boundary, checking interval' do
47-
start_date = Time.local(2010, 11, 6, 5, 0, 0)
48-
schedule = IceCube::Schedule.new(start_date)
47+
start_time = Time.local(2010, 11, 6, 5, 0, 0)
48+
schedule = IceCube::Schedule.new(start_time)
4949
schedule.add_recurrence_rule IceCube::Rule.hourly(2)
5050
dates = schedule.first(100)
5151
#check assumption
5252
distance_in_hours = 0
5353
dates.each do |d|
54-
d.should == start_date + IceCube::ONE_HOUR * distance_in_hours
54+
d.should == start_time + IceCube::ONE_HOUR * distance_in_hours
5555
distance_in_hours += 2
5656
end
5757
end
5858

5959
it 'every 30 minutes over a daylight savings time boundary, checking interval' do
60-
start_date = Time.local(2010, 11, 6, 23, 0, 0)
61-
schedule = IceCube::Schedule.new(start_date)
60+
start_time = Time.local(2010, 11, 6, 23, 0, 0)
61+
schedule = IceCube::Schedule.new(start_time)
6262
schedule.add_recurrence_rule IceCube::Rule.minutely(30)
6363
dates = schedule.first(100)
6464
#check assumption
6565
distance_in_minutes = 0
6666
dates.each do |d|
67-
d.should == start_date + IceCube::ONE_MINUTE * distance_in_minutes
67+
d.should == start_time + IceCube::ONE_MINUTE * distance_in_minutes
6868
distance_in_minutes += 30
6969
end
7070
end
7171

7272
it 'every 120 seconds over a daylight savings time boundary, checking interval' do
73-
start_date = Time.local(2010, 11, 6, 23, 50, 0)
74-
schedule = IceCube::Schedule.new(start_date)
73+
start_time = Time.local(2010, 11, 6, 23, 50, 0)
74+
schedule = IceCube::Schedule.new(start_time)
7575
schedule.add_recurrence_rule IceCube::Rule.secondly(120)
7676
dates = schedule.first(10)
7777
#check assumption
7878
distance_in_seconds = 0
7979
dates.each do |d|
80-
d.should == start_date + distance_in_seconds
80+
d.should == start_time + distance_in_seconds
8181
distance_in_seconds += 120
8282
end
8383
end
8484

8585
it 'every other day over a daylight savings time boundary, checking hour/min/sec' do
86-
start_date = Time.local(2010, 11, 6, 20, 0, 0)
87-
schedule = IceCube::Schedule.new(start_date)
86+
start_time = Time.local(2010, 11, 6, 20, 0, 0)
87+
schedule = IceCube::Schedule.new(start_time)
8888
schedule.add_recurrence_rule IceCube::Rule.daily(2)
8989
dates = schedule.first(10)
9090
#check assumption
9191
dates.each do |d|
92-
d.hour.should == start_date.hour
93-
d.min.should == start_date.min
94-
d.sec.should == start_date.sec
92+
d.hour.should == start_time.hour
93+
d.min.should == start_time.min
94+
d.sec.should == start_time.sec
9595
end
9696
end
9797

9898
it 'every other month over a daylight savings time boundary, checking day/hour/min/sec' do
99-
start_date = Time.local(2010, 11, 6, 20, 0, 0)
100-
schedule = IceCube::Schedule.new(start_date)
99+
start_time = Time.local(2010, 11, 6, 20, 0, 0)
100+
schedule = IceCube::Schedule.new(start_time)
101101
schedule.add_recurrence_rule IceCube::Rule.monthly(2)
102102
dates = schedule.first(10)
103103
#check assumption
104104
dates.each do |d|
105-
d.day.should == start_date.day
106-
d.hour.should == start_date.hour
107-
d.min.should == start_date.min
108-
d.sec.should == start_date.sec
105+
d.day.should == start_time.day
106+
d.hour.should == start_time.hour
107+
d.min.should == start_time.min
108+
d.sec.should == start_time.sec
109109
end
110110
end
111111

112112
it 'every other year over a daylight savings time boundary, checking day/hour/min/sec' do
113-
start_date = Time.local(2010, 11, 6, 20, 0, 0)
114-
schedule = IceCube::Schedule.new(start_date)
113+
start_time = Time.local(2010, 11, 6, 20, 0, 0)
114+
schedule = IceCube::Schedule.new(start_time)
115115
schedule.add_recurrence_rule IceCube::Rule.yearly(2)
116116
dates = schedule.first(10)
117117
#check assumption
118118
dates.each do |d|
119-
d.month.should == start_date.month
120-
d.day.should == start_date.day
121-
d.hour.should == start_date.hour
122-
d.min.should == start_date.min
123-
d.sec.should == start_date.sec
119+
d.month.should == start_time.month
120+
d.day.should == start_time.day
121+
d.hour.should == start_time.hour
122+
d.min.should == start_time.min
123+
d.sec.should == start_time.sec
124124
end
125125
end
126126

127127
it 'LOCAL - has an until date on a rule that is over a DST from the start date' do
128-
start_date = Time.local(2010, 3, 13, 5, 0, 0)
128+
start_time = Time.local(2010, 3, 13, 5, 0, 0)
129129
end_date = Time.local(2010, 3, 15, 5, 0, 0)
130-
schedule = IceCube::Schedule.new(start_date)
130+
schedule = IceCube::Schedule.new(start_time)
131131
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
132132
#make sure we end on the proper time
133133
schedule.all_occurrences.last.should == end_date
134134
end
135135

136136
it 'UTC - has an until date on a rule that is over a DST from the start date' do
137-
start_date = Time.utc(2010, 3, 13, 5, 0, 0)
137+
start_time = Time.utc(2010, 3, 13, 5, 0, 0)
138138
end_date = Time.utc(2010, 3, 15, 5, 0, 0)
139-
schedule = IceCube::Schedule.new(start_date)
139+
schedule = IceCube::Schedule.new(start_time)
140140
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
141141
#make sure we end on the proper time
142142
schedule.all_occurrences.last.should == end_date
143143
end
144144

145145
it 'LOCAL - has an until date on a rule that is over a DST from the start date (other direction)' do
146-
start_date = Time.local(2010, 11, 5, 5, 0, 0)
146+
start_time = Time.local(2010, 11, 5, 5, 0, 0)
147147
end_date = Time.local(2010, 11, 10, 5, 0, 0)
148-
schedule = IceCube::Schedule.new(start_date)
148+
schedule = IceCube::Schedule.new(start_time)
149149
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
150150
#make sure we end on the proper time
151151
schedule.all_occurrences.last.should == end_date
152152
end
153153

154154
it 'UTC - has an until date on a rule that is over a DST from the start date (other direction)' do
155-
start_date = Time.utc(2010, 11, 5, 5, 0, 0)
155+
start_time = Time.utc(2010, 11, 5, 5, 0, 0)
156156
end_date = Time.utc(2010, 11, 10, 5, 0, 0)
157-
schedule = IceCube::Schedule.new(start_date)
157+
schedule = IceCube::Schedule.new(start_time)
158158
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_date)
159159
#make sure we end on the proper time
160160
schedule.all_occurrences.last.should == end_date
161161
end
162162

163163
it 'LOCAL - has an end date on a rule that is over a DST from the start date' do
164-
start_date = Time.local(2010, 3, 13, 5, 0, 0)
164+
start_time = Time.local(2010, 3, 13, 5, 0, 0)
165165
end_date = Time.local(2010, 3, 15, 5, 0, 0)
166-
schedule = IceCube::Schedule.new(start_date)
166+
schedule = IceCube::Schedule.new(start_time)
167167
schedule.add_recurrence_rule IceCube::Rule.daily
168168
#make sure we end on the proper time
169169
schedule.occurrences(end_date).last.should == end_date
170170
end
171171

172172
it 'UTC - has an end date on a rule that is over a DST from the start date' do
173-
start_date = Time.utc(2010, 3, 13, 5, 0, 0)
173+
start_time = Time.utc(2010, 3, 13, 5, 0, 0)
174174
end_date = Time.utc(2010, 3, 15, 5, 0, 0)
175-
schedule = IceCube::Schedule.new(start_date)
175+
schedule = IceCube::Schedule.new(start_time)
176176
schedule.add_recurrence_rule IceCube::Rule.daily
177177
#make sure we end on the proper time
178178
schedule.occurrences(end_date).last.should == end_date
179179
end
180180

181181
it 'LOCAL - has an end date on a rule that is over a DST from the start date (other direction)' do
182-
start_date = Time.local(2010, 11, 5, 5, 0, 0)
182+
start_time = Time.local(2010, 11, 5, 5, 0, 0)
183183
end_date = Time.local(2010, 11, 10, 5, 0, 0)
184-
schedule = IceCube::Schedule.new(start_date)
184+
schedule = IceCube::Schedule.new(start_time)
185185
schedule.add_recurrence_rule IceCube::Rule.daily
186186
#make sure we end on the proper time
187187
schedule.occurrences(end_date).last.should == end_date
188188
end
189189

190190
it 'UTC - has an end date on a rule that is over a DST from the start date (other direction)' do
191-
start_date = Time.utc(2010, 11, 5, 5, 0, 0)
191+
start_time = Time.utc(2010, 11, 5, 5, 0, 0)
192192
end_date = Time.utc(2010, 11, 10, 5, 0, 0)
193-
schedule = IceCube::Schedule.new(start_date)
193+
schedule = IceCube::Schedule.new(start_time)
194194
schedule.add_recurrence_rule IceCube::Rule.daily
195195
#make sure we end on the proper time
196196
schedule.occurrences(end_date).last.should == end_date
197197
end
198198

199199
it 'local - should make dates on interval over dst - github issue 4' do
200-
start_date = Time.local(2010, 3, 12, 19, 0, 0)
201-
schedule = IceCube::Schedule.new(start_date)
200+
start_time = Time.local(2010, 3, 12, 19, 0, 0)
201+
schedule = IceCube::Schedule.new(start_time)
202202
schedule.add_recurrence_rule IceCube::Rule.daily(3)
203203
schedule.first(3).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 3, 15, 19, 0, 0), Time.local(2010, 3, 18, 19, 0, 0)]
204204
end
205205

206206
it 'local - should make dates on monthly interval over dst - github issue 4' do
207-
start_date = Time.local(2010, 3, 12, 19, 0, 0)
208-
schedule = IceCube::Schedule.new(start_date)
207+
start_time = Time.local(2010, 3, 12, 19, 0, 0)
208+
schedule = IceCube::Schedule.new(start_time)
209209
schedule.add_recurrence_rule IceCube::Rule.monthly(2)
210210
schedule.first(6).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 5, 12, 19, 0, 0), Time.local(2010, 7, 12, 19, 0, 0),
211211
Time.local(2010, 9, 12, 19, 0, 0), Time.local(2010, 11, 12, 19, 0, 0), Time.local(2011, 1, 12, 19, 0, 0)]
212212
end
213213

214214
it 'local - should make dates on monthly interval over dst - github issue 4' do
215-
start_date = Time.local(2010, 3, 12, 19, 0, 0)
216-
schedule = IceCube::Schedule.new(start_date)
215+
start_time = Time.local(2010, 3, 12, 19, 0, 0)
216+
schedule = IceCube::Schedule.new(start_time)
217217
schedule.add_recurrence_rule IceCube::Rule.monthly
218218
schedule.first(10).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2010, 4, 12, 19, 0, 0), Time.local(2010, 5, 12, 19, 0, 0),
219219
Time.local(2010, 6, 12, 19, 0, 0), Time.local(2010, 7, 12, 19, 0, 0), Time.local(2010, 8, 12, 19, 0, 0),
@@ -222,43 +222,43 @@
222222
end
223223

224224
it 'local - should make dates on yearly interval over dst - github issue 4' do
225-
start_date = Time.local(2010, 3, 12, 19, 0, 0)
226-
schedule = IceCube::Schedule.new(start_date)
225+
start_time = Time.local(2010, 3, 12, 19, 0, 0)
226+
schedule = IceCube::Schedule.new(start_time)
227227
schedule.add_recurrence_rule IceCube::Rule.yearly(2)
228228
schedule.first(3).should == [Time.local(2010, 3, 12, 19, 0, 0), Time.local(2012, 3, 12, 19, 0, 0), Time.local(2014, 3, 12, 19, 0, 0)]
229229
end
230230

231231
it "local - should make dates on monthly (day of week) inverval over dst - github issue 5" do
232-
start_date = Time.local(2010, 3, 7, 12, 0, 0)
233-
schedule = IceCube::Schedule.new(start_date)
232+
start_time = Time.local(2010, 3, 7, 12, 0, 0)
233+
schedule = IceCube::Schedule.new(start_time)
234234
schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_week(:sunday => [1])
235235
schedule.first(3).should == [Time.local(2010, 3, 7, 12, 0, 0), Time.local(2010, 4, 4, 12, 0, 0), Time.local(2010, 5, 2, 12, 0, 0)]
236236
end
237237

238238
it "local - should make dates on monthly (day of month) inverval over dst - github issue 5" do
239-
start_date = Time.local(2010, 3, 1, 12, 0, 0)
240-
schedule = IceCube::Schedule.new(start_date)
239+
start_time = Time.local(2010, 3, 1, 12, 0, 0)
240+
schedule = IceCube::Schedule.new(start_time)
241241
schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_month(1)
242242
schedule.first(3).should == [Time.local(2010, 3, 1, 12, 0, 0), Time.local(2010, 4, 1, 12, 0, 0), Time.local(2010, 5, 1, 12, 0, 0)]
243243
end
244244

245245
it "local - should make dates on weekly (day) inverval over dst - github issue 5" do
246-
start_date = Time.local(2010, 3, 7, 12, 0, 0)
247-
schedule = IceCube::Schedule.new(start_date)
246+
start_time = Time.local(2010, 3, 7, 12, 0, 0)
247+
schedule = IceCube::Schedule.new(start_time)
248248
schedule.add_recurrence_rule IceCube::Rule.weekly.day(:sunday)
249249
schedule.first(3).should == [Time.local(2010, 3, 7, 12, 0, 0), Time.local(2010, 3, 14, 12, 0, 0), Time.local(2010, 3, 21, 12, 0, 0)]
250250
end
251251

252252
it "local - should make dates on monthly (day of year) inverval over dst - github issue 5" do
253-
start_date = Time.local(2010, 3, 7, 12, 0, 0)
254-
schedule = IceCube::Schedule.new(start_date)
253+
start_time = Time.local(2010, 3, 7, 12, 0, 0)
254+
schedule = IceCube::Schedule.new(start_time)
255255
schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_year(1)
256256
schedule.first(3).should == [Time.local(2011, 1, 1, 12, 0, 0), Time.local(2012, 1, 1, 12, 0, 0), Time.local(2013, 1, 1, 12, 0, 0)]
257257
end
258258

259259
it "local - should make dates on monthly (month_of_year) inverval over dst - github issue 5" do
260-
start_date = Time.local(2010, 3, 7, 12, 0, 0)
261-
schedule = IceCube::Schedule.new(start_date)
260+
start_time = Time.local(2010, 3, 7, 12, 0, 0)
261+
schedule = IceCube::Schedule.new(start_time)
262262
schedule.add_recurrence_rule IceCube::Rule.yearly.month_of_year(:april).day_of_month(10)
263263
schedule.first(3).should == [Time.local(2010, 4, 10, 12, 0, 0), Time.local(2011, 4, 10, 12, 0, 0), Time.local(2012, 4, 10, 12, 0, 0)]
264264
end

spec/examples/hourly_rule_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ module IceCube
5959
end
6060

6161
it 'should produce the correct days for @interval = 3' do
62-
start_date = DAY
63-
schedule = Schedule.new(start_date)
62+
start_time = DAY
63+
schedule = Schedule.new(start_time)
6464
schedule = Schedule.from_yaml(schedule.to_yaml)
6565
schedule.add_recurrence_rule Rule.hourly(3)
6666
#check assumption (3) -- (1) 2 (3) 4 (5) 6

0 commit comments

Comments
 (0)