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
@@ -2,6 +2,7 @@ module Tilia
2
2
  module VObject
3
3
  module Parser
4
4
  class Xml
5
+ # Implementation of our own Tilia::Xml::Element classes
5
6
  module Element
6
7
  require 'tilia/v_object/parser/xml/element/key_value'
7
8
  end
@@ -24,9 +24,9 @@ module Tilia
24
24
  # reader.parse_inner_tree will parse the entire sub-tree, and advance to
25
25
  # the next element.
26
26
  #
27
- # @param XML\Reader reader
27
+ # @param [XML\Reader] reader
28
28
  #
29
- # @return mixed
29
+ # @return [mixed]
30
30
  def self.xml_deserialize(reader)
31
31
  # If there's no children, we don't do anything.
32
32
  if reader.empty_element?
@@ -22,43 +22,43 @@ module Tilia
22
22
  #
23
23
  # This will contain a string such as DTSTART, SUMMARY, FN.
24
24
  #
25
- # @var string
25
+ # @return [String]
26
26
  attr_accessor :name
27
27
 
28
28
  # Property group.
29
29
  #
30
30
  # This is only used in vcards
31
31
  #
32
- # @var string
32
+ # @return [String]
33
33
  attr_accessor :group
34
34
 
35
35
  # List of parameters.
36
36
  #
37
- # @var array
37
+ # @return [array]
38
38
  attr_accessor :parameters
39
39
 
40
40
  # Current value.
41
41
  #
42
- # @var mixed
42
+ # @return [mixed]
43
43
  # RUBY: attr_accessor :value
44
44
 
45
45
  # In case this is a multi-value property. This string will be used as a
46
46
  # delimiter.
47
47
  #
48
- # @var string|null
48
+ # @return [String, nil]
49
49
  attr_accessor :delimiter
50
50
 
51
51
  # Creates the generic property.
52
52
  #
53
53
  # Parameters must be specified in key=>value syntax.
54
54
  #
55
- # @param Component root The root document
56
- # @param string name
57
- # @param string|array|null value
58
- # @param array parameters List of parameters
59
- # @param string group The vcard property group
55
+ # @param [Component] root The root document
56
+ # @param [String] name
57
+ # @param [String|array, nil] value
58
+ # @param [array] parameters List of parameters
59
+ # @param [String] group The vcard property group
60
60
  #
61
- # @return void
61
+ # @return [void]
62
62
  def initialize(root, name, value = nil, parameters = {}, group = nil)
63
63
  @parameters = {}
64
64
  @delimiter = ';'
@@ -77,9 +77,9 @@ module Tilia
77
77
  #
78
78
  # This may be either a single, or multiple strings in an array.
79
79
  #
80
- # @param string|array value
80
+ # @param [String|array] value
81
81
  #
82
- # @return void
82
+ # @return [void]
83
83
  attr_writer :value
84
84
 
85
85
  # Returns the current value.
@@ -90,7 +90,7 @@ module Tilia
90
90
  #
91
91
  # To get the correct multi-value version, use getParts.
92
92
  #
93
- # @return string
93
+ # @return [String]
94
94
  def value
95
95
  if @value.is_a?(Array)
96
96
  if @value.empty?
@@ -107,9 +107,9 @@ module Tilia
107
107
 
108
108
  # Sets a multi-valued property.
109
109
  #
110
- # @param array parts
110
+ # @param [array] parts
111
111
  #
112
- # @return void
112
+ # @return [void]
113
113
  def parts=(parts)
114
114
  @value = parts
115
115
  end
@@ -119,7 +119,7 @@ module Tilia
119
119
  # This method always returns an array, if there was only a single value,
120
120
  # it will still be wrapped in an array.
121
121
  #
122
- # @return array
122
+ # @return [array]
123
123
  def parts
124
124
  if @value.nil?
125
125
  []
@@ -136,8 +136,8 @@ module Tilia
136
136
  # combined.
137
137
  # If nameless parameter is added, we try to guess it's name.
138
138
  #
139
- # @param string name
140
- # @param string|null|array value
139
+ # @param [String] name
140
+ # @param [String, nil|array] value
141
141
  def add(name, value = nil)
142
142
  no_name = false
143
143
  if name.nil?
@@ -156,7 +156,7 @@ module Tilia
156
156
 
157
157
  # Returns an iterable list of children.
158
158
  #
159
- # @return array
159
+ # @return [array]
160
160
  attr_reader :parameters
161
161
 
162
162
  # Returns the type of value.
@@ -164,7 +164,7 @@ module Tilia
164
164
  # This corresponds to the VALUE= parameter. Every property also has a
165
165
  # 'default' valueType.
166
166
  #
167
- # @return string
167
+ # @return [String]
168
168
  def value_type
169
169
  end
170
170
 
@@ -173,26 +173,26 @@ module Tilia
173
173
  # This has been 'unfolded', so only 1 line will be passed. Unescaping is
174
174
  # not yet done, but parameters are not included.
175
175
  #
176
- # @param string val
176
+ # @param [String] val
177
177
  #
