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
@@ -1,5 +1,6 @@
1
1
  module Tilia
2
2
  module VObject
3
+ # Namespace of the shipped time zone data
3
4
  module TimeZoneData
4
5
  require 'tilia/v_object/time_zone_data/exchange_zones'
5
6
  require 'tilia/v_object/time_zone_data/lotus_zones'
@@ -104,10 +104,10 @@ module Tilia
104
104
  # Alternatively, if fail_if_uncertain is set to true, it will throw an
105
105
  # exception if we cannot accurately determine the timezone.
106
106
  #
107
- # @param string tzid
108
- # @param Sabre\VObject\Component vcalendar
107
+ # @param [String] tzid
108
+ # @param [Component] vcalendar
109
109
  #
110
- # @return DateTimeZone
110
+ # @return [ActiveSupport::TimeZone]
111
111
  def self.time_zone(tzid, vcalendar = nil, fail_if_uncertain = false)
112
112
  # First we will just see if the tzid is a support timezone identifier.
113
113
  #
@@ -198,9 +198,9 @@ module Tilia
198
198
  return @map if @map
199
199
 
200
200
  @map = TimeZoneData::PhpZones.list
201
- @map.merge! TimeZoneData::ExchangeZones.list
202
- @map.merge! TimeZoneData::LotusZones.list
203
- @map.merge! TimeZoneData::WindowsZones.list
201
+ @map.merge!(TimeZoneData::ExchangeZones.list)
202
+ @map.merge!(TimeZoneData::LotusZones.list)
203
+ @map.merge!(TimeZoneData::WindowsZones.list)
204
204
  @map
205
205
  end
206
206
 
@@ -12,7 +12,7 @@ module Tilia
12
12
  #
13
13
  # @see http://www.php.net/manual/en/function.uniqid.php#94959
14
14
  #
15
- # @return string
15
+ # @return [String]
16
16
  def self.uuid
