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,7 +2,7 @@ module Tilia
2
2
  module VObject
3
3
  module ITip
4
4
  # This message is emitted in case of serious problems with iTip messages.
5
- class ITipException < Exception
5
+ class ITipException < StandardError
6
6
  end
7
7
  end
8
8
  end
@@ -10,23 +10,23 @@ module Tilia
10
10
  class Message
11
11
  # The object's UID.
12
12
  #
13
- # @var string
13
+ # @return [String]
14
14
  attr_accessor :uid
15
15
 
16
16
  # The component type, such as VEVENT.
17
17
  #
18
- # @var string
18
+ # @return [String]
19
19
  attr_accessor :component
20
20
 
21
21
  # Contains the ITip method, which is something like REQUEST, REPLY or
22
22
  # CANCEL.
23
23
  #
24
- # @var string
24
+ # @return [String]
25
25
  attr_accessor :method
26
26
 
27
27
  # The current sequence number for the event.
28
28
  #
29
- # @var int
29
+ # @return [Fixnum]
30
30
  attr_accessor :sequence
31
31
 
32
32
  # The senders' email address.
@@ -35,24 +35,24 @@ module Tilia
35
35
  # if the message is sent by email. It may also be populated in Reply-To:
36
36
  # or not at all.
37
37
  #
38
- # @var string
38
+ # @return [String]
39
39
  attr_accessor :sender
40
40
 
41
41
  # The name of the sender. This is often populated from a CN parameter from
42
42
  # either the ORGANIZER or ATTENDEE, depending on the message.
43
43
  #
44
- # @var string|null
44
+ # @return [String, nil]
45
45
  attr_accessor :sender_name
46
46
 
47
47
  # The recipient's email address.
48
48
  #
49
- # @var string
49
+ # @return [String]
50
50
  attr_accessor :recipient
51
51
 
52
52
  # The name of the recipient. This is usually populated with the CN
53
53
  # parameter from the ATTENDEE or ORGANIZER property, if it's available.
54
54
  #
55
- # @var string|null
55
+ # @return [String, nil]
56
56
  attr_accessor :recipient_name
57
57
 
58
58
  # After the message has been delivered, this should contain a string such
@@ -63,12 +63,12 @@ module Tilia
63
63
  # See:
64
64
  # http://tools.ietf.org/html/rfc6638#section-7.3
65
65
  #
66
- # @var string
66
+ # @return [String]
67
67
  attr_accessor :schedule_status
68
68
 
69
69
  # The iCalendar / iTip body.
70
70
  #
71
- # @var \Sabre\VObject\Component\VCalendar
71
+ # @return [Component::VCalendar]
72
72
  attr_accessor :message
73
73
 
74
74
  # This will be set to true, if the iTip broker considers the change
@@ -82,7 +82,7 @@ module Tilia
82
82
  # To see the list of properties that are considered 'significant', check
83
83
  # out Sabre\VObject\ITip\Broker::significant_change_properties.
84
84
  #
85
- # @var bool
85
+ # @return [Boolean]
86
86
  attr_accessor :significant_change
87
87
 
88
88
  # Returns the schedule status as a string.
@@ -90,7 +90,7 @@ module Tilia
90
90
  # For example:
91
91
  # 1.2
92
92
  #
93
- # @return mixed bool|string
93
+ # @return [String, false]
94
94
  def schedule_status
95
95
  if !@schedule_status
96
96
  false
@@ -99,7 +99,7 @@ module Tilia
99
99
  end
100
100
  end
101
101
 
102
- # TODO: document
102
+ # Initialize instance variables
103
103
  def initialize
104
104
  @significant_change = true
105
105
  end
@@ -0,0 +1,8 @@
1
+ module Tilia
2
+ module VObject
3
+ # This exception is thrown whenever an invalid value is found anywhere in a
4
+ # iCalendar or vCard object.
5
+ class InvalidDataException < StandardError
6
+ end
7
+ end
8
+ end
@@ -27,34 +27,29 @@ module Tilia
27
27
 
