tilia-vobject 4.0.0.pre.alpha5 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.sabre.md +59 -2
  3. data/Gemfile +1 -8
  4. data/Gemfile.lock +18 -12
  5. data/LICENSE +1 -1
  6. data/LICENSE.sabre +1 -1
  7. data/lib/tilia/v_object.rb +1 -0
  8. data/lib/tilia/v_object/birthday_calendar_generator.rb +11 -11
  9. data/lib/tilia/v_object/cli.rb +39 -38
  10. data/lib/tilia/v_object/component.rb +47 -50
  11. data/lib/tilia/v_object/component/available.rb +4 -37
  12. data/lib/tilia/v_object/component/v_alarm.rb +6 -18
  13. data/lib/tilia/v_object/component/v_availability.rb +6 -39
  14. data/lib/tilia/v_object/component/v_calendar.rb +66 -98
  15. data/lib/tilia/v_object/component/v_card.rb +42 -69
  16. data/lib/tilia/v_object/component/v_event.rb +5 -17
  17. data/lib/tilia/v_object/component/v_free_busy.rb +4 -16
  18. data/lib/tilia/v_object/component/v_journal.rb +16 -16
  19. data/lib/tilia/v_object/component/v_time_zone.rb +2 -14
  20. data/lib/tilia/v_object/component/v_todo.rb +17 -36
  21. data/lib/tilia/v_object/date_time_parser.rb +24 -24
  22. data/lib/tilia/v_object/document.rb +25 -25
  23. data/lib/tilia/v_object/free_busy_data.rb +7 -7
  24. data/lib/tilia/v_object/free_busy_generator.rb +73 -75
  25. data/lib/tilia/v_object/i_tip.rb +1 -0
  26. data/lib/tilia/v_object/i_tip/broker.rb +134 -116
  27. data/lib/tilia/v_object/i_tip/i_tip_exception.rb +1 -1
  28. data/lib/tilia/v_object/i_tip/message.rb +13 -13
  29. data/lib/tilia/v_object/invalid_data_exception.rb +8 -0
  30. data/lib/tilia/v_object/node.rb +22 -27
  31. data/lib/tilia/v_object/parameter.rb +22 -22
  32. data/lib/tilia/v_object/parse_exception.rb +1 -1
  33. data/lib/tilia/v_object/parser.rb +1 -0
  34. data/lib/tilia/v_object/parser/json.rb +9 -19
  35. data/lib/tilia/v_object/parser/mime_dir.rb +73 -39
  36. data/lib/tilia/v_object/parser/parser.rb +9 -14
  37. data/lib/tilia/v_object/parser/xml.rb +33 -50
  38. data/lib/tilia/v_object/parser/xml/element.rb +1 -0
  39. data/lib/tilia/v_object/parser/xml/element/key_value.rb +2 -2
  40. data/lib/tilia/v_object/property.rb +52 -52
  41. data/lib/tilia/v_object/property/binary.rb +10 -10
  42. data/lib/tilia/v_object/property/boolean.rb +6 -6
  43. data/lib/tilia/v_object/property/flat_text.rb +3 -3
  44. data/lib/tilia/v_object/property/float_value.rb +10 -10
  45. data/lib/tilia/v_object/property/i_calendar.rb +1 -0
  46. data/lib/tilia/v_object/property/i_calendar/cal_address.rb +3 -3
  47. data/lib/tilia/v_object/property/i_calendar/date_time.rb +29 -57
  48. data/lib/tilia/v_object/property/i_calendar/duration.rb +6 -6
  49. data/lib/tilia/v_object/property/i_calendar/period.rb +10 -10
  50. data/lib/tilia/v_object/property/i_calendar/recur.rb +16 -24
  51. data/lib/tilia/v_object/property/integer_value.rb +8 -8
  52. data/lib/tilia/v_object/property/text.rb +21 -36
  53. data/lib/tilia/v_object/property/time.rb +29 -6
  54. data/lib/tilia/v_object/property/unknown.rb +2 -2
  55. data/lib/tilia/v_object/property/uri.rb +24 -5
  56. data/lib/tilia/v_object/property/utc_offset.rb +5 -5
  57. data/lib/tilia/v_object/property/v_card.rb +1 -0
  58. data/lib/tilia/v_object/property/v_card/date.rb +3 -3
  59. data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +30 -42
  60. data/lib/tilia/v_object/property/v_card/date_time.rb +1 -1
  61. data/lib/tilia/v_object/property/v_card/language_tag.rb +4 -4
  62. data/lib/tilia/v_object/property/v_card/time_stamp.rb +5 -5
  63. data/lib/tilia/v_object/reader.rb +12 -11
  64. data/lib/tilia/v_object/recur.rb +2 -0
  65. data/lib/tilia/v_object/recur/event_iterator.rb +30 -27
  66. data/lib/tilia/v_object/recur/max_instances_exceeded_exception.rb +10 -0
  67. data/lib/tilia/v_object/recur/no_instances_exception.rb +1 -1
  68. data/lib/tilia/v_object/recur/r_date_iterator.rb +15 -41
  69. data/lib/tilia/v_object/recur/r_rule_iterator.rb +23 -156
  70. data/lib/tilia/v_object/settings.rb +16 -0
  71. data/lib/tilia/v_object/splitter.rb +1 -0
  72. data/lib/tilia/v_object/splitter/i_calendar.rb +5 -5
  73. data/lib/tilia/v_object/splitter/splitter_interface.rb +2 -2
  74. data/lib/tilia/v_object/splitter/v_card.rb +5 -5
  75. data/lib/tilia/v_object/string_util.rb +25 -9
  76. data/lib/tilia/v_object/time_zone_data.rb +1 -0
  77. data/lib/tilia/v_object/time_zone_util.rb +6 -6
  78. data/lib/tilia/v_object/uuid_util.rb +3 -3
  79. data/lib/tilia/v_object/v_card_converter.rb +24 -21
  80. data/lib/tilia/v_object/version.rb +1 -1
  81. data/lib/tilia/v_object/writer.rb +7 -7
  82. data/test/test_helper.rb +3 -3
  83. data/test/v_object/birthday_calendar_generator_test.rb +22 -0
  84. data/test/v_object/component/v_alarm_test.rb +3 -1
  85. data/test/v_object/component/v_calendar_test.rb +40 -4
  86. data/test/v_object/component/v_card_test.rb +1 -1
  87. data/test/v_object/component_test.rb +5 -3
  88. data/test/v_object/date_time_parser_test.rb +15 -5
  89. data/test/v_object/free_busy_generator_test.rb +5 -5
  90. data/test/v_object/i_tip/broker_attendee_reply_test.rb +19 -0
  91. data/test/v_object/i_tip/broker_delete_event_test.rb +146 -2
  92. data/test/v_object/i_tip/broker_new_event_test.rb +21 -0
  93. data/test/v_object/i_tip/broker_process_reply_test.rb +10 -0
  94. data/test/v_object/i_tip/broker_tester.rb +1 -1
  95. data/test/v_object/i_tip/broker_update_event_test.rb +36 -0
  96. data/test/v_object/issue259_test.rb +24 -0
  97. data/test/v_object/issue40_test.rb +3 -1
  98. data/test/v_object/j_cal_test.rb +15 -12
  99. data/test/v_object/parser/json_test.rb +5 -5
  100. data/test/v_object/parser/mime_dir_test.rb +109 -0
  101. data/test/v_object/property/binary_test.rb +4 -2
  102. data/test/v_object/property/i_calendar/date_time_test.rb +3 -1
  103. data/test/v_object/property/uri_test.rb +23 -0
  104. data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +1 -1
  105. data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +1 -1
  106. data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +9 -9
  107. data/test/v_object/recur/event_iterator/handle_r_date_expand_test.rb +51 -0
  108. data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +3 -5
  109. data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +3 -1
  110. data/test/v_object/{issue26_test.rb → recur/event_iterator/issue26_test.rb} +3 -1
  111. data/test/v_object/recur/event_iterator/main_test.rb +9 -3
  112. data/test/v_object/recur/event_iterator/max_instances_test.rb +38 -0
  113. data/test/v_object/recur/event_iterator/missing_overridden_test.rb +3 -5
  114. data/test/v_object/recur/event_iterator/no_instances_test.rb +5 -3
  115. data/test/v_object/recur/event_iterator/override_first_event_test.rb +9 -9
  116. data/test/v_object/recur/r_date_iterator_test.rb +18 -0
  117. data/test/v_object/recur/r_rule_iterator_test.rb +4 -4
  118. data/test/v_object/splitter/i_calendar_test.rb +27 -7
  119. data/test/v_object/splitter/v_card_test.rb +5 -3
  120. data/test/v_object/test_case.rb +14 -4
  121. data/tilia-vobject.gemspec +2 -2
  122. metadata +17 -11