17
17
  format(
18
18
  '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
@@ -41,8 +41,8 @@ module Tilia
41
41
 
42
42
  # Checks if a string is a valid UUID.
43
43
  #
44
- # @param string $uuid
45
- # @return bool
44
+ # @param [String] $uuid
45
+ # @return [Boolean]
46
46
  def self.validate_uuid(uuid)
47
47
  uuid =~ /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i
48
48
  end
@@ -17,8 +17,8 @@ module Tilia
17
17
  #
18
18
  # If input and output version are identical, a clone is returned.
19
19
  #
20
- # @param Component\VCard input
21
- # @param int target_version
20
+ # @param [Component::VCard] input
21
+ # @param [Fixnum] target_version
22
22
  def convert(input, target_version)
23
23
  input_version = input.document_type
24
24
  return input.dup if input_version == target_version
@@ -34,6 +34,9 @@ module Tilia
34
34
 
35
35
  output = Tilia::VObject::Component::VCard.new('VERSION' => new_version)
36
36
 
37
+ # We might have generated a default UID. Remove it!
38
+ output.delete('UID')
39
+
37
40
  input.children.each do |property|
38
41
  convert_property(input, output, property, target_version)
39
42
  end
@@ -45,12 +48,12 @@ module Tilia
45
48
 
46
49
  # Handles conversion of a single property.
47
50
  #
48
- # @param Component\VCard input
49
- # @param Component\VCard output
50
- # @param Property property
51
- # @param int target_version
51
+ # @param [Component::VCard] input
52
+ # @param [Component::VCard] output
53
+ # @param [Property] property
54
+ # @param [Fixnum] target_version
52
55
  #
53
- # @return void
56
+ # @return [void]
54
57
  def convert_property(input, output, property, target_version)
55
58
  # Skipping these, those are automatically added.
56
59
  return nil if %w(VERSION PRODID).include?(property.name)
@@ -204,12 +207,12 @@ module Tilia
204
207
  #
205
208
  # vCard 4.0 no longer supports BINARY properties.
206
209
  #
207
- # @param Component\VCard output
208
- # @param Tilia::VObject::Property::Uri property The input property.
209
- # @param parameters List of parameters that will eventually be added to
210
- # the new property.
210
+ # @param [Component::VCard] output
211
+ # @param [Tilia::VObject::Property::Uri] property The input property.
212
+ # @param [Hash] parameters List of parameters that will eventually be added to
213
+ # the new property.
211
214
  #
212
- # @return Tilia::VObject::Property::Uri
215
+ # @return [Tilia::VObject::Property::Uri]
213
216
  def convert_binary_to_uri(output, new_property, parameters)
214
217
  value = new_property.value
215
218
  new_property = output.create_property(
@@ -251,10 +254,10 @@ module Tilia
251
254
  # be valid in vCard 3.0 as well, we should convert those to BINARY if
252
255
  # possible, to improve compatibility.
253
256
  #
254
- # @param Component\VCard output
255
- # @param Tilia::VObject::Property::Uri property The input property.
257
+ # @param [Component::VCard] output
258
+ # @param [Property::Uri] property The input property.
256
259
  #
257
- # @return Tilia::VObject::Property::Binary|null
260
+ # @return [Property::Binary, nil]
258
261
  def convert_uri_to_binary(output, new_property)
259
262
  value = new_property.value
260
263
 
@@ -291,10 +294,10 @@ module Tilia
291
294
 
292
295
  # Adds parameters to a new property for vCard 4.0.
293
296
  #
294
- # @param Property new_property
295
- # @param array parameters
297
+ # @param [Property] new_property
298
+ # @param [Hash] parameters
296
299
  #
297
- # @return void
300
+ # @return [void]
298
301
  def convert_parameters40(new_property, parameters)
299
302
  # Adding all parameters.
300
303
  parameters.each do |_, param|
@@ -322,10 +325,10 @@ module Tilia
322
325
 
323
326
  # Adds parameters to a new property for vCard 3.0.
324
327
  #
325
- # @param Property new_property
326
- # @param array parameters
328
+ # @param [Property] new_property
329
+ # @param [Hash] parameters
327
330
  #
328
- # @return void
331
+ # @return [void]
329
332
  def convert_parameters30(new_property, parameters)
330
333
  # Adding all parameters.
331
334
  parameters.each do |_, param|
@@ -3,7 +3,7 @@ module Tilia
3
3
  # This class contains the version number for the VObject package.
4
4
  class Version
5
5
  # Full version number.
6
- VERSION = '4.0.0-alpha5'
6
+ VERSION = '4.0.2'.freeze
7
7
  end
8
8
  end
9
9
  end
@@ -8,28 +8,28 @@ module Tilia
8
8
  class Writer
9
9
  # Serializes a vCard or iCalendar object.
10
10
  #
11
- # @param Component component
11
+ # @param [Component] component
12
12
  #
13
- # @return string
13
+ # @return [String]
14
14
  def self.write(component)
15
15
  component.serialize
16
16
  end
17
17
 
18
18
  # Serializes a jCal or jCard object.
19
19
  #
20
- # @param Component component
21
- # @param int options
20
+ # @param [Component] component
21
+ # @param [Fixnum] options
22
22
  #
23
- # @return string
23
+ # @return [String]
24
24
  def self.write_json(component)
25
25
  component.json_serialize.to_json
26
26
  end
27
27
 
28
28
  # Serializes a xCal or xCard object.
29
29
  #
30
- # @param Component component
30
+ # @param [Component] component
31
31
  #
32
- # @return string
32
+ # @return [String]
33
33
  def self.write_xml(component)
34
34
  writer = Tilia::Xml::Writer.new
35
35
  writer.open_memory
data/test/test_helper.rb CHANGED
@@ -16,9 +16,9 @@ require 'minitest/autorun'
16
16
  # #
17
17
  # # CALSCALE will automatically get removed if it's set to GREGORIAN.
18
18
  # #
19
- # # @param resource|string|Component expected
20
- # # @param resource|string|Component actual
21
- # # @param string message
19
+ # # @param [resource|string|Component] expected
20
+ # # @param [resource|string|Component] actual
21
+ # # @param [String] message
22
22
  # self.obj = lambda do |input|
23
23
  # if input.respond_to?(:readlines)
24
24
  # input = input.readlines.join("\n")
@@ -20,6 +20,8 @@ VCF
20
20
  BEGIN:VCALENDAR
21
21
  VERSION:2.0
22
22
  BEGIN:VEVENT
23
+ UID:**ANY**
24
+ DTSTAMP:**ANY**
23
25
  SUMMARY:Forrest Gump's Birthday
24
26
  DTSTART;VALUE=DATE:19850407
25
27
  RRULE:FREQ=YEARLY
@@ -63,6 +65,8 @@ VCF
63
65
  BEGIN:VCALENDAR
64
66
  VERSION:2.0
65
67
  BEGIN:VEVENT
68
+ UID:**ANY**
69
+ DTSTAMP:**ANY**
66
70
  SUMMARY:Forrest Gump's Birthday
67
71
  DTSTART;VALUE=DATE:19850407
68
72
  RRULE:FREQ=YEARLY
@@ -70,6 +74,8 @@ TRANSP:TRANSPARENT
70
74
  X-SABRE-BDAY;X-SABRE-VCARD-UID=foo;X-SABRE-VCARD-FN=Forrest Gump:BDAY
71
75
  END:VEVENT
72
76
  BEGIN:VEVENT
77
+ UID:**ANY**
78
+ DTSTAMP:**ANY**
73
79
  SUMMARY:John Doe's Birthday
74
80
  DTSTART;VALUE=DATE:19820210
75
81
  RRULE:FREQ=YEARLY
@@ -114,6 +120,8 @@ VCF
114
120
  BEGIN:VCALENDAR
115
121
  VERSION:2.0
116
122
  BEGIN:VEVENT
123
+ UID:**ANY**
124
+ DTSTAMP:**ANY**
117
125
  SUMMARY:Forrest Gump's Birthday
118
126
  DTSTART;VALUE=DATE:19850407
119
127
  RRULE:FREQ=YEARLY
@@ -121,6 +129,8 @@ TRANSP:TRANSPARENT
121
129
  X-SABRE-BDAY;X-SABRE-VCARD-UID=foo;X-SABRE-VCARD-FN=Forrest Gump:BDAY
122
130
  END:VEVENT
123
131
  BEGIN:VEVENT
132
+ UID:**ANY**
133
+ DTSTAMP:**ANY**
124
134
  SUMMARY:John Doe's Birthday
125
135
  DTSTART;VALUE=DATE:19820210
126
136
  RRULE:FREQ=YEARLY
@@ -154,6 +164,8 @@ VCF
154
164
  BEGIN:VCALENDAR
155
165
  VERSION:2.0
156
166
  BEGIN:VEVENT
167
+ UID:**ANY**
168
+ DTSTAMP:**ANY**
157
169
  SUMMARY:Forrest Gump's Birthday
158
170
  DTSTART;VALUE=DATE:19850407
159
171
  RRULE:FREQ=YEARLY
@@ -199,6 +211,8 @@ VCF
199
211
  BEGIN:VCALENDAR
200
212
  VERSION:2.0
201
213
  BEGIN:VEVENT
214
+ UID:**ANY**
215
+ DTSTAMP:**ANY**
202
216
  SUMMARY:Forrest Gump's Birthday
203
217
  DTSTART;VALUE=DATE:19850407
204
218
  RRULE:FREQ=YEARLY
@@ -206,6 +220,8 @@ TRANSP:TRANSPARENT
206
220
  X-SABRE-BDAY;X-SABRE-VCARD-UID=foo;X-SABRE-VCARD-FN=Forrest Gump:BDAY
207
221
  END:VEVENT
208
222
  BEGIN:VEVENT
223
+ UID:**ANY**
224
+ DTSTAMP:**ANY**
209
225
  SUMMARY:John Doe's Birthday
210
226
  DTSTART;VALUE=DATE:19820210
211
227
  RRULE:FREQ=YEARLY
@@ -237,6 +253,8 @@ VCF
237
253
  BEGIN:VCALENDAR
238
254
  VERSION:2.0
239
255
  BEGIN:VEVENT
256
+ UID:**ANY**
257
+ DTSTAMP:**ANY**
240
258
  SUMMARY:Forrest Gump's Birthday
241
259
  DTSTART;VALUE=DATE:20000407
242
260
  RRULE:FREQ=YEARLY
@@ -268,6 +286,8 @@ VCF
268
286
  BEGIN:VCALENDAR
269
287
  VERSION:2.0
270
288
  BEGIN:VEVENT
289
+ UID:**ANY**
290
+ DTSTAMP:**ANY**
271
291
  SUMMARY:Forrest Gump's Birthday
272
292
  DTSTART;VALUE=DATE:20000407
273
293
  RRULE:FREQ=YEARLY
@@ -346,6 +366,8 @@ VCF
346
366
  BEGIN:VCALENDAR
347
367
  VERSION:2.0
348
368
  BEGIN:VEVENT
369
+ UID:**ANY**
370
+ DTSTAMP:**ANY**
349
371
  SUMMARY:Forrest Gump's Geburtstag
350
372
  DTSTART;VALUE=DATE:19850407
351
373
  RRULE:FREQ=YEARLY
@@ -128,7 +128,9 @@ module Tilia
128
128
  vjournal = calendar.create_component('VJOURNAL')
129
129
  vjournal.add(valarm)
130
130
 
131
- assert_raises(RuntimeError) { valarm.in_time_range?(Time.zone.parse('2012-02-25 01:00:00'), Time.zone.parse('2012-03-05 01:00:00')) }
131
+ assert_raises(InvalidDataException) do
132
+ valarm.in_time_range?(Time.zone.parse('2012-02-25 01:00:00'), Time.zone.parse('2012-03-05 01:00:00'))
133
+ end
132
134
  end
133
135
 
134
136
  # This bug was found and reported on the mailing list.
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Tilia
4
4
  module VObject
5
- class VCalendarTest < Minitest::Test
5
+ class VCalendarTest < TestCase
6
6
  def assert_validate(ics, options, expected_level, expected_message = nil)
7
7
  vcal = Tilia::VObject::Reader.read(ics)
8
8
  result = vcal.validate(options)
@@ -96,6 +96,40 @@ END:VCALENDAR
96
96
 
97
97
  tests << [input, output]
98
98
 
99
+ # Removing timezone info from sub-components. See Issue #278
100
+ input = 'BEGIN:VCALENDAR
101
+ CALSCALE:GREGORIAN
102
+ VERSION:2.0
103
+ BEGIN:VTIMEZONE
104
+ TZID:Europe/Paris
105
+ END:VTIMEZONE
106
+ BEGIN:VEVENT
107
+ UID:bla4
108
+ SUMMARY:RemoveTZ info
109
+ DTSTART;TZID=Europe/Paris:20111203T130102
110
+ BEGIN:VALARM
111
+ TRIGGER;VALUE=DATE-TIME;TZID=America/New_York:20151209T133200
112
+ END:VALARM
113
+ END:VEVENT
114
+ END:VCALENDAR
115
+ '
116
+
117
+ output = 'BEGIN:VCALENDAR
118
+ CALSCALE:GREGORIAN
119
+ VERSION:2.0
120
+ BEGIN:VEVENT
121
+ UID:bla4
122
+ SUMMARY:RemoveTZ info
123
+ DTSTART:20111203T120102Z
124
+ BEGIN:VALARM
125
+ TRIGGER;VALUE=DATE-TIME:20151209T183200Z
126
+ END:VALARM
127
+ END:VEVENT
128
+ END:VCALENDAR
129
+ '
130
+
131
+ tests << [input, output]
132
+
99
133
  # Recurrence rule
100
134
  input = 'BEGIN:VCALENDAR
101
135
  CALSCALE:GREGORIAN
@@ -297,7 +331,7 @@ END:VCALENDAR
297
331
  vcal = Tilia::VObject::Reader.read(input)
298
332
  time_zone = ActiveSupport::TimeZone.new(time_zone)
299
333
 
300
- vcal.expand(
334
+ vcal = vcal.expand(
301
335
  Time.zone.parse(start),
302
336
  Time.zone.parse(ending),
303
337
  time_zone
@@ -306,7 +340,7 @@ END:VCALENDAR
306
340
  # This will normalize the output
307
341
  output = Tilia::VObject::Reader.read(output).serialize
308
342
 
309
- assert_equal(output, vcal.serialize)
343
+ assert_v_obj_equals(output, vcal.serialize)
310
344
  end
311
345
  end
312
346
 
@@ -322,7 +356,9 @@ END:VCALENDAR
322
356
  '
323
357
  vcal = Tilia::VObject::Reader.read(input)
324
358
 
325
- assert_raises(RuntimeError) { vcal.expand(Time.zone.parse('2011-12-01'), Time.zone.parse('2011-12-31')) }
359
+ assert_raises(InvalidDataException) do
360
+ vcal.expand(Time.zone.parse('2011-12-01'), Time.zone.parse('2011-12-31'))
361
+ end
326
362
  end
327
363
 
328
364
  def test_get_document_type
@@ -42,7 +42,7 @@ module Tilia
42
42
  [
43
43
  'VERSION MUST appear exactly once in a VCARD component'
44
44
  ],
45
- "BEGIN:VCARD\r\nVERSION:3.0\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n"
45
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nUID:foo\r\nEND:VCARD\r\n"
46
46
  ]
47
47
 
48
48
  # Unknown version
@@ -295,9 +295,11 @@ module Tilia
295
295
  def test_serialize_children
296
296
  comp = Tilia::VObject::Component::VCalendar.new({}, false)
297
297
  event = comp.add(comp.create_component('VEVENT'))
298
- event.delete 'DTSTAMP'
299
- event.delete 'UID'
300
- comp.add(comp.create_component('VTODO'))
298
+ event.delete('DTSTAMP')
299
+ event.delete('UID')
300
+ todo = comp.add(comp.create_component('VTODO'))
301
+ todo.delete('DTSTAMP')
302
+ todo.delete('UID')
301
303
 
302
304
  str = comp.serialize
303
305
 
@@ -267,7 +267,9 @@ module Tilia
267
267
  end
268
268
 
269
269
  def test_parse_i_calendar_duration_fail
270
- assert_raises(RuntimeError) { Tilia::VObject::DateTimeParser.parse_duration('P1X', true) }
270
+ assert_raises(InvalidDataException) do
271
+ Tilia::VObject::DateTimeParser.parse_duration('P1X', true)
272
+ end
271
273
  end
272
274
 
273
275
  def test_parse_i_calendar_date_time
@@ -279,7 +281,9 @@ module Tilia
279
281
  end
280
282
 
281
283
  def test_parse_i_calendar_date_time_bad_format
282
- assert_raises(RuntimeError) { Tilia::VObject::DateTimeParser.parse_date_time('20100316T141405 ') }
284
+ assert_raises(InvalidDataException) do
285
+ Tilia::VObject::DateTimeParser.parse_date_time('20100316T141405 ')
286
+ end
283
287
  end
284
288
 
285
289
  def test_parse_i_calendar_date_time_utc
@@ -338,7 +342,9 @@ module Tilia
338
342
  end
339
343
 
340
344
  def test_parse_i_calendar_date_bad_format
341
- assert_raises(RuntimeError) { Tilia::VObject::DateTimeParser.parse_date('20100316T141405') }
345
+ assert_raises(InvalidDataException) do
346
+ Tilia::VObject::DateTimeParser.parse_date('20100316T141405')
347
+ end
342
348
  end
343
349
 
344
350
  def test_v_card_date
@@ -349,11 +355,15 @@ module Tilia
349
355
  end
350
356
 
351
357
  def test_bad_v_card_date
352
- assert_raises(ArgumentError) { Tilia::VObject::DateTimeParser.parse_v_card_date_time('1985---01') }
358
+ assert_raises(InvalidDataException) do
359
+ Tilia::VObject::DateTimeParser.parse_v_card_date_time('1985---01')
360
+ end
353
361
  end
354
362
 
355
363
  def test_bad_v_card_time
356
- assert_raises(ArgumentError) { Tilia::VObject::DateTimeParser.parse_v_card_time('23:12:166') }
364
+ assert_raises(InvalidDataException) do
365
+ Tilia::VObject::DateTimeParser.parse_v_card_time('23:12:166')
366
+ end
357
367
  end
358
368
 
359
369
  def test_date_and_or_time_date_with_year_month_day