28
28
  # Reference to the parent object, if this is not the top object.
29
29
  #
30
- # @var Node
30
+ # @return [Node]
31
31
  attr_accessor :parent
32
32
 
33
- # The root document.
34
- #
35
- # @var Component
36
- # RUBY: attr_accessor :root
37
-
38
33
  # Serializes the node into a mimedir format.
39
34
  #
40
- # @return string
35
+ # @return [String]
41
36
  def serialize
42
37
  end
43
38
 
44
39
  # This method returns an array, with the representation as it should be
45
40
  # encoded in JSON. This is used to create jCard or jCal documents.
46
41
  #
47
- # @return array
42
+ # @return [array]
48
43
  def json_serialize
49
44
  end
50
45
 
51
46
  # This method serializes the data into XML. This is used to create xCard or
52
47
  # xCal documents.
53
48
  #
54
- # @param Xml\Writer writer XML writer.
49
+ # @param [Xml\Writer] writer XML writer.
55
50
  #
56
- # @return void
57
- def xml_serialize(_writer)
51
+ # @return [void]
52
+ def xml_serialize(writer)
58
53
  end
59
54
 
60
55
  # Call this method on a document if you're done using it.
@@ -62,7 +57,7 @@ module Tilia
62
57
  # It's intended to remove all circular references, so PHP can easily clean
63
58
  # it up.
64
59
  #
65
- # @return void
60
+ # @return [void]
66
61
  def destroy
67
62
  @parent = nil
68
63
  @root = nil
@@ -85,16 +80,16 @@ module Tilia
85
80
  # 2 - An inconsequential issue
86
81
  # 3 - A severe issue.
87
82
  #
88
- # @param int options
83
+ # @param [Fixnum] options
89
84
  #
90
- # @return array
85
+ # @return [array]
91
86
  def validate(_options = 0)
92
87
  []
93
88
  end
94
89
 
95
90
  # Returns the iterator for this object.
96
91
  #
97
- # @return ElementList
92
+ # @return [ElementList]
98
93
  def iterator
99
94
  return @iterator if @iterator
100
95
 
@@ -105,14 +100,14 @@ module Tilia
105
100
  #
106
101
  # Note that this is not actually part of the iterator interface
107
102
  #
108
- # @param ElementList $iterator
103
+ # @param [ElementList] $iterator
109
104
  #
110
- # @return void
105
+ # @return [void]
111
106
  attr_writer :iterator
112
107
 
113
108
  # Returns the number of elements.
114
109
  #
115
- # @return int
110
+ # @return [Fixnum]
116
111
  def size
117
112
  it = iterator
118
113
  it.size
@@ -124,9 +119,9 @@ module Tilia
124
119
  #
125
120
  # This method just forwards the request to the inner iterator
126
121
  #
127
- # @param int $offset
122
+ # @param [Fixnum] $offset
128
123
  #
129
- # @return bool
124
+ # @return [Boolean]
130
125
  def key?(offset)
131
126
  iterator = self.iterator
132
127
  iterator.key?(offset)
@@ -136,9 +131,9 @@ module Tilia
136
131
  #
137
132
  # This method just forwards the request to the inner iterator
138
133
  #
139
- # @param int $offset
134
+ # @param [Fixnum] $offset
140
135
  #
141
- # @return mixed
136
+ # @return [mixed]
142
137
  def [](offset)
143
138
  iterator = self.iterator
144
139
  iterator[offset]
@@ -148,10 +143,10 @@ module Tilia
148
143
  #
149
144
  # This method just forwards the request to the inner iterator
150
145
  #
151
- # @param int $offset
152
- # @param mixed $value
146
+ # @param [Fixnum] $offset
147
+ # @param $value
153
148
  #
154
- # @return void
149
+ # @return [void]
155
150
  def []=(offset, value)
156
151
  iterator = self.iterator
157
152
  iterator[offset] = value
@@ -161,9 +156,9 @@ module Tilia
161
156
  #
162
157
  # This method just forwards the request to the inner iterator