@@ -175,6 +175,7 @@ SEQUENCE:2
175
175
  UID:foobar
176
176
  RRULE:FREQ=DAILY
177
177
  DTSTART:20140724T000000Z
178
+ DTEND:20140724T010000Z
178
179
  ATTENDEE:mailto:foo@example.org
179
180
  ORGANIZER:mailto:bar@example.org
180
181
  END:VEVENT
@@ -189,6 +190,7 @@ SEQUENCE:2
189
190
  UID:foobar
190
191
  RRULE:FREQ=DAILY
191
192
  DTSTART:20140724T000000Z
193
+ DTEND:20140724T010000Z
192
194
  ATTENDEE:mailto:foo@example.org
193
195
  ORGANIZER:mailto:bar@example.org
194
196
  END:VEVENT
@@ -196,6 +198,7 @@ BEGIN:VEVENT
196
198
  SEQUENCE:2
197
199
  UID:foobar
198
200
  DTSTART:20140725T000000Z
201
+ DTEND:20140725T010000Z
199
202
  ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org
200
203
  ORGANIZER:mailto:bar@example.org
201
204
  RECURRENCE-ID:20140725T000000Z
@@ -231,6 +234,7 @@ SEQUENCE:2
231
234
  UID:foobar
232
235
  RRULE:FREQ=DAILY
