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
@@ -10,17 +10,19 @@ module Tilia
10
10
  #
11
11
  # This should be 'VCALENDAR' or 'VCARD'.
12
12
  #
13
- # @var string
13
+ # @return [String]
14
14
  @default_name = 'VCARD'
15
15
 
16
- # Caching the version number.
16
+ # This is a list of components, and which classes they should map to.
17
17
  #
18
- # @var int
19
- # RUBY: attr_accessor :version
18
+ # @return [Hash]
19
+ @component_map = {
20
+ 'VCARD' => Component::VCard
21
+ }
20
22
 
21
23
  # List of value-types, and which classes they map to.
22
24
  #
23
- # @var array
25
+ # @return [Hash]
24
26
  @value_map = {
25
27
  'BINARY' => Property::Binary,
26
28
  'BOOLEAN' => Property::Boolean,
@@ -42,7 +44,7 @@ module Tilia
42
44
 
43
45
  # List of properties, and which classes they map to.
44
46
  #
45
- # @var array
47
+ # @return [Hash]
46
48
  @property_map = {
47
49
  # vCard 2.1 properties and up
48
50
  'N' => Property::Text,
@@ -109,24 +111,24 @@ module Tilia
109
111
  'ORG-DIRECTORY' => Property::FlatText
110
112
  }
111
113
 
112
- @component_map = {}
113
-
114
114
  # Returns the current document type.
115
115
  #
116
- # @return int
116
+ # @return [Fixnum]
117
117
  def document_type
118
118
  unless @version
119
119
  version = self['VERSION'].to_s
120
120
 
121
121
  case version
122
122
  when '2.1'
123
- @version = self.class::VCARD21
123
+ @version = VCARD21
124
124
  when '3.0'
125
- @version = self.class::VCARD30
125
+ @version = VCARD30
126
126
  when '4.0'
127
- @version = self.class::VCARD40
127
+ @version = VCARD40
128
128
  else
129
- @version = self.class::UNKNOWN
129
+ # We don't want to cache the version if it's unknown,
130
+ # because we might get a version property in a bit.
131
+ return UNKNOWN
130
132
  end
131
133
  end
132
134
 
@@ -142,9 +144,9 @@ module Tilia
142
144
  #
143
145
  # If input and output version are identical, a clone is returned.
144
146
  #
145
- # @param int target
147
+ # @param [Fixnum] target
146
148
  #
147
- # @return VCard
149
+ # @return [VCard]
148
150
  def convert(target)
149
151
  converter = VCardConverter.new
150
152
  converter.convert(self, target)
@@ -155,33 +157,14 @@ module Tilia
155
157
  # If the VCARD doesn't know its version, 2.1 is assumed.
156
158
  DEFAULT_VERSION = VCARD21
157
159
 
158
- # Validates the node for correctness.
159
- #
160
- # The following options are supported:
161
- # Node::REPAIR - May attempt to automatically repair the problem.
162
- #
163
- # This method returns an array with detected problems.
164
- # Every element has the following properties:
165
- #
166
- # * level - problem level.
167
- # * message - A human-readable string describing the issue.
168
- # * node - A reference to the problematic node.
169
- #
170
- # The level means:
171
- # 1 - The issue was repaired (only happens if REPAIR was turned on)
172
- # 2 - An inconsequential issue
173
- # 3 - A severe issue.
174
- #
175
- # @param int options
176
- #
177
- # @return array
160
+ # (see Component#validate)
178
161
  def validate(options = 0)
179
162
  warnings = []
180
163
 
181
164
  version_map = {
182
- self.class::VCARD21 => '2.1',
183
- self.class::VCARD30 => '3.0',
184
- self.class::VCARD40 => '4.0'
165
+ VCARD21 => '2.1',
166
+ VCARD30 => '3.0',
167
+ VCARD40 => '4.0'
185
168
  }
186
169
 
187
170
  version = select('VERSION')
@@ -193,12 +176,12 @@ module Tilia
193
176
  'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
194
177
  'node' => self
195
178
  }
196
- if options & self.class::REPAIR > 0
197
- self['VERSION'] = version_map[self.class::DEFAULT_VERSION]
179
+ if options & REPAIR > 0
180
+ self['VERSION'] = version_map[DEFAULT_VERSION]
198
181
  end
199
182
  end
200
183
 
