@@ -6,89 +6,89 @@ module IceCube
6
6
describe Rule , 'from_ical' do
7
7
8
8
it 'should return a IceCube DailyRule class for a basic daily rule' do
9
- rule = IceCube ::IcalParser . rule_from_ical "FREQ=DAILY"
9
+ rule = IceCube ::Rule . from_ical "FREQ=DAILY"
10
10
rule . class . should == IceCube ::DailyRule
11
11
end
12
12
13
13
it 'should return a IceCube WeeklyRule class for a basic monthly rule' do
14
- rule = IceCube ::IcalParser . rule_from_ical "FREQ=WEEKLY"
14
+ rule = IceCube ::Rule . from_ical "FREQ=WEEKLY"
15
15
rule . class . should == IceCube ::WeeklyRule
16
16
end
17
17
18
18
it 'should return a IceCube MonthlyRule class for a basic monthly rule' do
19
- rule = IceCube ::IcalParser . rule_from_ical "FREQ=MONTHLY"
19
+ rule = IceCube ::Rule . from_ical "FREQ=MONTHLY"
20
20
rule . class . should == IceCube ::MonthlyRule
21
21
end
22
22
23
23
it 'should return a IceCube YearlyRule class for a basic yearly rule' do
24
- rule = IceCube ::IcalParser . rule_from_ical "FREQ=YEARLY"
24
+ rule = IceCube ::Rule . from_ical "FREQ=YEARLY"
25
25
rule . class . should == IceCube ::YearlyRule
26
26
end
27
27
28
28
it 'should be able to parse a .day rule' do
29
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYDAY=MO,TU" )
29
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYDAY=MO,TU" )
30
30
rule . should == IceCube ::Rule . daily . day ( :monday , :tuesday )
31
31
end
32
32
33
33
it 'should be able to parse a .day_of_week rule' do
34
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYDAY=-1TU,-2TU" )
34
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYDAY=-1TU,-2TU" )
35
35
rule . should == IceCube ::Rule . daily . day_of_week ( :tuesday => [ -1 , -2 ] )
36
36
end
37
37
38
38
it 'should be able to parse both .day and .day_of_week rules' do
39
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYDAY=MO,-1TU,-2TU" )
39
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYDAY=MO,-1TU,-2TU" )
40
40
rule . should == IceCube ::Rule . daily . day_of_week ( :tuesday => [ -1 , -2 ] ) . day ( :monday )
41
41
end
42
42
43
43
it 'should be able to parse a .day_of_month rule' do
44
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYMONTHDAY=23" )
44
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYMONTHDAY=23" )
45
45
rule . should == IceCube ::Rule . daily . day_of_month ( 23 )
46
46
end
47
47
48
48
it 'should be able to parse a .day_of_year rule' do
49
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYYEARDAY=100,200" )
49
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYYEARDAY=100,200" )
50
50
rule . should == IceCube ::Rule . daily . day_of_year ( 100 , 200 )
51
51
end
52
52
53
53
it 'should be able to serialize a .month_of_year rule' do
54
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYMONTH=1,4" )
54
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYMONTH=1,4" )
55
55
rule . should == IceCube ::Rule . daily . month_of_year ( :january , :april )
56
56
end
57
57
58
58
it 'should be able to split to a combination of day_of_week and day (day_of_week has priority)' do
59
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYDAY=TU,MO,1MO,-1MO" )
59
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYDAY=TU,MO,1MO,-1MO" )
60
60
rule . should == IceCube ::Rule . daily . day ( :tuesday ) . day_of_week ( :monday => [ 1 , -1 ] )
61
61
end
62
62
63
63
it 'should be able to parse of .day_of_week rule with multiple days' do
64
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;BYDAY=WE,1MO,-1MO,2TU" )
64
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;BYDAY=WE,1MO,-1MO,2TU" )
65
65
rule . should == IceCube ::Rule . daily . day_of_week ( :monday => [ 1 , -1 ] , :tuesday => [ 2 ] ) . day ( :wednesday )
66
66
end
67
67
68
68
it 'should be able to parse a rule with an until date' do
69
69
t = Time . now . utc
70
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=WEEKLY;UNTIL=#{ t . strftime ( "%Y%m%dT%H%M%SZ" ) } " )
70
+ rule = IceCube ::Rule . from_ical ( "FREQ=WEEKLY;UNTIL=#{ t . strftime ( "%Y%m%dT%H%M%SZ" ) } " )
71
71
rule . to_s . should == IceCube ::Rule . weekly . until ( t ) . to_s
72
72
end
73
73
74
74
it 'should be able to parse a rule with a count date' do
75
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=WEEKLY;COUNT=5" )
75
+ rule = IceCube ::Rule . from_ical ( "FREQ=WEEKLY;COUNT=5" )
76
76
rule . should == IceCube ::Rule . weekly . count ( 5 )
77
77
end
78
78
79
79
it 'should be able to parse a rule with an interval' do
80
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;INTERVAL=2" )
80
+ rule = IceCube ::Rule . from_ical ( "FREQ=DAILY;INTERVAL=2" )
81
81
rule . should == IceCube ::Rule . daily . interval ( 2 )
82
82
end
83
83
84
84
it 'should be able to parse week start (WKST)' do
85
- rule = IceCube ::IcalParser . rule_from_ical ( "FREQ=WEEKLY;INTERVAL=2;WKST=MO" )
85
+ rule = IceCube ::Rule . from_ical ( "FREQ=WEEKLY;INTERVAL=2;WKST=MO" )
86
86
rule . should == IceCube ::Rule . weekly ( 2 , :monday )
87
87
end
88
88
89
89
it 'should return no occurrences after daily interval with count is over' do
90
90
schedule = IceCube ::Schedule . new ( Time . now )
91
- schedule . add_recurrence_rule ( IceCube ::IcalParser . rule_from_ical ( "FREQ=DAILY;COUNT=5" ) )
91
+ schedule . add_recurrence_rule ( IceCube ::Rule . from_ical ( "FREQ=DAILY;COUNT=5" ) )
92
92
schedule . occurrences_between ( Time . now + 7 . days , Time . now + 14 . days ) . count . should == 0
93
93
end
94
94
@@ -123,7 +123,7 @@ def sorted_ical(ical)
123
123
124
124
describe "instantiation" do
125
125
it "loads an ICAL string" do
126
- expect ( IceCube ::IcalParser . schedule_from_ical ( ical_string ) ) . to be_a ( IceCube ::Schedule )
126
+ expect ( IceCube ::Schedule . from_ical ( ical_string ) ) . to be_a ( IceCube ::Schedule )
127
127
end
128
128
end
129
129
@@ -135,7 +135,7 @@ def sorted_ical(ical)
135
135
schedule . add_recurrence_rule ( IceCube ::Rule . daily )
136
136
137
137
ical = schedule . to_ical
138
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
138
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
139
139
end
140
140
141
141
it 'handles counts' do
@@ -145,7 +145,7 @@ def sorted_ical(ical)
145
145
schedule . add_recurrence_rule ( IceCube ::Rule . daily . count ( 4 ) )
146
146
147
147
ical = schedule . to_ical
148
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
148
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
149
149
end
150
150
151
151
it 'handles intervals' do
@@ -155,7 +155,7 @@ def sorted_ical(ical)
155
155
schedule . add_recurrence_rule ( IceCube ::Rule . daily ( 4 ) )
156
156
157
157
ical = schedule . to_ical
158
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
158
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
159
159
end
160
160
161
161
it 'handles intervals and counts' do
@@ -165,7 +165,7 @@ def sorted_ical(ical)
165
165
schedule . add_recurrence_rule ( IceCube ::Rule . daily ( 4 ) . count ( 10 ) )
166
166
167
167
ical = schedule . to_ical
168
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
168
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
169
169
end
170
170
171
171
it 'handles until dates' do
@@ -175,7 +175,7 @@ def sorted_ical(ical)
175
175
schedule . add_recurrence_rule ( IceCube ::Rule . daily . until ( start_time + 15 . days ) )
176
176
177
177
ical = schedule . to_ical
178
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
178
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
179
179
end
180
180
181
181
end
@@ -188,7 +188,7 @@ def sorted_ical(ical)
188
188
schedule . add_recurrence_rule ( IceCube ::Rule . weekly )
189
189
190
190
ical = schedule . to_ical
191
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
191
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
192
192
end
193
193
194
194
it 'handles weekdays' do
@@ -198,7 +198,7 @@ def sorted_ical(ical)
198
198
schedule . add_recurrence_rule ( IceCube ::Rule . weekly . day ( :monday , :thursday ) )
199
199
200
200
ical = schedule . to_ical
201
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
201
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
202
202
end
203
203
204
204
it 'handles intervals' do
@@ -208,7 +208,7 @@ def sorted_ical(ical)
208
208
schedule . add_recurrence_rule ( IceCube ::Rule . weekly ( 2 ) )
209
209
210
210
ical = schedule . to_ical
211
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
211
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
212
212
end
213
213
214
214
it 'handles intervals and counts' do
@@ -218,7 +218,7 @@ def sorted_ical(ical)
218
218
schedule . add_recurrence_rule ( IceCube ::Rule . weekly ( 2 ) . count ( 4 ) )
219
219
220
220
ical = schedule . to_ical
221
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
221
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
222
222
end
223
223
224
224
it 'handles intervals and counts on given weekdays' do
@@ -228,7 +228,7 @@ def sorted_ical(ical)
228
228
schedule . add_recurrence_rule ( IceCube ::Rule . weekly ( 2 ) . day ( :monday , :wednesday ) . count ( 4 ) )
229
229
230
230
ical = schedule . to_ical
231
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
231
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
232
232
end
233
233
end
234
234
@@ -240,7 +240,7 @@ def sorted_ical(ical)
240
240
schedule . add_recurrence_rule ( IceCube ::Rule . monthly )
241
241
242
242
ical = schedule . to_ical
243
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
243
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
244
244
end
245
245
246
246
it 'handles intervals' do
@@ -250,7 +250,7 @@ def sorted_ical(ical)
250
250
schedule . add_recurrence_rule ( IceCube ::Rule . monthly ( 2 ) )
251
251
252
252
ical = schedule . to_ical
253
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
253
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
254
254
end
255
255
256
256
it 'handles intervals and counts' do
@@ -260,7 +260,7 @@ def sorted_ical(ical)
260
260
schedule . add_recurrence_rule ( IceCube ::Rule . monthly ( 2 ) . count ( 5 ) )
261
261
262
262
ical = schedule . to_ical
263
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
263
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
264
264
end
265
265
266
266
it 'handles intervals and counts on specific days' do
@@ -270,7 +270,7 @@ def sorted_ical(ical)
270
270
schedule . add_recurrence_rule ( IceCube ::Rule . monthly ( 2 ) . day_of_month ( 1 , 15 ) . count ( 5 ) )
271
271
272
272
ical = schedule . to_ical
273
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
273
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
274
274
end
275
275
end
276
276
@@ -282,7 +282,7 @@ def sorted_ical(ical)
282
282
schedule . add_recurrence_rule ( IceCube ::Rule . yearly )
283
283
284
284
ical = schedule . to_ical
285
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
285
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
286
286
end
287
287
288
288
it 'handles intervals' do
@@ -292,7 +292,7 @@ def sorted_ical(ical)
292
292
schedule . add_recurrence_rule ( IceCube ::Rule . yearly ( 2 ) )
293
293
294
294
ical = schedule . to_ical
295
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
295
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
296
296
end
297
297
298
298
it 'handles a specific day' do
@@ -302,7 +302,7 @@ def sorted_ical(ical)
302
302
schedule . add_recurrence_rule ( IceCube ::Rule . yearly . day_of_year ( 15 ) )
303
303
304
304
ical = schedule . to_ical
305
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
305
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
306
306
end
307
307
308
308
it 'handles specific days' do
@@ -312,7 +312,7 @@ def sorted_ical(ical)
312
312
schedule . add_recurrence_rule ( IceCube ::Rule . yearly . day_of_year ( 1 , 15 , -1 ) )
313
313
314
314
ical = schedule . to_ical
315
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
315
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
316
316
end
317
317
318
318
it 'handles counts' do
@@ -322,7 +322,7 @@ def sorted_ical(ical)
322
322
schedule . add_recurrence_rule ( IceCube ::Rule . yearly . count ( 5 ) )
323
323
324
324
ical = schedule . to_ical
325
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
325
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
326
326
end
327
327
328
328
it 'handles specific months' do
@@ -332,7 +332,7 @@ def sorted_ical(ical)
332
332
schedule . add_recurrence_rule ( IceCube ::Rule . yearly . month_of_year ( :january , :december ) )
333
333
334
334
ical = schedule . to_ical
335
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
335
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
336
336
end
337
337
338
338
it 'handles specific months and counts' do
@@ -342,7 +342,7 @@ def sorted_ical(ical)
342
342
schedule . add_recurrence_rule ( IceCube ::Rule . yearly . month_of_year ( :january , :december ) . count ( 15 ) )
343
343
344
344
ical = schedule . to_ical
345
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
345
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
346
346
end
347
347
end
348
348
@@ -355,11 +355,11 @@ def sorted_ical(ical)
355
355
schedule . add_exception_time ( Time . now + 2 . days )
356
356
357
357
ical = schedule . to_ical
358
- sorted_ical ( IceCube ::IcalParser . schedule_from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
358
+ sorted_ical ( IceCube ::Schedule . from_ical ( ical ) . to_ical ) . should eq ( sorted_ical ( ical ) )
359
359
end
360
360
361
361
it 'handles multiple EXDATE lines' do
362
- schedule = IceCube ::IcalParser . schedule_from_ical ical_string_woth_multiple_exdates
362
+ schedule = IceCube ::Schedule . from_ical ical_string_woth_multiple_exdates
363
363
schedule . exception_times . count . should == 3
364
364
end
365
365
end
0 commit comments