233
236
  DTSTART;TZID=America/Toronto:20140724T000000
237
+ DTEND;TZID=America/Toronto:20140724T010000
234
238
  ATTENDEE:mailto:foo@example.org
235
239
  ORGANIZER:mailto:bar@example.org
236
240
  END:VEVENT
@@ -245,6 +249,7 @@ SEQUENCE:2
245
249
  UID:foobar
246
250
  RRULE:FREQ=DAILY
247
251
  DTSTART;TZID=America/Toronto:20140724T000000
252
+ DTEND;TZID=America/Toronto:20140724T010000
248
253
  ATTENDEE:mailto:foo@example.org
249
254
  ORGANIZER:mailto:bar@example.org
250
255
  END:VEVENT
@@ -252,6 +257,7 @@ BEGIN:VEVENT
252
257
  SEQUENCE:2
253
258
  UID:foobar
254
259
  DTSTART;TZID=America/Toronto:20140725T000000
260
+ DTEND;TZID=America/Toronto:20140725T010000
255
261
  ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo@example.org
256
262
  ORGANIZER:mailto:bar@example.org
257
263
  RECURRENCE-ID;TZID=America/Toronto:20140725T000000
@@ -290,6 +296,7 @@ SEQUENCE:2
290
296
  UID:foobar
291
297
  RRULE:FREQ=DAILY
292
298
  DTSTART:20140724T000000Z
299
+ DTEND:20140724T010000Z
293
300
  ORGANIZER:mailto:bar@example.org
294
301
  END:VEVENT
295
302
  END:VCALENDAR
@@ -303,12 +310,14 @@ SEQUENCE:2
303
310
  UID:foobar
304
311
  RRULE:FREQ=DAILY
305
312
  DTSTART:20140724T000000Z
313
+ DTEND:20140724T010000Z
306
314
  ORGANIZER:mailto:bar@example.org
307
315
  END:VEVENT
308
316
  BEGIN:VEVENT
309
317
  SEQUENCE:2
310
318
  UID:foobar
311
319
  DTSTART:20140725T000000Z
320
+ DTEND:20140725T010000Z
312
321
  ORGANIZER:mailto:bar@example.org
313
322
  RECURRENCE-ID:20140725T000000Z
314
323
  ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher@example.org
@@ -347,6 +356,7 @@ SEQUENCE:2
347
356
  UID:foobar
348
357
  RRULE:FREQ=DAILY
349
358
  DTSTART:20140724T000000Z
359
+ DTEND:20140724T010000Z
350
360
  RECURRENCE-ID:20140724T000000Z
351
361
  ORGANIZER:mailto:bar@example.org
352
362
  END:VEVENT
@@ -18,7 +18,7 @@ module Tilia
18
18
  if key == 'message'
19
19
  assert_v_obj_equals(val, message.message.serialize)
20
20
  else
21
- actual = message.send(key)
21
+ actual = message.send(key.underscore)
22
22
  assert_equal(val, val.is_a?(String) ? actual.to_s : actual)
23
23
  end
24
24
  end
@@ -17,6 +17,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
17
17
  ATTENDEE;CN=One:mailto:one@example.org
18
18
  ATTENDEE;CN=Two:mailto:two@example.org