201
- if version == '2.1' && options & self.class::PROFILE_CARDDAV > 0
184
+ if version == '2.1' && options & PROFILE_CARDDAV > 0
202
185
  warnings << {
203
186
  'level' => 3,
204
187
  'message' => 'CardDAV servers are not allowed to accept vCard 2.1.',
@@ -209,7 +192,7 @@ module Tilia
209
192
 
210
193
  uid = select('UID')
211
194
  if uid.size == 0
212
- if options & self.class::PROFILE_CARDDAV > 0
195
+ if options & PROFILE_CARDDAV > 0
213
196
  # Required for CardDAV
214
197
  warning_level = 3
215
198
  message = 'vCards on CardDAV servers MUST have a UID property.'
@@ -219,7 +202,7 @@ module Tilia
219
202
  message = 'Adding a UID to a vCard property is recommended.'
220
203
  end
221
204
 
222
- if options & self.class::REPAIR > 0
205
+ if options & REPAIR > 0
223
206
  self['UID'] = UuidUtil.uuid
224
207
  warning_level = 1
225
208
  end
@@ -235,7 +218,7 @@ module Tilia
235
218
  if fn.size != 1
236
219
  repaired = false
237
220
 
238
- if options & self.class::REPAIR > 0 && fn.size == 0
221
+ if options & REPAIR > 0 && fn.size == 0
239
222
  # We're going to try to see if we can use the contents of the
240
223
  # N property.
241
224
  if key?('N')
@@ -268,19 +251,7 @@ module Tilia
268
251
  w
269
252
  end
270
253
 
271
- # A simple list of validation rules.
272
- #
273
- # This is simply a list of properties, and how many times they either
274
- # must or must not appear.
275
- #
276
- # Possible values per property:
277
- # * 0 - Must not appear.
278
- # * 1 - Must appear exactly once.
279
- # * + - Must appear at least once.
280
- # * * - Can appear any number of times.
281
- # * ? - May appear, but not more than once.
282
- #
283
- # @var array
254
+ # (see Component#validation_rules)
284
255
  def validation_rules
285
256
  {
286
257
  'ADR' => '*',
@@ -334,9 +305,9 @@ module Tilia
334
305
  # If neither of those parameters are specified, the first is returned, if
335
306
  # a field with that name does not exist, null is returned.
336
307
  #
337
- # @param string field_name
308
+ # @param [String] field_name
338
309
  #
339
- # @return VObject\Property|null
310
+ # @return [Property, nil]
340
311
  def preferred(property_name)
341
312
  preferred = nil
342
313
  last_pref = 101
@@ -362,11 +333,12 @@ module Tilia
362
333
 
363
334
  # This method should return a list of default property values.
364
335
  #
365
- # @return array
336
+ # @return [Hash]
366
337
  def defaults
367
338
  {
368
- 'VERSION' => '3.0',
369
- 'PRODID' => "-//Tilia//Tilia VObject #{Version::VERSION}//EN"
339
+ 'VERSION' => '4.0',
340
+ 'PRODID' => "-//Tilia//Tilia VObject #{Version::VERSION}//EN",
341
+ 'UID' => "tilia-vobject-#{UuidUtil.uuid}"
370
342
  }
371
343
  end
372
344
 
@@ -375,7 +347,7 @@ module Tilia
375
347
  # This method returns an array, with the representation as it should be
376
348
  # encoded in json. This is used to create jCard or jCal documents.
377
349
  #
378
- # @return array
350
+ # @return [Array]
379
351
  def json_serialize
380
352
  # A vcard does not have sub-components, so we're overriding this
381
353
  # method to remove that array element.
@@ -391,9 +363,9 @@ module Tilia
391
363
  # This method serializes the data into XML. This is used to create xCard or
392
364
  # xCal documents.
393
365
  #
394
- # @param Xml\Writer writer XML writer.
366
+ # @param [Tilia::Xml::Writer] writer XML writer.
395
367
  #
396
- # @return void
368
+ # @return [void]
397
369
  def xml_serialize(writer)
398
370
  properties_by_group = {}
399
371
 
@@ -433,22 +405,23 @@ module Tilia
433
405
 
434
406
  # Returns the default class for a property name.
435
407
  #
436
- # @param string property_name
408
+ # @param [String] property_name
437
409
  #
438
- # @return string
410
+ # @return [String]
439
411
  def class_name_for_property_name(property_name)
440
412
  class_name = super(property_name)
441
413
 
442
414
  # In vCard 4, BINARY no longer exists, and we need URI instead.
443
- if class_name == Property::Binary && document_type == self.class::VCARD40
415
+ if class_name == Property::Binary && document_type == VCARD40
444
416
  return Property::Uri
445
417
  end
446
418
 
447
419
  class_name
448
420
  end
449
421
 
422
+ # sets instance variables
450
423
  def initialize(*args)
451
- super(*args)
424
+ super
452
425
  @version = nil
453
426
  end
454
427
  end
@@ -11,10 +11,10 @@ module Tilia
11
11
  # The rules used to determine if an event falls within the specified
12
12
  # time-range is based on the CalDAV specification.
13
13
  #
14
- # @param DateTimeInterface start
15
- # @param DateTimeInterface end
14
+ # @param [Time] start
15
+ # @param [Time] end
16
16
  #
17
- # @return bool
17
+ # @return [Boolean]
18
18
  def in_time_range?(start, ending)
19
19
  if self['RRULE']
20
20
  begin
@@ -63,7 +63,7 @@ module Tilia
63
63
 
64
64
  # This method should return a list of default property values.
65
65
  #
66
- # @return array
66
+ # @return [Hash]
67
67
  def defaults
68
68
  {
69
69
  'UID' => 'sabre-vobject-' + Tilia::VObject::UuidUtil.uuid,
@@ -73,19 +73,7 @@ module Tilia
73
73
 
74
74
  public
75
75
 
76
- # A simple list of validation rules.
77
- #
78
- # This is simply a list of properties, and how many times they either
79
- # must or must not appear.
80
- #
81
- # Possible values per property:
82
- # * 0 - Must not appear.
83
- # * 1 - Must appear exactly once.
84
- # * + - Must appear at least once.
85
- # * * - Can appear any number of times.
86
- # * ? - May appear, but not more than once.
87
- #
88
- # @var array
76
+ # (see Component#validation_rules)
89
77
  def validation_rules
90
78
  {
91
79
  'UID' => 1,
@@ -9,10 +9,10 @@ module Tilia
9
9
  # Checks based on the contained FREEBUSY information, if a timeslot is
10
10
  # available.
11
11
  #
12
- # @param DateTimeInterface start
13
- # @param DateTimeInterface end
12
+ # @param [Time] start
13
+ # @param [Time] end
14
14
  #
15
- # @return bool
15
+ # @return [Boolean]
16
16
  def free?(start, ending)
17
17
  select('FREEBUSY').each do |freebusy|
18
18
  # We are only interested in FBTYPE=BUSY (the default),
@@ -45,19 +45,7 @@ module Tilia
45
45
  true
46
46
  end
47
47
 
48
- # A simple list of validation rules.
49
- #
50
- # This is simply a list of properties, and how many times they either
51
- # must or must not appear.
52
- #
53
- # Possible values per property:
54
- # * 0 - Must not appear.
55
- # * 1 - Must appear exactly once.
56
- # * + - Must appear at least once.
57
- # * * - Can appear any number of times.
58
- # * ? - May appear, but not more than once.
59
- #
60
- # @var array
48
+ # (see Component#validation_rules)
61
49
  def validation_rules
62
50
  {
63
51
  'UID' => 1,
@@ -11,10 +11,10 @@ module Tilia
11
11
  # The rules used to determine if an event falls within the specified
12
12
  # time-range is based on the CalDAV specification.
13
13
  #
14
- # @param DateTimeInterface start
15
- # @param DateTimeInterface end
14
+ # @param [Time] start
15
+ # @param [Time] end
16
16
  #
17
- # @return bool
17
+ # @return [Boolean]
18
18
  def in_time_range?(start, ending)
19
19
  dtstart = key?('DTSTART') ? self['DTSTART'].date_time : nil
20
20
  if dtstart
@@ -27,19 +27,7 @@ module Tilia
27
27
  false
28
28
  end
29
29
 
30
- # A simple list of validation rules.
31
- #
32
- # This is simply a list of properties, and how many times they either
33
- # must or must not appear.
34
- #
35
- # Possible values per property:
36
- # * 0 - Must not appear.
37
- # * 1 - Must appear exactly once.
38
- # * + - Must appear at least once.
39
- # * * - Can appear any number of times.
40
- # * ? - May appear, but not more than once.
41
- #
42
- # @var array
30
+ # (see Component#validation_rules)
43
31
  def validation_rules
44
32
  {
45
33
  'UID' => 1,
@@ -69,6 +57,18 @@ module Tilia
69
57
  'RDATE' => '*'
70
58
  }
71
59
  end
60
+
61
+ protected
62
+
63
+ # This method should return a list of default property values.
64
+ #
65
+ # @return [array]
66
+ def defaults
67
+ {
68
+ 'UID' => "tilia-vobject-#{UuidUtil.uuid}",
69
+ 'DTSTAMP' => Time.zone.now.strftime('%Y%m%dT%H%M%SZ')
70
+ }
71
+ end
72
72
  end
73
73
  end
74
74
  end
@@ -11,24 +11,12 @@ module Tilia
11
11
  # If we can't accurately determine the timezone, this method will return
12
12
  # UTC.
13
13
  #
14
- # @return \DateTimeZone
14
+ # @return [ActiveSupport::TimeZone]
15
15
  def time_zone
16
16
  Tilia::VObject::TimeZoneUtil.time_zone(self['TZID'].to_s, @root)
17
17
  end
18
18
 
19
- # A simple list of validation rules.
20
- #
21
- # This is simply a list of properties, and how many times they either
22
- # must or must not appear.
23
- #
24
- # Possible values per property:
25
- # * 0 - Must not appear.
26
- # * 1 - Must appear exactly once.
27
- # * + - Must appear at least once.
28
- # * * - Can appear any number of times.
29
- # * ? - May appear, but not more than once.
30
- #
31
- # @var array
19
+ # (see Component#validation_rules)
32
20
  def validation_rules
33
21
  {
34
22
  'TZID' => 1,
@@ -11,10 +11,10 @@ module Tilia
11
11
  # The rules used to determine if an event falls within the specified
12
12
  # time-range is based on the CalDAV specification.
13
13
  #
14
- # @param DateTimeInterface start
15
- # @param DateTimeInterface end
14
+ # @param [Time] start
15
+ # @param [Time] end
16
16
  #
17
- # @return bool
17
+ # @return [Boolean]
18
18
  def in_time_range?(start, ending)
19
19
  dtstart = key?('DTSTART') ? self['DTSTART'].date_time : nil
20
20
  duration = key?('DURATION') ? Tilia::VObject::DateTimeParser.parse_duration(self['DURATION']) : nil
@@ -46,19 +46,7 @@ module Tilia
46
46
  true
47
47
  end
48
48
 
49
- # A simple list of validation rules.
50
- #
51
- # This is simply a list of properties, and how many times they either
52
- # must or must not appear.
53
- #
54
- # Possible values per property:
55
- # * 0 - Must not appear.
56
- # * 1 - Must appear exactly once.
57
- # * + - Must appear at least once.
58
- # * * - Can appear any number of times.
59
- # * ? - May appear, but not more than once.
60
- #
61
- # @var array
49
+ # (see Component#validation_rules)
62
50
  def validation_rules
63
51
  {
64
52
  'UID' => 1,
@@ -98,26 +86,7 @@ module Tilia
98
86
  }
99
87
  end
100
88
 
101
- # Validates the node for correctness.
102
- #
103
- # The following options are supported:
104
- # Node::REPAIR - May attempt to automatically repair the problem.
105
- #
106
- # This method returns an array with detected problems.
107
- # Every element has the following properties:
108
- #
109
- # * level - problem level.
110
- # * message - A human-readable string describing the issue.
111
- # * node - A reference to the problematic node.
112
- #
113
- # The level means:
114
- # 1 - The issue was repaired (only happens if REPAIR was turned on)
115
- # 2 - An inconsequential issue
116
- # 3 - A severe issue.
117
- #
118
- # @param int options
119
- #
120
- # @return array
89
+ # (see Component#validate)
121
90
  def validate(options = 0)
122
91
  result = super(options)
123
92
  if key?('DUE') && key?('DTSTART')
@@ -141,6 +110,18 @@ module Tilia
141
110
 
142
111
  result
143
112
  end
113
+
114
+ protected
115
+
116
+ # This method should return a list of default property values.
117
+ #
118
+ # @return [Hash]
119
+ def defaults
120
+ {
121
+ 'UID' => "tilia-vobject-#{UuidUtil.uuid}",
122
+ 'DTSTAMP' => Time.zone.now.strftime('%Y%m%dT%H%M%SZ')
123
+ }
124
+ end
144
125
  end
145
126
  end
146
127
  end