163
158
  #
164
- # @param int $offset
159
+ # @param [Fixnum] $offset
165
160
  #
166
- # @return void
161
+ # @return [void]
167
162
  def delete(offset)
168
163
  iterator = self.iterator
169
164
  iterator.delete(offset)
@@ -9,27 +9,27 @@ module Tilia
9
9
  class Parameter < Node
10
10
  # Parameter name.
11
11
  #
12
- # @var string
12
+ # @return [String]
13
13
  attr_accessor :name
14
14
 
15
15
  # vCard 2.1 allows parameters to be encoded without a name.
16
16
  #
17
17
  # We can deduce the parameter name based on it's value.
18
18
  #
19
- # @var bool
19
+ # @return [Boolean]
20
20
  attr_accessor :no_name
21
21
 
22
22
  # Parameter value.
23
23
  #
24
- # @var string
24
+ # @return [String]
25
25
  # RUBY: attr_accessor :value
26
26
 
27
27
  # Sets up the object.
28
28
  #
29
29
  # It's recommended to use the create:: factory method instead.
30
30
  #
31
- # @param string name
32
- # @param string value
31
+ # @param [String] name
32
+ # @param [String] value
33
33
  def initialize(root, name, value = nil)
34
34
  @no_name = false
35
35
  @name = (name || '').upcase
@@ -59,9 +59,9 @@ module Tilia
59
59
  # these are rather silly in 2014 and would probably rarely be
60
60
  # used, but we like to be complete.
61
61
  #
62
- # @param string value
62
+ # @param [String] value
63
63
  #
64
- # @return string
64
+ # @return [String]
65
65
  def self.guess_parameter_name_by_value(value)
66
66
  value ||= ''
67
67
  case value.upcase
@@ -148,9 +148,9 @@ module Tilia
148
148
  #
149
149
  # This may be either a single, or multiple strings in an array.
150
150
  #
151
- # @param string|array value
151
+ # @param [String|array] value
152
152
  #
153
- # @return void
153
+ # @return [void]
154
154
  attr_writer :value
155
155
 
156
156
  # Returns the current value.
@@ -158,7 +158,7 @@ module Tilia
158
158
  # This method will always return a string, or null. If there were multiple
159
159
  # values, it will automatically concatenate them (separated by comma).
160
160
  #
161
- # @return string|null
161
+ # @return [String, nil]
162
162
  def value
163
163
  if @value.is_a?(Array)
164
164
  @value.join(',')
@@ -169,9 +169,9 @@ module Tilia
169
169
 
170
170
  # Sets multiple values for this parameter.
171
171
  #
172
- # @param array value
172
+ # @param [array] value
173
173
  #
174
- # @return void
174
+ # @return [void]
175
175
  def parts=(value)
176
176
  @value = value
177
177
  end
@@ -180,7 +180,7 @@ module Tilia
180
180
  #
181
181
  # If there were no values, an empty array will be returned.
182
182
  #
183
- # @return array
183
+ # @return [array]
184
184
  def parts
185
185
  if @value.is_a?(Array)
186
186
  @value
@@ -196,9 +196,9 @@ module Tilia
196
196
  # If the argument is specified as an array, all items will be added to the
197
197
  # parameter value list.
198
198
  #
199
- # @param string|array part
199
+ # @param [String|array] part
200
200
  #
201
- # @return void
201
+ # @return [void]
202
202
  def add_value(part)
203
203
  if @value.nil?
204
204
  @value = part
@@ -215,9 +215,9 @@ module Tilia
215
215
  # instance the TYPE parameter, to see if it contains a keyword such as
216
216
  # 'WORK' or 'FAX'.
217
217
  #
218
- # @param string value
218
+ # @param [String] value
219
219
  #
220
- # @return bool
220
+ # @return [Boolean]
221
221
  def has(value)
222
222
  value = value.downcase
223
223
  results = (@value.is_a?(Array) ? @value : [@value]).select do |entry|
@@ -228,7 +228,7 @@ module Tilia
228
228
 