178
- # @return void
178
+ # @return [void]
179
179
  def raw_mime_dir_value=(_val)
180
180
  end
181
181
 
182
182
  # Returns a raw mime-dir representation of the value.
183
183
  #
184
- # @return string
184
+ # @return [String]
185
185
  def raw_mime_dir_value
186
186
  end
187
187
 
188
188
  # Turns the object back into a serialized blob.
189
189
  #
190
- # @return string
190
+ # @return [String]
191
191
  def serialize
192
192
  str = @name
193
193
  str = "#{@group}.#{@name}" if @group
194
194
 
195
- @parameters.each do |_name, param|
195
+ parameters.each do |_name, param| # use parameters(), can be overwritten
196
196
  str += ";#{param.serialize}"
197
197
  end
198
198
 
@@ -218,7 +218,7 @@ module Tilia
218
218
  #
219
219
  # This method must always return an array.
220
220
  #
221
- # @return array
221
+ # @return [array]
222
222
  def json_value
223
223
  parts
224
224
  end
@@ -227,9 +227,9 @@ module Tilia
227
227
  #
228
228
  # The value must always be an array.
229
229
  #
230
- # @param array value
230
+ # @param [array] value
231
231
  #
232
- # @return void
232
+ # @return [void]
233
233
  def json_value=(value)
234
234
  value = value.values if value.is_a?(Hash)
235
235
  if value.size == 1
@@ -242,7 +242,7 @@ module Tilia
242
242
  # This method returns an array, with the representation as it should be
243
243
  # encoded in JSON. This is used to create jCard or jCal documents.
244
244
  #
245
- # @return array
245
+ # @return [array]
246
246
  def json_serialize
247
247
  parameters = {}
248
248
 
@@ -267,9 +267,9 @@ module Tilia
267
267
  # Hydrate data from a XML subtree, as it would appear in a xCard or xCal
268
268
  # object.
269
269
  #
270
- # @param array value
270
+ # @param [array] value
271
271
  #
272
- # @return void
272
+ # @return [void]
273
273
  def xml_value=(value)
274
274
  self.json_value = value
275
275
  end
@@ -277,9 +277,9 @@ module Tilia
277
277
  # This method serializes the data into XML. This is used to create xCard or
278
278
  # xCal documents.
279
279
  #
280
- # @param Xml\Writer writer XML writer.
280
+ # @param [Xml\Writer] writer XML writer.
281
281
  #
282
- # @return void
282
+ # @return [void]
283
283
  def xml_serialize(writer)
284
284
  parameters = []
285
285
 
@@ -312,9 +312,9 @@ module Tilia
312
312
  # This method serializes only the value of a property. This is used to
313
313
  # create xCard or xCal documents.
314
314
  #
315
- # @param Xml\Writer writer XML writer.
315
+ # @param [Xml\Writer] writer XML writer.
316
316
  #
317
- # @return void
317
+ # @return [void]
318
318
  def xml_serialize_value(writer)
319
319
  value_type = self.value_type.downcase
320
320
 
@@ -334,16 +334,16 @@ module Tilia
334
334
  # case the property had multiple values, the contents will be escaped and
335
335
  # combined with ,.
336
336
  #
337
- # @return string
337
+ # @return [String]
338
338
  def to_s
339
339
  value.to_s
340
340
  end
341
341
 
342
342
  # Checks if an array element exists.
343
343
  #
344
- # @param mixed name
344
+ # @param name
345
345
  #
346
- # @return bool
346
+ # @return [Boolean]
347
347
  def key?(name)
348
348
  name = name.upcase
349
349
 
@@ -357,9 +357,9 @@ module Tilia
357
357
  #
358
358
  # If the parameter does not exist, null is returned.
359
359
  #
360
- # @param string name
360
+ # @param [String] name
361
361
  #
362
- # @return Node
362
+ # @return [Node]
363
363
  def [](name)
364
364
  return super(name) if name.is_a?(Fixnum)
365
365
 
@@ -368,10 +368,10 @@ module Tilia
368
368
 
369
369
  # Creates a new parameter.
370
370
  #
371
- # @param string name
372
- # @param mixed value
371
+ # @param [String] name
372
+ # @param value
373
373
  #
374
- # @return void
374
+ # @return [void]
375
375
  def []=(name, value)
376
376
  if name.is_a?(Fixnum)
377
377
  super(name, value)
@@ -388,9 +388,9 @@ module Tilia
388
388
 
389
389
  # Removes one or more parameters with the specified name.
390
390
  #
391
- # @param string name
391
+ # @param [String] name
392
392
  #
393
- # @return void
393
+ # @return [void]
394
394
  def delete(name)
395
395
  if name.is_a?(Fixnum)
396
396
  super(name)
@@ -407,7 +407,7 @@ module Tilia
407
407
  # This method is automatically called when the object is cloned.
408
408
  # Specifically, this will ensure all child elements are also cloned.
409
409
  #
410
- # @return void
410
+ # @return [void]
411
411
  def initialize_copy(_original)
412
412
  new_params = {}
413
413
  @parameters.each do |key, child|
@@ -430,9 +430,9 @@ module Tilia
430
430
  # * message - (human readable message)