19
19
  DTSTART:20140716T120000Z
20
+ DTEND:20140716T130000Z
20
21
  END:VEVENT
21
22
  END:VCALENDAR
22
23
  ICS
@@ -33,6 +34,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
33
34
  ATTENDEE;CN=Two:mailto:two@example.org
34
35
  ATTENDEE;CN=Three:mailto:three@example.org
35
36
  DTSTART:20140716T120000Z
37
+ DTEND:20140716T130000Z
36
38
  END:VEVENT
37
39
  END:VCALENDAR
38
40
  ICS
@@ -57,9 +59,11 @@ CALSCALE:GREGORIAN
57
59
  METHOD:CANCEL
58
60
  BEGIN:VEVENT
59
61
  UID:foobar
62
+ DTSTAMP:**ANY**
60
63
  SEQUENCE:2
61
64
  SUMMARY:foo
62
65
  DTSTART:20140716T120000Z
66
+ DTEND:20140716T130000Z
63
67
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
64
68
  ATTENDEE;CN=One:mailto:one@example.org
65
69
  END:VEVENT
@@ -90,6 +94,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
90
94
  ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
91
95
  ATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:three@example.org
92
96
  DTSTART:20140716T120000Z
97
+ DTEND:20140716T130000Z
93
98
  END:VEVENT
94
99
  END:VCALENDAR
95
100
  ICS
@@ -119,6 +124,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
119
124
  ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
120
125
  ATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:three@example.org
121
126
  DTSTART:20140716T120000Z
127
+ DTEND:20140716T130000Z
122
128
  END:VEVENT
123
129
  END:VCALENDAR
124
130
  ICS
@@ -137,6 +143,7 @@ BEGIN:VEVENT
137
143
  UID:foobar
138
144
  SEQUENCE:1
139
145
  DTSTART:20140716T120000Z
146
+ DTEND:20140716T130000Z
140
147
  END:VEVENT
141
148
  END:VCALENDAR
142
149
  ICS
@@ -150,6 +157,7 @@ SEQUENCE:2
150
157
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
151
158
  ATTENDEE;CN=One:mailto:one@example.org
152
159
  DTSTART:20140716T120000Z
160
+ DTEND:20140716T130000Z
153
161
  END:VEVENT
154
162
  END:VCALENDAR
155
163
  ICS
@@ -177,6 +185,7 @@ SEQUENCE:2
177
185
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
178
186
  ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
179
187
  DTSTART:20140716T120000Z
188
+ DTEND:20140716T130000Z
180
189
  END:VEVENT
181
190
  END:VCALENDAR
182
191
  ICS
@@ -196,6 +205,7 @@ SEQUENCE:2
196
205
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
197
206
  ATTENDEE;CN=One:mailto:one@example.org
198
207
  DTSTART:20140716T120000Z
208
+ DTEND:20140716T130000Z
199
209
  END:VEVENT
200
210
  END:VCALENDAR
201
211
  ICS
@@ -207,6 +217,7 @@ BEGIN:VEVENT
207
217
  UID:foobar
208
218
  SEQUENCE:1
209
219
  DTSTART:20140716T120000Z
220
+ DTEND:20140716T130000Z
210
221
  END:VEVENT
211
222
  END:VCALENDAR
212
223
  ICS
@@ -226,8 +237,10 @@ CALSCALE:GREGORIAN
226
237
  METHOD:CANCEL
227
238
  BEGIN:VEVENT
228
239
  UID:foobar
240
+ DTSTAMP:**ANY**
229
241
  SEQUENCE:1
230
242
  DTSTART:20140716T120000Z
243
+ DTEND:20140716T130000Z
231
244
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
232
245
  ATTENDEE;CN=One:mailto:one@example.org
233
246
  END:VEVENT
@@ -247,6 +260,7 @@ BEGIN:VEVENT
247
260
  UID:foobar
248
261
  SEQUENCE:1
249
262
  DTSTART:20140716T120000Z
263
+ DTEND:20140716T130000Z
250
264
  END:VEVENT
251
265
  END:VCALENDAR
252
266
  ICS
@@ -258,6 +272,7 @@ BEGIN:VEVENT
258
272
  UID:foobar
259
273
  SEQUENCE:2
260
274
  DTSTART:20140716T120000Z
275
+ DTEND:20140716T130000Z
261
276
  END:VEVENT
262
277
  END:VCALENDAR
263
278
  ICS
