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.
- checksums.yaml +4 -4
- data/CHANGELOG.sabre.md +59 -2
- data/Gemfile +1 -8
- data/Gemfile.lock +18 -12
- data/LICENSE +1 -1
- data/LICENSE.sabre +1 -1
- data/lib/tilia/v_object.rb +1 -0
- data/lib/tilia/v_object/birthday_calendar_generator.rb +11 -11
- data/lib/tilia/v_object/cli.rb +39 -38
- data/lib/tilia/v_object/component.rb +47 -50
- data/lib/tilia/v_object/component/available.rb +4 -37
- data/lib/tilia/v_object/component/v_alarm.rb +6 -18
- data/lib/tilia/v_object/component/v_availability.rb +6 -39
- data/lib/tilia/v_object/component/v_calendar.rb +66 -98
- data/lib/tilia/v_object/component/v_card.rb +42 -69
- data/lib/tilia/v_object/component/v_event.rb +5 -17
- data/lib/tilia/v_object/component/v_free_busy.rb +4 -16
- data/lib/tilia/v_object/component/v_journal.rb +16 -16
- data/lib/tilia/v_object/component/v_time_zone.rb +2 -14
- data/lib/tilia/v_object/component/v_todo.rb +17 -36
- data/lib/tilia/v_object/date_time_parser.rb +24 -24
- data/lib/tilia/v_object/document.rb +25 -25
- data/lib/tilia/v_object/free_busy_data.rb +7 -7
- data/lib/tilia/v_object/free_busy_generator.rb +73 -75
- data/lib/tilia/v_object/i_tip.rb +1 -0
- data/lib/tilia/v_object/i_tip/broker.rb +134 -116
- data/lib/tilia/v_object/i_tip/i_tip_exception.rb +1 -1
- data/lib/tilia/v_object/i_tip/message.rb +13 -13
- data/lib/tilia/v_object/invalid_data_exception.rb +8 -0
- data/lib/tilia/v_object/node.rb +22 -27
- data/lib/tilia/v_object/parameter.rb +22 -22
- data/lib/tilia/v_object/parse_exception.rb +1 -1
- data/lib/tilia/v_object/parser.rb +1 -0
- data/lib/tilia/v_object/parser/json.rb +9 -19
- data/lib/tilia/v_object/parser/mime_dir.rb +73 -39
- data/lib/tilia/v_object/parser/parser.rb +9 -14
- data/lib/tilia/v_object/parser/xml.rb +33 -50
- data/lib/tilia/v_object/parser/xml/element.rb +1 -0
- data/lib/tilia/v_object/parser/xml/element/key_value.rb +2 -2
- data/lib/tilia/v_object/property.rb +52 -52
- data/lib/tilia/v_object/property/binary.rb +10 -10
- data/lib/tilia/v_object/property/boolean.rb +6 -6
- data/lib/tilia/v_object/property/flat_text.rb +3 -3
- data/lib/tilia/v_object/property/float_value.rb +10 -10
- data/lib/tilia/v_object/property/i_calendar.rb +1 -0
- data/lib/tilia/v_object/property/i_calendar/cal_address.rb +3 -3
- data/lib/tilia/v_object/property/i_calendar/date_time.rb +29 -57
- data/lib/tilia/v_object/property/i_calendar/duration.rb +6 -6
- data/lib/tilia/v_object/property/i_calendar/period.rb +10 -10
- data/lib/tilia/v_object/property/i_calendar/recur.rb +16 -24
- data/lib/tilia/v_object/property/integer_value.rb +8 -8
- data/lib/tilia/v_object/property/text.rb +21 -36
- data/lib/tilia/v_object/property/time.rb +29 -6
- data/lib/tilia/v_object/property/unknown.rb +2 -2
- data/lib/tilia/v_object/property/uri.rb +24 -5
- data/lib/tilia/v_object/property/utc_offset.rb +5 -5
- data/lib/tilia/v_object/property/v_card.rb +1 -0
- data/lib/tilia/v_object/property/v_card/date.rb +3 -3
- data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +30 -42
- data/lib/tilia/v_object/property/v_card/date_time.rb +1 -1
- data/lib/tilia/v_object/property/v_card/language_tag.rb +4 -4
- data/lib/tilia/v_object/property/v_card/time_stamp.rb +5 -5
- data/lib/tilia/v_object/reader.rb +12 -11
- data/lib/tilia/v_object/recur.rb +2 -0
- data/lib/tilia/v_object/recur/event_iterator.rb +30 -27
- data/lib/tilia/v_object/recur/max_instances_exceeded_exception.rb +10 -0
- data/lib/tilia/v_object/recur/no_instances_exception.rb +1 -1
- data/lib/tilia/v_object/recur/r_date_iterator.rb +15 -41
- data/lib/tilia/v_object/recur/r_rule_iterator.rb +23 -156
- data/lib/tilia/v_object/settings.rb +16 -0
- data/lib/tilia/v_object/splitter.rb +1 -0
- data/lib/tilia/v_object/splitter/i_calendar.rb +5 -5
- data/lib/tilia/v_object/splitter/splitter_interface.rb +2 -2
- data/lib/tilia/v_object/splitter/v_card.rb +5 -5
- data/lib/tilia/v_object/string_util.rb +25 -9
- data/lib/tilia/v_object/time_zone_data.rb +1 -0
- data/lib/tilia/v_object/time_zone_util.rb +6 -6
- data/lib/tilia/v_object/uuid_util.rb +3 -3
- data/lib/tilia/v_object/v_card_converter.rb +24 -21
- data/lib/tilia/v_object/version.rb +1 -1
- data/lib/tilia/v_object/writer.rb +7 -7
- data/test/test_helper.rb +3 -3
- data/test/v_object/birthday_calendar_generator_test.rb +22 -0
- data/test/v_object/component/v_alarm_test.rb +3 -1
- data/test/v_object/component/v_calendar_test.rb +40 -4
- data/test/v_object/component/v_card_test.rb +1 -1
- data/test/v_object/component_test.rb +5 -3
- data/test/v_object/date_time_parser_test.rb +15 -5
- data/test/v_object/free_busy_generator_test.rb +5 -5
- data/test/v_object/i_tip/broker_attendee_reply_test.rb +19 -0
- data/test/v_object/i_tip/broker_delete_event_test.rb +146 -2
- data/test/v_object/i_tip/broker_new_event_test.rb +21 -0
- data/test/v_object/i_tip/broker_process_reply_test.rb +10 -0
- data/test/v_object/i_tip/broker_tester.rb +1 -1
- data/test/v_object/i_tip/broker_update_event_test.rb +36 -0
- data/test/v_object/issue259_test.rb +24 -0
- data/test/v_object/issue40_test.rb +3 -1
- data/test/v_object/j_cal_test.rb +15 -12
- data/test/v_object/parser/json_test.rb +5 -5
- data/test/v_object/parser/mime_dir_test.rb +109 -0
- data/test/v_object/property/binary_test.rb +4 -2
- data/test/v_object/property/i_calendar/date_time_test.rb +3 -1
- data/test/v_object/property/uri_test.rb +23 -0
- data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +1 -1
- data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +1 -1
- data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +9 -9
- data/test/v_object/recur/event_iterator/handle_r_date_expand_test.rb +51 -0
- data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +3 -5
- data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +3 -1
- data/test/v_object/{issue26_test.rb → recur/event_iterator/issue26_test.rb} +3 -1
- data/test/v_object/recur/event_iterator/main_test.rb +9 -3
- data/test/v_object/recur/event_iterator/max_instances_test.rb +38 -0
- data/test/v_object/recur/event_iterator/missing_overridden_test.rb +3 -5
- data/test/v_object/recur/event_iterator/no_instances_test.rb +5 -3
- data/test/v_object/recur/event_iterator/override_first_event_test.rb +9 -9
- data/test/v_object/recur/r_date_iterator_test.rb +18 -0
- data/test/v_object/recur/r_rule_iterator_test.rb +4 -4
- data/test/v_object/splitter/i_calendar_test.rb +27 -7
- data/test/v_object/splitter/v_card_test.rb +5 -3
- data/test/v_object/test_case.rb +14 -4
- data/tilia-vobject.gemspec +2 -2
- metadata +17 -11
@@ -18,16 +18,16 @@ module Tilia
|
|
18
18
|
class FlatText < Property::Text
|
19
19
|
# Field separator.
|
20
20
|
#
|
21
|
-
# @
|
21
|
+
# @return [String]
|
22
22
|
attr_accessor :delimiter
|
23
23
|
|
24
24
|
# Sets the value as a quoted-printable encoded string.
|
25
25
|
#
|
26
26
|
# Overriding this so we're not splitting on a ; delimiter.
|
27
27
|
#
|
28
|
-
# @param
|
28
|
+
# @param [String] val
|
29
29
|
#
|
30
|
-
# @return void
|
30
|
+
# @return [void]
|
31
31
|
def quoted_printable_value=(val)
|
32
32
|
val = Mail::Encodings::QuotedPrintable.decode(val)
|
33
33
|
val = val.gsub(/\n/, "\r\n").gsub(/\r\r/, "\r")
|
@@ -9,7 +9,7 @@ module Tilia
|
|
9
9
|
# In case this is a multi-value property. This string will be used as a
|
10
10
|
# delimiter.
|
11
11
|
#
|
12
|
-
# @
|
12
|
+
# @return [String, nil]
|
13
13
|
attr_accessor :delimiter
|
14
14
|
|
15
15
|
# Sets a raw value coming from a mimedir (iCalendar/vCard) file.
|
@@ -17,9 +17,9 @@ module Tilia
|
|
17
17
|
# This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
18
18
|
# not yet done, but parameters are not included.
|
19
19
|
#
|
20
|
-
# @param
|
20
|
+
# @param [String] val
|
21
21
|
#
|
22
|
-
# @return void
|
22
|
+
# @return [void]
|
23
23
|
def raw_mime_dir_value=(val)
|
24
24
|
val = val.split(@delimiter)
|
25
25
|
val = val.map(&:to_f)
|
@@ -28,7 +28,7 @@ module Tilia
|
|
28
28
|
|
29
29
|
# Returns a raw mime-dir representation of the value.
|
30
30
|
#
|
31
|
-
# @return
|
31
|
+
# @return [String]
|
32
32
|
def raw_mime_dir_value
|
33
33
|
parts.join(@delimiter)
|
34
34
|
end
|
@@ -38,7 +38,7 @@ module Tilia
|
|
38
38
|
# This corresponds to the VALUE= parameter. Every property also has a
|
39
39
|
# 'default' valueType.
|
40
40
|
#
|
41
|
-
# @return
|
41
|
+
# @return [String]
|
42
42
|
def value_type
|
43
43
|
'FLOAT'
|
44
44
|
end
|
@@ -47,7 +47,7 @@ module Tilia
|
|
47
47
|
#
|
48
48
|
# This method must always return an array.
|
49
49
|
#
|
50
|
-
# @return array
|
50
|
+
# @return [array]
|
51
51
|
def json_value
|
52
52
|
val = parts.map(&:to_f)
|
53
53
|
|
@@ -63,9 +63,9 @@ module Tilia
|
|
63
63
|
# Hydrate data from a XML subtree, as it would appear in a xCard or xCal
|
64
64
|
# object.
|
65
65
|
#
|
66
|
-
# @param array value
|
66
|
+
# @param [array] value
|
67
67
|
#
|
68
|
-
# @return void
|
68
|
+
# @return [void]
|
69
69
|
def xml_value=(value)
|
70
70
|
value = value.values if value.is_a?(Hash)
|
71
71
|
value = value.map(&:to_f)
|
@@ -77,9 +77,9 @@ module Tilia
|
|
77
77
|
# This method serializes only the value of a property. This is used to
|
78
78
|
# create xCard or xCal documents.
|
79
79
|
#
|
80
|
-
# @param Xml\Writer writer XML writer.
|
80
|
+
# @param [Xml\Writer] writer XML writer.
|
81
81
|
#
|
82
|
-
# @return void
|
82
|
+
# @return [void]
|
83
83
|
def xml_serialize_value(writer)
|
84
84
|
# Special-casing the GEO property.
|
85
85
|
#
|
@@ -9,7 +9,7 @@ module Tilia
|
|
9
9
|
# In case this is a multi-value property. This string will be used as a
|
10
10
|
# delimiter.
|
11
11
|
#
|
12
|
-
# @
|
12
|
+
# @return [String, nil]
|
13
13
|
attr_accessor :delimiter
|
14
14
|
|
15
15
|
# Returns the type of value.
|
@@ -17,7 +17,7 @@ module Tilia
|
|
17
17
|
# This corresponds to the VALUE= parameter. Every property also has a
|
18
18
|
# 'default' valueType.
|
19
19
|
#
|
20
|
-
# @return
|
20
|
+
# @return [String]
|
21
21
|
def value_type
|
22
22
|
'CAL-ADDRESS'
|
23
23
|
end
|
@@ -29,7 +29,7 @@ module Tilia
|
|
29
29
|
#
|
30
30
|
# Evolution in particular tends to encode mailto: as MAILTO:.
|
31
31
|
#
|
32
|
-
# @return
|
32
|
+
# @return [String]
|
33
33
|
def normalized_value
|
34
34
|
input = value
|
35
35
|
return input unless input.index(':')
|
@@ -15,16 +15,16 @@ module Tilia
|
|
15
15
|
# In case this is a multi-value property. This string will be used as a
|
16
16
|
# delimiter.
|
17
17
|
#
|
18
|
-
# @
|
18
|
+
# @return [String, nil]
|
19
19
|
attr_accessor :delimiter
|
20
20
|
|
21
21
|
# Sets a multi-valued property.
|
22
22
|
#
|
23
23
|
# You may also specify DateTime objects here.
|
24
24
|
#
|
25
|
-
# @param array parts
|
25
|
+
# @param [array] parts
|
26
26
|
#
|
27
|
-
# @return void
|
27
|
+
# @return [void]
|
28
28
|
def parts=(parts)
|
29
29
|
if parts[0].is_a?(::Time)
|
30
30
|
self.date_times = parts
|
@@ -39,9 +39,9 @@ module Tilia
|
|
39
39
|
#
|
40
40
|
# Instead of strings, you may also use DateTime here.
|
41
41
|
#
|
42
|
-
# @param
|
42
|
+
# @param [String|array|DateTimeInterface] value
|
43
43
|
#
|
44
|
-
# @return void
|
44
|
+
# @return [void]
|
45
45
|
def value=(value)
|
46
46
|
if value.is_a?(Array) && value[0].is_a?(::Time)
|
47
47
|
self.date_times = value
|
@@ -57,23 +57,23 @@ module Tilia
|
|
57
57
|
# This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
58
58
|
# not yet done, but parameters are not included.
|
59
59
|
#
|
60
|
-
# @param
|
60
|
+
# @param [String] val
|
61
61
|
#
|
62
|
-
# @return void
|
62
|
+
# @return [void]
|
63
63
|
def raw_mime_dir_value=(val)
|
64
64
|
self.value = val.split(@delimiter)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Returns a raw mime-dir representation of the value.
|
68
68
|
#
|
69
|
-
# @return
|
69
|
+
# @return [String]
|
70
70
|
def raw_mime_dir_value
|
71
71
|
parts.join(@delimiter)
|
72
72
|
end
|
73
73
|
|
74
74
|
# Returns true if this is a DATE-TIME value, false if it's a DATE.
|
75
75
|
#
|
76
|
-
# @return
|
76
|
+
# @return [Boolean]
|
77
77
|
def time?
|
78
78
|
self['VALUE'].to_s.upcase != 'DATE'
|
79
79
|
end
|
@@ -95,9 +95,9 @@ module Tilia
|
|
95
95
|
# property or floating time, we will use the DateTimeZone argument to
|
96
96
|
# figure out the exact date.
|
97
97
|
#
|
98
|
-
# @param
|
98
|
+
# @param [ActiveSupport::TimeZone] time_zone
|
99
99
|
#
|
100
|
-
# @return
|
100
|
+
# @return [Time]
|
101
101
|
def date_time(time_zone = nil)
|
102
102
|
dt = date_times(time_zone)
|
103
103
|
return nil unless dt
|
@@ -111,10 +111,10 @@ module Tilia
|
|
111
111
|
# property or floating time, we will use the DateTimeZone argument to
|
112
112
|
# figure out the exact date.
|
113
113
|
#
|
114
|
-
# @param
|
114
|
+
# @param [ActiveSupport::TimeZone] time_zone
|
115
115
|
#
|
116
|
-
# @return DateTimeImmutable[]
|
117
|
-
# @return \DateTime[]
|
116
|
+
# @return [DateTimeImmutable[]]
|
117
|
+
# @return [\DateTime[]]
|
118
118
|
def date_times(time_zone = nil)
|
119
119
|
# Does the property have a TZID?
|
120
120
|
tzid = self['TZID']
|
@@ -130,10 +130,10 @@ module Tilia
|
|
130
130
|
|
131
131
|
# Sets the property as a DateTime object.
|
132
132
|
#
|
133
|
-
# @param
|
134
|
-
# @param
|
133
|
+
# @param [Time] dt
|
134
|
+
# @param [Boolean] isFloating If set to true, timezones will be ignored.
|
135
135
|
#
|
136
|
-
# @return void
|
136
|
+
# @return [void]
|
137
137
|
def date_time=(dt)
|
138
138
|
self.date_times = [dt]
|
139
139
|
end
|
@@ -143,10 +143,10 @@ module Tilia
|
|
143
143
|
# The first value will be used as a reference for the timezones, and all
|
144
144
|
# the otehr values will be adjusted for that timezone
|
145
145
|
#
|
146
|
-
# @param DateTimeInterface[] dt
|
147
|
-
# @param
|
146
|
+
# @param [DateTimeInterface[]] dt
|
147
|
+
# @param [Boolean] isFloating If set to true, timezones will be ignored.
|
148
148
|
#
|
149
|
-
# @return void
|
149
|
+
# @return [void]
|
150
150
|
def date_times=(dt)
|
151
151
|
update_date_times(dt)
|
152
152
|
end
|
@@ -156,7 +156,7 @@ module Tilia
|
|
156
156
|
# This corresponds to the VALUE= parameter. Every property also has a
|
157
157
|
# 'default' valueType.
|
158
158
|
#
|
159
|
-
# @return
|
159
|
+
# @return [String]
|
160
160
|
def value_type
|
161
161
|
time? ? 'DATE-TIME' : 'DATE'
|
162
162
|
end
|
@@ -165,7 +165,7 @@ module Tilia
|
|
165
165
|
#
|
166
166
|
# This method must always return an array.
|
167
167
|
#
|
168
|
-
# @return array
|
168
|
+
# @return [array]
|
169
169
|
def json_value
|
170
170
|
dts = date_times
|
171
171
|
|
@@ -185,9 +185,9 @@ module Tilia
|
|
185
185
|
#
|
186
186
|
# The value must always be an array.
|
187
187
|
#
|
188
|
-
# @param array value
|
188
|
+
# @param [array] value
|
189
189
|
#
|
190
|
-
# @return void
|
190
|
+
# @return [void]
|
191
191
|
def json_value=(value)
|
192
192
|
# dates and times in jCal have one difference to dates and times in
|
193
193
|
# iCalendar. In jCal date-parts are separated by dashes, and
|
@@ -201,10 +201,10 @@ module Tilia
|
|
201
201
|
# We need to intercept offsetSet, because it may be used to alter the
|
202
202
|
# VALUE from DATE-TIME to DATE or vice-versa.
|
203
203
|
#
|
204
|
-
# @param
|
205
|
-
# @param
|
204
|
+
# @param [String] name
|
205
|
+
# @param value
|
206
206
|
#
|
207
|
-
# @return void
|
207
|
+
# @return [void]
|
208
208
|
def []=(name, value)
|
209
209
|
super
|
210
210
|
|
@@ -214,26 +214,7 @@ module Tilia
|
|
214
214
|
update_date_times(date_times)
|
215
215
|
end
|
216
216
|
|
217
|
-
#
|
218
|
-
#
|
219
|
-
# The following options are supported:
|
220
|
-
# Node::REPAIR - May attempt to automatically repair the problem.
|
221
|
-
#
|
222
|
-
# This method returns an array with detected problems.
|
223
|
-
# Every element has the following properties:
|
224
|
-
#
|
225
|
-
# * level - problem level.
|
226
|
-
# * message - A human-readable string describing the issue.
|
227
|
-
# * node - A reference to the problematic node.
|
228
|
-
#
|
229
|
-
# The level means:
|
230
|
-
# 1 - The issue was repaired (only happens if REPAIR was turned on)
|
231
|
-
# 2 - An inconsequential issue
|
232
|
-
# 3 - A severe issue.
|
233
|
-
#
|
234
|
-
# @param int options
|
235
|
-
#
|
236
|
-
# @return array
|
217
|
+
# (see Component#validate)
|
237
218
|
def validate(options = 0)
|
238
219
|
messages = super(options)
|
239
220
|
value_type = self.value_type
|
@@ -250,7 +231,7 @@ module Tilia
|
|
250
231
|
Tilia::VObject::DateTimeParser.parse_date_time(value)
|
251
232
|
end
|
252
233
|
end
|
253
|
-
rescue
|
234
|
+
rescue InvalidDataException
|
254
235
|
messages << {
|
255
236
|
'level' => 3,
|
256
237
|
'message' => "The supplied value (#{save_val}) is not a correct #[value_type}",
|
@@ -261,15 +242,6 @@ module Tilia
|
|
261
242
|
messages
|
262
243
|
end
|
263
244
|
|
264
|
-
protected
|
265
|
-
|
266
|
-
# Raw values of dates for post_processing
|
267
|
-
#
|
268
|
-
# @return [Array<TIME>]
|
269
|
-
attr_accessor :raw_values
|
270
|
-
|
271
|
-
public
|
272
|
-
|
273
245
|
def initialize(*args)
|
274
246
|
super
|
275
247
|
@delimiter = ','
|
@@ -11,7 +11,7 @@ module Tilia
|
|
11
11
|
# In case this is a multi-value property. This string will be used as a
|
12
12
|
# delimiter.
|
13
13
|
#
|
14
|
-
# @
|
14
|
+
# @return [String, nil]
|
15
15
|
attr_accessor :delimiter
|
16
16
|
|
17
17
|
# Sets a raw value coming from a mimedir (iCalendar/vCard) file.
|
@@ -19,16 +19,16 @@ module Tilia
|
|
19
19
|
# This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
20
20
|
# not yet done, but parameters are not included.
|
21
21
|
#
|
22
|
-
# @param
|
22
|
+
# @param [String] val
|
23
23
|
#
|
24
|
-
# @return void
|
24
|
+
# @return [void]
|
25
25
|
def raw_mime_dir_value=(val)
|
26
26
|
self.value = val.split(@delimiter)
|
27
27
|
end
|
28
28
|
|
29
29
|
# Returns a raw mime-dir representation of the value.
|
30
30
|
#
|
31
|
-
# @return
|
31
|
+
# @return [String]
|
32
32
|
def raw_mime_dir_value
|
33
33
|
parts.join(@delimiter)
|
34
34
|
end
|
@@ -38,7 +38,7 @@ module Tilia
|
|
38
38
|
# This corresponds to the VALUE= parameter. Every property also has a
|
39
39
|
# 'default' valueType.
|
40
40
|
#
|
41
|
-
# @return
|
41
|
+
# @return [String]
|
42
42
|
def value_type
|
43
43
|
'DURATION'
|
44
44
|
end
|
@@ -47,7 +47,7 @@ module Tilia
|
|
47
47
|
#
|
48
48
|
# If the property has more than one value, only the first is returned.
|
49
49
|
#
|
50
|
-
# @return \DateInterval
|
50
|
+
# @return [\DateInterval]
|
51
51
|
def date_interval
|
52
52
|
parts = self.parts
|
53
53
|
value = parts[0]
|
@@ -11,7 +11,7 @@ module Tilia
|
|
11
11
|
# In case this is a multi-value property. This string will be used as a
|
12
12
|
# delimiter.
|
13
13
|
#
|
14
|
-
# @
|
14
|
+
# @return [String, nil]
|
15
15
|
attr_accessor :delimiter
|
16
16
|
|
17
17
|
# Sets a raw value coming from a mimedir (iCalendar/vCard) file.
|
@@ -19,16 +19,16 @@ module Tilia
|
|
19
19
|
# This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
20
20
|
# not yet done, but parameters are not included.
|
21
21
|
#
|
22
|
-
# @param
|
22
|
+
# @param [String] val
|
23
23
|
#
|
24
|
-
# @return void
|
24
|
+
# @return [void]
|
25
25
|
def raw_mime_dir_value=(val)
|
26
26
|
self.value = val.split(@delimiter)
|
27
27
|
end
|
28
28
|
|
29
29
|
# Returns a raw mime-dir representation of the value.
|
30
30
|
#
|
31
|
-
# @return
|
31
|
+
# @return [String]
|
32
32
|
def raw_mime_dir_value
|
33
33
|
parts.join(@delimiter)
|
34
34
|
end
|
@@ -38,7 +38,7 @@ module Tilia
|
|
38
38
|
# This corresponds to the VALUE= parameter. Every property also has a
|
39
39
|
# 'default' valueType.
|
40
40
|
#
|
41
|
-
# @return
|
41
|
+
# @return [String]
|
42
42
|
def value_type
|
43
43
|
'PERIOD'
|
44
44
|
end
|
@@ -47,9 +47,9 @@ module Tilia
|
|
47
47
|
#
|
48
48
|
# The value must always be an array.
|
49
49
|
#
|
50
|
-
# @param array value
|
50
|
+
# @param [array] value
|
51
51
|
#
|
52
|
-
# @return void
|
52
|
+
# @return [void]
|
53
53
|
def json_value=(value)
|
54
54
|
value = value.values if value.is_a?(Hash)
|
55
55
|
value = value.map do |item|
|
@@ -63,7 +63,7 @@ module Tilia
|
|
63
63
|
#
|
64
64
|
# This method must always return an array.
|
65
65
|
#
|
66
|
-
# @return array
|
66
|
+
# @return [array]
|
67
67
|
def json_value
|
68
68
|
result = []
|
69
69
|
parts.each do |item|
|
@@ -94,9 +94,9 @@ module Tilia
|
|
94
94
|
# This method serializes only the value of a property. This is used to
|
95
95
|
# create xCard or xCal documents.
|
96
96
|
#
|
97
|
-
# @param Xml\Writer writer XML writer.
|
97
|
+
# @param [Xml\Writer] writer XML writer.
|
98
98
|
#
|
99
|
-
# @return void
|
99
|
+
# @return [void]
|
100
100
|
def xml_serialize_value(writer)
|
101
101
|
writer.start_element(value_type.downcase)
|
102
102
|
|
@@ -18,13 +18,10 @@ module Tilia
|
|
18
18
|
#
|
19
19
|
# This may be either a single, or multiple strings in an array.
|
20
20
|
#
|
21
|
-
# @param
|
21
|
+
# @param [String|array] value
|
22
22
|
#
|
23
|
-
# @return void
|
23
|
+
# @return [void]
|
24
24
|
def value=(value)
|
25
|
-
# If we're getting the data from json, we'll be receiving an object
|
26
|
-
value = [value] if false # value.is_a?(Array) TODO
|
27
|
-
|
28
25
|
if value.is_a?(Hash)
|
29
26
|
new_val = {}
|
30
27
|
value.each do |k, v|
|
@@ -33,6 +30,7 @@ module Tilia
|
|
33
30
|
|
34
31
|
# The value had multiple sub-values
|
35
32
|
v = v.split(',') if v.index(',')
|
33
|
+
v = v.gsub(/[:\-]/, '') if k == 'until'
|
36
34
|
else
|
37
35
|
v = v.map { |val| val.is_a?(String) ? val.upcase : val }
|
38
36
|
end
|
@@ -56,7 +54,7 @@ module Tilia
|
|
56
54
|
#
|
57
55
|
# To get the correct multi-value version, use getParts.
|
58
56
|
#
|
59
|
-
# @return
|
57
|
+
# @return [String]
|
60
58
|
def value
|
61
59
|
out = []
|
62
60
|
@value.each do |key, value|
|
@@ -67,9 +65,8 @@ module Tilia
|
|
67
65
|
|
68
66
|
# Sets a multi-valued property.
|
69
67
|
#
|
70
|
-
# @param array parts
|
71
|
-
#
|
72
|
-
# @return void
|
68
|
+
# @param [array] parts
|
69
|
+
# @return [void]
|
73
70
|
def parts=(parts)
|
74
71
|
self.value = parts
|
75
72
|
end
|
@@ -79,7 +76,7 @@ module Tilia
|
|
79
76
|
# This method always returns an array, if there was only a single value,
|
80
77
|
# it will still be wrapped in an array.
|
81
78
|
#
|
82
|
-
# @return array
|
79
|
+
# @return [array]
|
83
80
|
def parts
|
84
81
|
@value
|
85
82
|
end
|
@@ -89,16 +86,15 @@ module Tilia
|
|
89
86
|
# This has been 'unfolded', so only 1 line will be passed. Unescaping is
|
90
87
|
# not yet done, but parameters are not included.
|
91
88
|
#
|
92
|
-
# @param
|
93
|
-
#
|
94
|
-
# @return void
|
89
|
+
# @param [String] val
|
90
|
+
# @return [void]
|
95
91
|
def raw_mime_dir_value=(val)
|
96
92
|
self.value = val
|
97
93
|
end
|
98
94
|
|
99
95
|
# Returns a raw mime-dir representation of the value.
|
100
96
|
#
|
101
|
-
# @return
|
97
|
+
# @return [String]
|
102
98
|
def raw_mime_dir_value
|
103
99
|
value
|
104
100
|
end
|
@@ -108,7 +104,7 @@ module Tilia
|
|
108
104
|
# This corresponds to the VALUE= parameter. Every property also has a
|
109
105
|
# 'default' valueType.
|
110
106
|
#
|
111
|
-
# @return
|
107
|
+
# @return [String]
|
112
108
|
def value_type
|
113
109
|
'RECUR'
|
114
110
|
end
|
@@ -117,7 +113,7 @@ module Tilia
|
|
117
113
|
#
|
118
114
|
# This method must always return an array.
|
119
115
|
#
|
120
|
-
# @return array
|
116
|
+
# @return [array]
|
121
117
|
def json_value
|
122
118
|
values = {}
|
123
119
|
parts.each do |k, v|
|
@@ -131,9 +127,8 @@ module Tilia
|
|
131
127
|
# This method serializes only the value of a property. This is used to
|
132
128
|
# create xCard or xCal documents.
|
133
129
|
#
|
134
|
-
# @param Xml\Writer writer XML writer.
|
135
|
-
#
|
136
|
-
# @return void
|
130
|
+
# @param [Xml\Writer] writer XML writer.
|
131
|
+
# @return [void]
|
137
132
|
def xml_serialize_value(writer)
|
138
133
|
value_type = self.value_type.downcase
|
139
134
|
|
@@ -142,13 +137,10 @@ module Tilia
|
|
142
137
|
end
|
143
138
|
end
|
144
139
|
|
145
|
-
public
|
146
|
-
|
147
140
|
# Parses an RRULE value string, and turns it into a struct-ish array.
|
148
141
|
#
|
149
|
-
# @param
|
150
|
-
#
|
151
|
-
# @return array
|
142
|
+
# @param [String] value
|
143
|
+
# @return [array]
|
152
144
|
def self.string_to_array(value)
|
153
145
|
value = value.upcase
|
154
146
|
new_value = {}
|