431
431
  # * node - (reference to the offending node)
432
432
  #
433
- # @param int options
433
+ # @param [Fixnum] options
434
434
  #
435
- # @return array
435
+ # @return [array]
436
436
  def validate(options = 0)
437
437
  warnings = []
438
438
 
@@ -441,7 +441,7 @@ module Tilia
441
441
  old_value = raw_mime_dir_value
442
442
  level = 3
443
443
 
444
- if options & self.class::REPAIR > 0
444
+ if options & REPAIR > 0
445
445
  new_value = StringUtil.convert_to_utf8(old_value)
446
446
 
447
447
  self.raw_mime_dir_value = new_value
@@ -470,7 +470,7 @@ module Tilia
470
470
  'node' => self
471
471
  }
472
472
 
473
- if options & self.class::REPAIR > 0
473
+ if options & REPAIR > 0
474
474
  # Uppercasing and converting underscores to dashes.
475
475
  @name = @name.upcase.tr('_', '-')
476
476
 
@@ -524,7 +524,7 @@ module Tilia
524
524
  # It's intended to remove all circular references, so PHP can easily clean
525
525
  # it up.
526
526
  #
527
- # @return void
527
+ # @return [void]
528
528
  def destroy
529
529
  super
530
530
 
@@ -14,16 +14,16 @@ module Tilia
14
14
  # In case this is a multi-value property. This string will be used as a
15
15
  # delimiter.
16
16
  #
17
- # @var string|null
17
+ # @return [String, nil]
18
18
  attr_accessor :delimiter
19
19
 
20
20
  # Updates the current value.
21
21
  #
22
22
  # This may be either a single, or multiple strings in an array.
23
23
  #
24
- # @param string|array value
24
+ # @param [String|array] value
25
25
  #
26
- # @return void
26
+ # @return [void]
27
27
  def value=(value)
28
28
  if value.is_a?(Array)
29
29
  if value.size == 1
@@ -41,16 +41,16 @@ module Tilia
41
41
  # This has been 'unfolded', so only 1 line will be passed. Unescaping is
42
42
  # not yet done, but parameters are not included.
43
43
  #
44
- # @param string val
44
+ # @param [String] val
45
45
  #
46
- # @return void
46
+ # @return [void]
47
47
  def raw_mime_dir_value=(val)
48
48
  @value = Base64.decode64(val)
49
49
  end
50
50
 
51
51
  # Returns a raw mime-dir representation of the value.
52
52
  #
53
- # @return string
53
+ # @return [String]
54
54
  def raw_mime_dir_value
55
55
  Base64.strict_encode64(@value)
56
56
  end
@@ -60,7 +60,7 @@ module Tilia
60
60
  # This corresponds to the VALUE= parameter. Every property also has a
61
61
  # 'default' valueType.
62
62
  #
63
- # @return string
63
+ # @return [String]
64
64
  def value_type
65
65
  'BINARY'
66
66
  end
@@ -69,7 +69,7 @@ module Tilia
69
69
  #
70
70
  # This method must always return an array.
71
71
  #
72
- # @return array
72
+ # @return [array]
73
73
  def json_value
74
74
  [Base64.strict_encode64(value)]
75
75
  end
@@ -78,9 +78,9 @@ module Tilia
78
78
  #
79
79
  # The value must always be an array.
80
80
  #
81
- # @param array value
81
+ # @param [array] value
82
82
  #
83
- # @return void
83
+ # @return [void]
84
84
  def json_value=(value)
85
85
  value = value.map { |v| Base64.decode64(v) }
86
86
  super(value)
@@ -13,9 +13,9 @@ module Tilia
13
13
  # This has been 'unfolded', so only 1 line will be passed. Unescaping is
14
14
  # not yet done, but parameters are not included.
15
15
  #
16
- # @param string val
16
+ # @param [String] val
17
17
  #
18
- # @return void
18
+ # @return [void]
19
19
  def raw_mime_dir_value=(val)
20
20
  val = val.upcase == 'TRUE' ? true : false
21
21
  self.value = val
@@ -23,7 +23,7 @@ module Tilia
23
23
 
24
24
  # Returns a raw mime-dir representation of the value.
25
25
  #
26
- # @return string
26
+ # @return [String]
27
27
  def raw_mime_dir_value
28
28
  @value ? 'TRUE' : 'FALSE'
29
29
  end
@@ -33,7 +33,7 @@ module Tilia
33
33
  # This corresponds to the VALUE= parameter. Every property also has a
34
34
  # 'default' valueType.
35
35
  #
36
- # @return string
36
+ # @return [String]
37
37
  def value_type
38
38
  'BOOLEAN'
39
39
  end
@@ -41,9 +41,9 @@ module Tilia
41
41
  # Hydrate data from a XML subtree, as it would appear in a xCard or xCal
42
42
  # object.
43
43
  #
44
- # @param array value
44
+ # @param [array] value
45
45
  #
46
- # @return void
46
+ # @return [void]
47
47
  def xml_value=(value)
48
48
  value = value.map do |v|
49
49
  'true' == v