@@ -276,6 +291,7 @@ SEQUENCE:1
276
291
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
277
292
  ATTENDEE;CN=One:mailto:one@example.org
278
293
  DTSTART;TZID=America/Toronto:20140716T120000
294
+ DTEND;TZID=America/Toronto:20140716T130000
279
295
  RRULE:FREQ=WEEKLY
280
296
  END:VEVENT
281
297
  END:VCALENDAR
@@ -290,6 +306,7 @@ SEQUENCE:2
290
306
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
291
307
  ATTENDEE;CN=One:mailto:one@example.org
292
308
  DTSTART;TZID=America/Toronto:20140716T120000
309
+ DTEND;TZID=America/Toronto:20140716T130000
293
310
  RRULE:FREQ=WEEKLY
294
311
  EXDATE;TZID=America/Toronto:20140724T120000
295
312
  END:VEVENT
@@ -319,6 +336,7 @@ SEQUENCE:2
319
336
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
320
337
  ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
321
338
  DTSTART;TZID=America/Toronto:20140716T120000
339
+ DTEND;TZID=America/Toronto:20140716T130000
322
340
  RRULE:FREQ=WEEKLY
323
341
  EXDATE;TZID=America/Toronto:20140724T120000
324
342
  END:VEVENT
@@ -347,6 +365,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
347
365
  ATTENDEE;CN=One:mailto:one@example.org
348
366
  ATTENDEE;CN=Two:mailto:two@example.org
349
367
  DTSTART:20140716T120000Z
368
+ DTEND:20140716T130000Z
350
369
  END:VEVENT
351
370
  END:VCALENDAR
352
371
  ICS
@@ -363,6 +382,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
363
382
  ATTENDEE;CN=Two:mailto:two@example.org
364
383
  ATTENDEE;CN=Three:mailto:three@example.org
365
384
  DTSTART:20140716T120000Z
385
+ DTEND:20140716T130000Z
366
386
  END:VEVENT
367
387
  END:VCALENDAR
368
388
  ICS
@@ -387,8 +407,10 @@ CALSCALE:GREGORIAN
387
407
  METHOD:CANCEL
388
408
  BEGIN:VEVENT
389
409
  UID:foobar
410
+ DTSTAMP:**ANY**
390
411
  SEQUENCE:2
391
412
  DTSTART:20140716T120000Z
413
+ DTEND:20140716T130000Z
392
414
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
393
415
  ATTENDEE;CN=One:mailto:one@example.org
394
416
  END:VEVENT
@@ -419,6 +441,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
419
441
  ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
420
442
  ATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:three@example.org
421
443
  DTSTART:20140716T120000Z
444
+ DTEND:20140716T130000Z
422
445
  END:VEVENT
423
446
  END:VCALENDAR
424
447
  ICS
@@ -447,6 +470,7 @@ ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
447
470
  ATTENDEE;CN=Two;PARTSTAT=NEEDS-ACTION:mailto:two@example.org
448
471
  ATTENDEE;CN=Three;PARTSTAT=NEEDS-ACTION:mailto:three@example.org
449
472
  DTSTART:20140716T120000Z
473
+ DTEND:20140716T130000Z
450
474
  END:VEVENT
451
475
  END:VCALENDAR
452
476
  ICS
@@ -467,6 +491,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
467
491
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
468
492
  ATTENDEE;CN=One:mailto:one@example.org
469
493
  DTSTART:20140716T120000Z
494
+ DTEND:20140716T130000Z
470
495
  END:VEVENT
471
496
  END:VCALENDAR
472
497
  ICS
@@ -481,6 +506,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
481
506
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
482
507
  ATTENDEE;CN=One:mailto:one@example.org
483
508
  DTSTART:20140716T120000Z
509
+ DTEND:20140716T130000Z
484
510
  END:VEVENT
485
511
  END:VCALENDAR
486
512
  ICS
@@ -510,6 +536,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
510
536
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
511
537
  ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
512
538
  DTSTART:20140716T120000Z
539
+ DTEND:20140716T130000Z
513
540
  END:VEVENT
514
541
  END:VCALENDAR
515
542
  ICS
@@ -530,6 +557,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
530
557
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
531
558
  ATTENDEE;CN=One:mailto:one@example.org
532
559
  DTSTART:20140716T120000Z
560
+ DTEND:20140716T130000Z
533
561
  END:VEVENT
534
562
  END:VCALENDAR
535
563
  ICS
@@ -544,6 +572,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
544
572
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
545
573
  ATTENDEE;SCHEDULE-FORCE-SEND=REQUEST;CN=One:mailto:one@example.org