229
229
  # Turns the object back into a serialized blob.
230
230
  #
231
- # @return string
231
+ # @return [String]
232
232
  def serialize
233
233
  value = parts
234
234
 
@@ -278,7 +278,7 @@ module Tilia
278
278
  # This method returns an array, with the representation as it should be
279
279
  # encoded in JSON. This is used to create jCard or jCal documents.
280
280
  #
281
- # @return array
281
+ # @return [array]
282
282
  def json_serialize
283
283
  @value
284
284
  end
@@ -286,9 +286,9 @@ module Tilia
286
286
  # This method serializes the data into XML. This is used to create xCard or
287
287
  # xCal documents.
288
288
  #
289
- # @param Xml\Writer writer XML writer.
289
+ # @param [Xml\Writer] writer XML writer.
290
290
  #
291
- # @return void
291
+ # @return [void]
292
292
  def xml_serialize(writer)
293
293
  @value.split(',').each do |value|
294
294
  writer.write_element('text', value)
@@ -297,7 +297,7 @@ module Tilia
297
297
 
298
298
  # Called when this object is being cast to a string.
299
299
  #
300
- # @return string
300
+ # @return [String]
301
301
  def to_s
302
302
  value.to_s
303
303
  end
@@ -1,7 +1,7 @@
1
1
  module Tilia
2
2
  module VObject
3
3
  # Exception thrown by Reader if an invalid object was attempted to be parsed.
4
- class ParseException < Exception
4
+ class ParseException < StandardError
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  module Tilia
2
2
  module VObject
3
+ # Namespace of the parser components
3
4
  module Parser
4
5
  require 'tilia/v_object/parser/parser'
5
6
  require 'tilia/v_object/parser/mime_dir'
@@ -6,16 +6,6 @@ module Tilia
6
6
  #
7
7
  # This parser parses both the jCal and jCard formats.
8
8
  class Json < Parser
9
- # The input data.
10
- #
11
- # @var array
12
- # RUBY: attr_accessor :input
13
-
14
- # Root component.
15
- #
16
- # @var Document
17
- # RUBY: attr_accessor :root
18
-
19
9
  # This method starts the parsing process.
20
10
  #
21
11
  # If the input was not supplied during construction, it's possible to pass
@@ -23,10 +13,10 @@ module Tilia
23
13
  #
24
14
  # If either input or options are not supplied, the defaults will be used.
25
15
  #
26
- # @param resource|string|array|null input
27
- # @param int options
16
+ # @param [String, #read, nil] input
17
+ # @param [Fixnum] options
28
18
  #
29
- # @return Sabre\VObject\Document
19
+ # @return [Document]
30
20
  def parse(input = nil, options = 0)
31
21
  self.input = input unless input.nil?
32
22
  if @input.nil?
@@ -61,9 +51,9 @@ module Tilia
61
51
 
62
52
  # Parses a component.
63
53
  #
64
- # @param array j_comp
54
+ # @param [Array] j_comp
65
55
  #
66
- # @return \Sabre\VObject\Component
56
+ # @return [Component]
67
57
  def parse_component(j_comp)
68
58
  properties = j_comp[1].map do |j_prop|
69
59
  parse_property(j_prop)
@@ -86,9 +76,9 @@ module Tilia
86
76
 
87
77
  # Parses properties.
88
78
  #
89
- # @param array j_prop
79
+ # @param [Array] j_prop
90
80
  #
91
- # @return \Sabre\VObject\Property
81
+ # @return [\Sabre\VObject\Property]
92
82
  def parse_property(j_prop)
93
83
  (
94
84
  property_name,
@@ -134,9 +124,9 @@ module Tilia
134
124
 
135
125
  # Sets the input data.
136
126
  #
137
- # @param resource|string|array input
127
+ # @param [String, #read] input
138
128
  #
139
- # @return void
129
+ # @return [void]
140
130
  def input=(input)
141
131
  input = input.read unless input.is_a?(String)
142
132
  input = JSON.parse(input)