546
574
  DTSTART:20140716T120000Z
575
+ DTEND:20140716T130000Z
547
576
  END:VEVENT
548
577
  END:VCALENDAR
549
578
  ICS
@@ -573,6 +602,7 @@ ORGANIZER;CN=Strunk:mailto:strunk@example.org
573
602
  ATTENDEE;CN=Strunk;PARTSTAT=ACCEPTED:mailto:strunk@example.org
574
603
  ATTENDEE;CN=One;PARTSTAT=NEEDS-ACTION:mailto:one@example.org
575
604
  DTSTART:20140716T120000Z
605
+ DTEND:20140716T130000Z
576
606
  END:VEVENT
577
607
  END:VCALENDAR
578
608
  ICS
@@ -595,6 +625,7 @@ ATTENDEE;CN=Strunk:mailto:strunk@example.org
595
625
  ATTENDEE;CN=One:mailto:one@example.org
596
626
  ATTENDEE;CN=Two:mailto:two@example.org
597
627
  DTSTART:20140716T120000Z
628
+ DTEND:20140716T130000Z
598
629
  END:VEVENT
599
630
  END:VCALENDAR
600
631
  ICS
@@ -607,6 +638,7 @@ UID:foobar
607
638
  SEQUENCE:2
608
639
  SUMMARY:foo
609
640
  DTSTART:20140716T120000Z
641
+ DTEND:20140716T130000Z
610
642
  END:VEVENT
611
643
  END:VCALENDAR
612
644
  ICS
@@ -631,9 +663,11 @@ CALSCALE:GREGORIAN
631
663
  METHOD:CANCEL
632
664
  BEGIN:VEVENT
633
665
  UID:foobar
666
+ DTSTAMP:**ANY**
634
667
  SEQUENCE:2
635
668
  SUMMARY:foo
636
669
  DTSTART:20140716T120000Z
670
+ DTEND:20140716T130000Z
637
671
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
638
672
  ATTENDEE;CN=One:mailto:one@example.org
639
673
  END:VEVENT
@@ -658,9 +692,11 @@ CALSCALE:GREGORIAN
658
692
  METHOD:CANCEL
659
693
  BEGIN:VEVENT
660
694
  UID:foobar
695
+ DTSTAMP:**ANY**
661
696
  SEQUENCE:2
662
697
  SUMMARY:foo
663
698
  DTSTART:20140716T120000Z
699
+ DTEND:20140716T130000Z
664
700
  ORGANIZER;CN=Strunk:mailto:strunk@example.org
665
701
  ATTENDEE;CN=Two:mailto:two@example.org
666
702
  END:VEVENT
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ module Tilia
4
+ module VObject
5
+ # This test is created to handle the issues brought forward by issue 40.
6
+ #
7
+ # https://github.com/fruux/sabre-vobject/issues/40
8
+ class Issue259Test < Minitest::Test
9
+ def test_parsing_jcal_with_until
10
+ jcal_with_until = '["vcalendar",[],[["vevent",[["uid",{},"text","dd1f7d29"],["organizer",{"cn":"robert"},"cal-address","mailto:robert@robert.com"],["dtstart",{"tzid":"Europe/Berlin"},"date-time","2015-10-21T12:00:00"],["dtend",{"tzid":"Europe/Berlin"},"date-time","2015-10-21T13:00:00"],["transp",{},"text","OPAQUE"],["rrule",{},"recur",{"freq":"MONTHLY","until":"2016-01-01T22:00:00Z"}]],[]]]]'
11
+ parser = Parser::Json.new
12
+ parser.input = jcal_with_until
13
+
14
+ vcalendar = parser.parse
15
+ event_as_array = vcalendar.select('VEVENT')
16
+ event = event_as_array.first
17
+ rrule_as_array = event.select('RRULE')
18
+ rrule = rrule_as_array.first
19
+ refute_nil(rrule)
20
+ assert_equal(rrule.value, 'FREQ=MONTHLY;UNTIL=20160101T220000Z')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -10,9 +10,11 @@ module Tilia
10
10
  card = Tilia::VObject::Component::VCard.new
11
11
  card.add('N', ['van der Harten', ['Rene', 'J.'], '', 'Sir', 'R.D.O.N.'], 'SORT-AS' => ['Harten', 'Rene'])
12
12
 
13
+ card.delete('UID')
14
+
13
15
  expected = [
14
16
  'BEGIN:VCARD',
15
- 'VERSION:3.0',
17
+ 'VERSION:4.0',
16
18
  "PRODID:-//Tilia//Tilia VObject #{Tilia::VObject::Version::VERSION}//EN",
17
19
  'N;SORT-AS=Harten,Rene:van der Harten;Rene,J.;;Sir;R.D.O.N.',
18
20
  'END:VCARD',
@@ -9,19 +9,22 @@ module Tilia
9
9
 
10
10
  event = cal.add(
11
11
  'VEVENT',
12
- 'UID' => 'foo',
13
- 'DTSTART' => Time.zone.parse('2013-05-26 18:10:00Z'),
14
- 'DURATION' => 'P1D',
15
- 'CATEGORIES' => ['home', 'testing'],
16
- 'CREATED' => Time.zone.parse('2013-05-26 18:10:00Z'),
12
+ {
13
+ 'UID' => 'foo',
14
+ 'DTSTART' => Time.zone.parse('2013-05-26 18:10:00Z'),
15
+ 'DURATION' => 'P1D',
16
+ 'CATEGORIES' => ['home', 'testing'],
17
+ 'CREATED' => Time.zone.parse('2013-05-26 18:10:00Z'),
17
18
 
18
- 'ATTENDEE' => 'mailto:armin@example.org',
19
- 'GEO' => [51.96668, 7.61876],
20
- 'SEQUENCE' => 5,
21
- 'FREEBUSY' => ['20130526T210213Z/PT1H', '20130626T120000Z/20130626T130000Z'],
22
- 'URL' => 'http://example.org/',
23
- 'TZOFFSETFROM' => '+0500',
24
- 'RRULE' => { 'FREQ' => 'WEEKLY', 'BYDAY' => ['MO', 'TU'] }
19
+ 'ATTENDEE' => 'mailto:armin@example.org',
20
+ 'GEO' => [51.96668, 7.61876],
21
+ 'SEQUENCE' => 5,
22
+ 'FREEBUSY' => ['20130526T210213Z/PT1H', '20130626T120000Z/20130626T130000Z'],
23
+ 'URL' => 'http://example.org/',
24
+ 'TZOFFSETFROM' => '+0500',
25
+ 'RRULE' => { 'FREQ' => 'WEEKLY', 'BYDAY' => ['MO', 'TU'] }
26
+ },
27
+ false
25
28
  )
26
29
 
27
30
  # Modifying DTSTART to be a date-only.
@@ -166,9 +166,9 @@ item1.TEL:+1 555 123456
166
166
  item1.X-AB-LABEL:Walkie Talkie
167
167
  ADR:;;My Street,Left Side,Second Shack;Hometown;PA;18252;U.S.A
168
168
  X-TRUNCATED;VALUE=DATE:--12-25
169
- X-TIME-LOCAL;VALUE=TIME:12:30:00
170
- X-TIME-UTC;VALUE=TIME:12:30:00Z
171
- X-TIME-OFFSET;VALUE=TIME:12:30:00-08:00
169
+ X-TIME-LOCAL;VALUE=TIME:123000
170
+ X-TIME-UTC;VALUE=TIME:123000Z
171
+ X-TIME-OFFSET;VALUE=TIME:123000-0800
172
172
  X-TIME-REDUCED;VALUE=TIME:23
173
173
  X-TIME-TRUNCATED;VALUE=TIME:--30
174
174
  X-KARMA-POINTS;VALUE=INTEGER:42
@@ -316,11 +316,11 @@ ATTENDEE;CN=Dominik;PARTSTAT=DECLINED:mailto:dominik@example.org
316
316
  GEO:51.96668;7.61876
317
317
  SEQUENCE:5
318
318
  FREEBUSY:20130526T210213/PT1H,20130626T120000/20130626T130000
319
- URL:http://example.org/
319
+ URL;VALUE=URI:http://example.org/
320
320
  TZOFFSETFROM:+0500
321
321
  RRULE:FREQ=WEEKLY;BYDAY=MO,TU
322
322
  X-BOOL;VALUE=BOOLEAN:TRUE
323
- X-TIME;VALUE=TIME:08:00:00
323
+ X-TIME;VALUE=TIME:080000
324
324
  REQUEST-STATUS:2.0;Success
325
325
  REQUEST-STATUS:3.7;Invalid Calendar User;ATTENDEE:mailto:jsmith@example.org
326
326
  BEGIN:VALARM
@@ -9,6 +9,115 @@ module Tilia
9
9
  mime_dir = Tilia::VObject::Parser::MimeDir.new
10
10
  assert_raises(Tilia::VObject::ParseException) { mime_dir.parse(File.open(__FILE__)) }
11
11
  end
12
+
13
+ def test_decode_latin1
14
+ vcard = <<VCF
15
+ BEGIN:VCARD
16
+ VERSION:3.0
17
+ FN:umlaut u - \xFC
18
+ END:VCARD
19
+ VCF
20
+
21
+ mime_dir = Parser::MimeDir.new
22
+ mime_dir.charset = 'ISO-8859-1'
23
+ vcard = mime_dir.parse(vcard)
24
+ assert_equal("umlaut u - \xC3\xBC", vcard['FN'].value)
25
+ end
26
+
27
+ def test_decode_inline_latin1
28
+ vcard = <<VCF
29
+ BEGIN:VCARD
30
+ VERSION:2.1
31
+ FN;CHARSET=ISO-8859-1:umlaut u - \xFC
32
+ END:VCARD
33
+ VCF
34
+
35
+ mime_dir = Parser::MimeDir.new
36
+ vcard = mime_dir.parse(vcard)
37
+ assert_equal("umlaut u - \xC3\xBC", vcard['FN'].value)
38
+ end
39
+
40
+ def test_ignore_charset_v_card30
41
+ vcard = <<VCF
42
+ BEGIN:VCARD
43
+ VERSION:3.0
44
+ FN;CHARSET=unknown:foo-bar - \xFC
45
+ END:VCARD
46
+ VCF
47
+
48
+ mime_dir = Parser::MimeDir.new
49
+ vcard = mime_dir.parse(vcard)
50
+
51
+ # encode(u8, u8) is noop but sets encoding to utf-8, that's what the other string is
52
+ assert_equal("foo-bar - \xFC", vcard['FN'].value.encode('UTF-8', 'UTF-8'))
53
+ end
54
+
55
+ def test_dont_decode_latin1
56
+ vcard = <<VCF
57
+ BEGIN:VCARD
58
+ VERSION:4.0
59
+ FN:umlaut u - \xFC
60
+ END:VCARD
61
+ VCF
62
+
63
+ mime_dir = Parser::MimeDir.new
64
+ vcard = mime_dir.parse(vcard)
65
+ # This basically tests that we don't touch the input string if
66
+ # the encoding was set to UTF-8. The result is actually invalid
67
+ # and the validator should report this, but it tests effectively
68
+ # that we pass through the string byte-by-byte.
69
+
70
+ # encode(u8, u8) is noop but sets encoding to utf-8, that's what the other string is
71
+ assert_equal("umlaut u - \xFC", vcard['FN'].value.encode('UTF-8', 'UTF-8'))
72
+ end
73
+
74
+ def test_decode_unsupported_charset
75
+ mime_dir = Parser::MimeDir.new
76
+ assert_raises(ArgumentError) do
77
+ mime_dir.charset = 'foobar'
78
+ end
79
+ end
80
+
81
+ def test_decode_unsupported_inline_charset
82
+ vcard = <<VCF
83
+ BEGIN:VCARD
84
+ VERSION:2.1
85
+ FN;CHARSET=foobar:nothing
86
+ END:VCARD
87
+ VCF
88
+
89
+ mime_dir = Parser::MimeDir.new
90
+ assert_raises(ParseException) do
91
+ mime_dir.parse(vcard)
92
+ end
93
+ end
94
+
95
+ def test_decode_windows1252
96
+ vcard = <<VCF
97
+ BEGIN:VCARD
98
+ VERSION:3.0
99
+ FN:Euro \x80
100
+ END:VCARD
101
+ VCF
102
+
103
+ mime_dir = Parser::MimeDir.new
104
+ mime_dir.charset = 'Windows-1252'
105
+ vcard = mime_dir.parse(vcard)
106
+ assert_equal("Euro \xE2\x82\xAC", vcard['FN'].value)
107
+ end
108
+
109
+ def test_decode_windows1252_inline
110
+ vcard = <<VCF
111
+ BEGIN:VCARD
112
+ VERSION:2.1
113
+ FN;CHARSET=Windows-1252:Euro \x80
114
+ END:VCARD
115
+ VCF
116
+
117
+ mime_dir = Parser::MimeDir.new
118
+ vcard = mime_dir.parse(vcard)
119
+ assert_equal("Euro \xE2\x82\xAC", vcard['FN'].value)
120
+ end
12
121
  end
13
122
  end
14
123
  end