tilia-vobject 4.0.0.pre.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +32 -0
- data/.simplecov +4 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.sabre.md +626 -0
- data/CONTRIBUTING.md +25 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +68 -0
- data/LICENSE +27 -0
- data/LICENSE.sabre +27 -0
- data/README.md +63 -0
- data/Rakefile +17 -0
- data/bin/vobject +7 -0
- data/lib/tilia/v_object/birthday_calendar_generator.rb +142 -0
- data/lib/tilia/v_object/cli.rb +582 -0
- data/lib/tilia/v_object/component/available.rb +107 -0
- data/lib/tilia/v_object/component/v_alarm.rb +114 -0
- data/lib/tilia/v_object/component/v_availability.rb +128 -0
- data/lib/tilia/v_object/component/v_calendar.rb +468 -0
- data/lib/tilia/v_object/component/v_card.rb +457 -0
- data/lib/tilia/v_object/component/v_event.rb +127 -0
- data/lib/tilia/v_object/component/v_free_busy.rb +81 -0
- data/lib/tilia/v_object/component/v_journal.rb +75 -0
- data/lib/tilia/v_object/component/v_time_zone.rb +51 -0
- data/lib/tilia/v_object/component/v_todo.rb +147 -0
- data/lib/tilia/v_object/component.rb +591 -0
- data/lib/tilia/v_object/date_time_parser.rb +486 -0
- data/lib/tilia/v_object/document.rb +218 -0
- data/lib/tilia/v_object/element_list.rb +18 -0
- data/lib/tilia/v_object/eof_exception.rb +8 -0
- data/lib/tilia/v_object/free_busy_data.rb +149 -0
- data/lib/tilia/v_object/free_busy_generator.rb +465 -0
- data/lib/tilia/v_object/i_tip/broker.rb +909 -0
- data/lib/tilia/v_object/i_tip/i_tip_exception.rb +9 -0
- data/lib/tilia/v_object/i_tip/message.rb +109 -0
- data/lib/tilia/v_object/i_tip/same_organizer_for_all_components_exception.rb +13 -0
- data/lib/tilia/v_object/i_tip.rb +10 -0
- data/lib/tilia/v_object/node.rb +192 -0
- data/lib/tilia/v_object/parameter.rb +327 -0
- data/lib/tilia/v_object/parse_exception.rb +7 -0
- data/lib/tilia/v_object/parser/json.rb +149 -0
- data/lib/tilia/v_object/parser/mime_dir.rb +543 -0
- data/lib/tilia/v_object/parser/parser.rb +61 -0
- data/lib/tilia/v_object/parser/xml/element/key_value.rb +60 -0
- data/lib/tilia/v_object/parser/xml/element.rb +11 -0
- data/lib/tilia/v_object/parser/xml.rb +322 -0
- data/lib/tilia/v_object/parser.rb +10 -0
- data/lib/tilia/v_object/property/binary.rb +96 -0
- data/lib/tilia/v_object/property/boolean.rb +57 -0
- data/lib/tilia/v_object/property/flat_text.rb +52 -0
- data/lib/tilia/v_object/property/float_value.rb +107 -0
- data/lib/tilia/v_object/property/i_calendar/cal_address.rb +49 -0
- data/lib/tilia/v_object/property/i_calendar/date.rb +15 -0
- data/lib/tilia/v_object/property/i_calendar/date_time.rb +330 -0
- data/lib/tilia/v_object/property/i_calendar/duration.rb +65 -0
- data/lib/tilia/v_object/property/i_calendar/period.rb +124 -0
- data/lib/tilia/v_object/property/i_calendar/recur.rb +173 -0
- data/lib/tilia/v_object/property/i_calendar.rb +14 -0
- data/lib/tilia/v_object/property/integer_value.rb +60 -0
- data/lib/tilia/v_object/property/text.rb +352 -0
- data/lib/tilia/v_object/property/time.rb +85 -0
- data/lib/tilia/v_object/property/unknown.rb +30 -0
- data/lib/tilia/v_object/property/uri.rb +78 -0
- data/lib/tilia/v_object/property/utc_offset.rb +56 -0
- data/lib/tilia/v_object/property/v_card/date.rb +31 -0
- data/lib/tilia/v_object/property/v_card/date_and_or_time.rb +343 -0
- data/lib/tilia/v_object/property/v_card/date_time.rb +22 -0
- data/lib/tilia/v_object/property/v_card/language_tag.rb +41 -0
- data/lib/tilia/v_object/property/v_card/time_stamp.rb +74 -0
- data/lib/tilia/v_object/property/v_card.rb +13 -0
- data/lib/tilia/v_object/property.rb +532 -0
- data/lib/tilia/v_object/reader.rb +73 -0
- data/lib/tilia/v_object/recur/event_iterator.rb +417 -0
- data/lib/tilia/v_object/recur/no_instances_exception.rb +11 -0
- data/lib/tilia/v_object/recur/r_date_iterator.rb +138 -0
- data/lib/tilia/v_object/recur/r_rule_iterator.rb +717 -0
- data/lib/tilia/v_object/recur.rb +10 -0
- data/lib/tilia/v_object/settings.rb +32 -0
- data/lib/tilia/v_object/splitter/i_calendar.rb +95 -0
- data/lib/tilia/v_object/splitter/splitter_interface.rb +31 -0
- data/lib/tilia/v_object/splitter/v_card.rb +56 -0
- data/lib/tilia/v_object/splitter.rb +9 -0
- data/lib/tilia/v_object/string_util.rb +58 -0
- data/lib/tilia/v_object/time_zone_data/exchange_zones.rb +96 -0
- data/lib/tilia/v_object/time_zone_data/lotus_zones.rb +104 -0
- data/lib/tilia/v_object/time_zone_data/php_zones.rb +49 -0
- data/lib/tilia/v_object/time_zone_data/windows_zones.rb +121 -0
- data/lib/tilia/v_object/time_zone_data.rb +10 -0
- data/lib/tilia/v_object/time_zone_util.rb +213 -0
- data/lib/tilia/v_object/uuid_util.rb +51 -0
- data/lib/tilia/v_object/v_card_converter.rb +354 -0
- data/lib/tilia/v_object/version.rb +9 -0
- data/lib/tilia/v_object/writer.rb +56 -0
- data/lib/tilia/v_object.rb +45 -0
- data/lib/tilia/vobject.rb +1 -0
- data/resources/schema/xcal.rng +1192 -0
- data/resources/schema/xcard.rng +388 -0
- data/test/test_helper.rb +56 -0
- data/test/v_object/attach_issue_test.rb +19 -0
- data/test/v_object/birthday_calendar_generator_test.rb +463 -0
- data/test/v_object/cli_mock.rb +19 -0
- data/test/v_object/cli_test.rb +460 -0
- data/test/v_object/component/available_test.rb +59 -0
- data/test/v_object/component/v_alarm_test.rb +160 -0
- data/test/v_object/component/v_availability_test.rb +388 -0
- data/test/v_object/component/v_calendar_test.rb +646 -0
- data/test/v_object/component/v_card_test.rb +258 -0
- data/test/v_object/component/v_event_test.rb +85 -0
- data/test/v_object/component/v_free_busy_test.rb +59 -0
- data/test/v_object/component/v_journal_test.rb +85 -0
- data/test/v_object/component/v_time_zone_test.rb +47 -0
- data/test/v_object/component/v_todo_test.rb +172 -0
- data/test/v_object/component_test.rb +419 -0
- data/test/v_object/date_time_parser_test.rb +526 -0
- data/test/v_object/document_test.rb +71 -0
- data/test/v_object/element_list_test.rb +27 -0
- data/test/v_object/em_client_test.rb +53 -0
- data/test/v_object/empty_parameter_test.rb +65 -0
- data/test/v_object/empty_value_issue_test.rb +25 -0
- data/test/v_object/fake_component.rb +21 -0
- data/test/v_object/free_busy_data_test.rb +285 -0
- data/test/v_object/free_busy_generator_test.rb +637 -0
- data/test/v_object/google_colon_escaping_test.rb +27 -0
- data/test/v_object/i_calendar/attach_parse_test.rb +24 -0
- data/test/v_object/i_tip/broker_attendee_reply_test.rb +1042 -0
- data/test/v_object/i_tip/broker_delete_event_test.rb +175 -0
- data/test/v_object/i_tip/broker_new_event_test.rb +440 -0
- data/test/v_object/i_tip/broker_process_message_test.rb +153 -0
- data/test/v_object/i_tip/broker_process_reply_test.rb +402 -0
- data/test/v_object/i_tip/broker_tester.rb +71 -0
- data/test/v_object/i_tip/broker_update_event_test.rb +763 -0
- data/test/v_object/i_tip/evolution_test.rb +2644 -0
- data/test/v_object/i_tip/message_test.rb +25 -0
- data/test/v_object/issue153.vcf +352 -0
- data/test/v_object/issue153_test.rb +12 -0
- data/test/v_object/issue26_test.rb +25 -0
- data/test/v_object/issue36_work_around_test.rb +37 -0
- data/test/v_object/issue40_test.rb +26 -0
- data/test/v_object/issue64.vcf +351 -0
- data/test/v_object/issue64_test.rb +17 -0
- data/test/v_object/issue96_test.rb +22 -0
- data/test/v_object/issue_undefined_index_test.rb +24 -0
- data/test/v_object/j_cal_test.rb +150 -0
- data/test/v_object/j_card_test.rb +192 -0
- data/test/v_object/line_folding_issue_test.rb +19 -0
- data/test/v_object/mock_document.rb +6 -0
- data/test/v_object/parameter_test.rb +109 -0
- data/test/v_object/parser/json_test.rb +370 -0
- data/test/v_object/parser/mime_dir_test.rb +14 -0
- data/test/v_object/parser/quoted_printable_test.rb +78 -0
- data/test/v_object/parser/xml_test.rb +2563 -0
- data/test/v_object/property/binary_test.rb +12 -0
- data/test/v_object/property/boolean_test.rb +18 -0
- data/test/v_object/property/compound_test.rb +43 -0
- data/test/v_object/property/float_test.rb +20 -0
- data/test/v_object/property/i_calendar/cal_address_test.rb +26 -0
- data/test/v_object/property/i_calendar/date_time_test.rb +303 -0
- data/test/v_object/property/i_calendar/duration_test.rb +14 -0
- data/test/v_object/property/i_calendar/recur_test.rb +39 -0
- data/test/v_object/property/text_test.rb +81 -0
- data/test/v_object/property/v_card/date_and_or_time_test.rb +205 -0
- data/test/v_object/property/v_card/language_tag_test.rb +35 -0
- data/test/v_object/property_test.rb +338 -0
- data/test/v_object/reader_test.rb +403 -0
- data/test/v_object/recur/event_iterator/by_month_in_daily_test.rb +52 -0
- data/test/v_object/recur/event_iterator/by_set_pos_hang_test.rb +55 -0
- data/test/v_object/recur/event_iterator/expand_floating_times_test.rb +109 -0
- data/test/v_object/recur/event_iterator/fifth_tuesday_problem_test.rb +45 -0
- data/test/v_object/recur/event_iterator/incorrect_expand_test.rb +53 -0
- data/test/v_object/recur/event_iterator/infinite_loop_problem_test.rb +75 -0
- data/test/v_object/recur/event_iterator/issue48_test.rb +43 -0
- data/test/v_object/recur/event_iterator/issue50_test.rb +123 -0
- data/test/v_object/recur/event_iterator/main_test.rb +1222 -0
- data/test/v_object/recur/event_iterator/missing_overridden_test.rb +55 -0
- data/test/v_object/recur/event_iterator/no_instances_test.rb +32 -0
- data/test/v_object/recur/event_iterator/override_first_event_test.rb +106 -0
- data/test/v_object/recur/r_date_iterator_test.rb +44 -0
- data/test/v_object/recur/r_rule_iterator_test.rb +608 -0
- data/test/v_object/recurrence_iterator/UntilRespectsTimezoneTest.ics +39 -0
- data/test/v_object/slash_r_test.rb +15 -0
- data/test/v_object/splitter/i_calendar_test.rb +299 -0
- data/test/v_object/splitter/v_card_test.rb +173 -0
- data/test/v_object/string_util_test.rb +37 -0
- data/test/v_object/test_case.rb +42 -0
- data/test/v_object/time_zone_util_test.rb +271 -0
- data/test/v_object/uuid_util_test.rb +18 -0
- data/test/v_object/v_card21_test.rb +43 -0
- data/test/v_object/v_card_converter_test.rb +419 -0
- data/test/v_object/version_test.rb +15 -0
- data/test/v_object/writer_test.rb +33 -0
- data/tilia-vobject.gemspec +17 -0
- metadata +308 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Tilia
|
5
|
+
module VObject
|
6
|
+
class EmptyParameterTest < Minitest::Test
|
7
|
+
def test_read
|
8
|
+
input = <<VCF
|
9
|
+
BEGIN:VCARD
|
10
|
+
VERSION:2.1
|
11
|
+
N:Doe;Jon;;;
|
12
|
+
FN:Jon Doe
|
13
|
+
EMAIL;X-INTERN:foo@example.org
|
14
|
+
UID:foo
|
15
|
+
END:VCARD
|
16
|
+
VCF
|
17
|
+
vcard = Tilia::VObject::Reader.read(input)
|
18
|
+
|
19
|
+
assert_kind_of(Tilia::VObject::Component::VCard, vcard)
|
20
|
+
vcard = vcard.convert(Tilia::VObject::Document::VCARD30)
|
21
|
+
vcard = vcard.serialize
|
22
|
+
|
23
|
+
converted = Tilia::VObject::Reader.read(vcard)
|
24
|
+
converted.validate
|
25
|
+
|
26
|
+
assert(converted['EMAIL'].key?('X-INTERN'))
|
27
|
+
|
28
|
+
version = Tilia::VObject::Version::VERSION
|
29
|
+
|
30
|
+
expected = <<VCF
|
31
|
+
BEGIN:VCARD
|
32
|
+
VERSION:3.0
|
33
|
+
PRODID:-//Tilia//Tilia VObject #{version}//EN
|
34
|
+
N:Doe;Jon;;;
|
35
|
+
FN:Jon Doe
|
36
|
+
EMAIL;X-INTERN=:foo@example.org
|
37
|
+
UID:foo
|
38
|
+
END:VCARD
|
39
|
+
VCF
|
40
|
+
|
41
|
+
assert_equal(expected, vcard.delete("\r"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_v_card21_parameter
|
45
|
+
vcard = Tilia::VObject::Component::VCard.new({}, false)
|
46
|
+
vcard['VERSION'] = '2.1'
|
47
|
+
vcard['PHOTO'] = 'random_stuff'
|
48
|
+
vcard['PHOTO'].add(nil, 'BASE64')
|
49
|
+
vcard['UID'] = 'foo-bar'
|
50
|
+
|
51
|
+
result = vcard.serialize
|
52
|
+
expected = [
|
53
|
+
'BEGIN:VCARD',
|
54
|
+
'VERSION:2.1',
|
55
|
+
'PHOTO;BASE64:' + Base64.strict_encode64('random_stuff'),
|
56
|
+
'UID:foo-bar',
|
57
|
+
'END:VCARD',
|
58
|
+
''
|
59
|
+
]
|
60
|
+
|
61
|
+
assert_equal(expected.join("\r\n"), result)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tilia
|
4
|
+
module VObject
|
5
|
+
# This test is written for Issue 68:
|
6
|
+
#
|
7
|
+
# https://github.com/fruux/sabre-vobject/issues/68
|
8
|
+
class EmptyValueIssueTest < Minitest::Test
|
9
|
+
def test_decode_value
|
10
|
+
input = <<ICS
|
11
|
+
BEGIN:VCALENDAR
|
12
|
+
VERSION:2.0
|
13
|
+
BEGIN:VEVENT
|
14
|
+
DESCRIPTION:This is a descpription\\nwith a linebreak and a \\; \\, and :
|
15
|
+
END:VEVENT
|
16
|
+
END:VCALENDAR
|
17
|
+
ICS
|
18
|
+
vobj = Tilia::VObject::Reader.read(input)
|
19
|
+
|
20
|
+
# Before this bug was fixed, self.value would return nothing.
|
21
|
+
assert_equal("This is a descpription\nwith a linebreak and a ; , and :", vobj['VEVENT']['DESCRIPTION'].value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Tilia
|
2
|
+
module VObject
|
3
|
+
class FakeComponent < Component
|
4
|
+
def validation_rules
|
5
|
+
{
|
6
|
+
'FOO' => '0',
|
7
|
+
'BAR' => '1',
|
8
|
+
'BAZ' => '+',
|
9
|
+
'ZIM' => '*',
|
10
|
+
'GIR' => '?'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def defaults
|
15
|
+
{
|
16
|
+
'BAR' => 'yow'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,285 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Tilia
|
4
|
+
module VObject
|
5
|
+
class FreeBusyDataTest < Minitest::Test
|
6
|
+
def test_get_data
|
7
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
8
|
+
|
9
|
+
assert_equal(
|
10
|
+
[
|
11
|
+
{
|
12
|
+
'start' => 100,
|
13
|
+
'end' => 200,
|
14
|
+
'type' => 'FREE'
|
15
|
+
}
|
16
|
+
],
|
17
|
+
fb.data
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_add_beginning
|
22
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
23
|
+
|
24
|
+
# Overwriting the first half
|
25
|
+
fb.add(100, 150, 'BUSY')
|
26
|
+
|
27
|
+
assert_equal(
|
28
|
+
[
|
29
|
+
{
|
30
|
+
'start' => 100,
|
31
|
+
'end' => 150,
|
32
|
+
'type' => 'BUSY'
|
33
|
+
},
|
34
|
+
{
|
35
|
+
'start' => 150,
|
36
|
+
'end' => 200,
|
37
|
+
'type' => 'FREE'
|
38
|
+
}
|
39
|
+
],
|
40
|
+
fb.data
|
41
|
+
)
|
42
|
+
|
43
|
+
# Overwriting the first half again
|
44
|
+
fb.add(100, 150, 'BUSY-TENTATIVE')
|
45
|
+
|
46
|
+
assert_equal(
|
47
|
+
[
|
48
|
+
{
|
49
|
+
'start' => 100,
|
50
|
+
'end' => 150,
|
51
|
+
'type' => 'BUSY-TENTATIVE'
|
52
|
+
},
|
53
|
+
{
|
54
|
+
'start' => 150,
|
55
|
+
'end' => 200,
|
56
|
+
'type' => 'FREE'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
fb.data
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_add_end
|
64
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
65
|
+
|
66
|
+
# Overwriting the first half
|
67
|
+
fb.add(150, 200, 'BUSY')
|
68
|
+
|
69
|
+
assert_equal(
|
70
|
+
[
|
71
|
+
{
|
72
|
+
'start' => 100,
|
73
|
+
'end' => 150,
|
74
|
+
'type' => 'FREE'
|
75
|
+
},
|
76
|
+
{
|
77
|
+
'start' => 150,
|
78
|
+
'end' => 200,
|
79
|
+
'type' => 'BUSY'
|
80
|
+
}
|
81
|
+
],
|
82
|
+
fb.data
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_add_middle
|
87
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
88
|
+
|
89
|
+
# Overwriting the first half
|
90
|
+
fb.add(150, 160, 'BUSY')
|
91
|
+
|
92
|
+
assert_equal(
|
93
|
+
[
|
94
|
+
{
|
95
|
+
'start' => 100,
|
96
|
+
'end' => 150,
|
97
|
+
'type' => 'FREE'
|
98
|
+
},
|
99
|
+
{
|
100
|
+
'start' => 150,
|
101
|
+
'end' => 160,
|
102
|
+
'type' => 'BUSY'
|
103
|
+
},
|
104
|
+
{
|
105
|
+
'start' => 160,
|
106
|
+
'end' => 200,
|
107
|
+
'type' => 'FREE'
|
108
|
+
}
|
109
|
+
],
|
110
|
+
fb.data
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_add_multiple
|
115
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
116
|
+
|
117
|
+
fb.add(110, 120, 'BUSY')
|
118
|
+
fb.add(130, 140, 'BUSY')
|
119
|
+
|
120
|
+
assert_equal(
|
121
|
+
[
|
122
|
+
{
|
123
|
+
'start' => 100,
|
124
|
+
'end' => 110,
|
125
|
+
'type' => 'FREE'
|
126
|
+
},
|
127
|
+
{
|
128
|
+
'start' => 110,
|
129
|
+
'end' => 120,
|
130
|
+
'type' => 'BUSY'
|
131
|
+
},
|
132
|
+
{
|
133
|
+
'start' => 120,
|
134
|
+
'end' => 130,
|
135
|
+
'type' => 'FREE'
|
136
|
+
},
|
137
|
+
{
|
138
|
+
'start' => 130,
|
139
|
+
'end' => 140,
|
140
|
+
'type' => 'BUSY'
|
141
|
+
},
|
142
|
+
{
|
143
|
+
'start' => 140,
|
144
|
+
'end' => 200,
|
145
|
+
'type' => 'FREE'
|
146
|
+
}
|
147
|
+
],
|
148
|
+
fb.data
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_add_multiple_overlap
|
153
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
154
|
+
|
155
|
+
fb.add(110, 120, 'BUSY')
|
156
|
+
fb.add(130, 140, 'BUSY')
|
157
|
+
|
158
|
+
assert_equal(
|
159
|
+
[
|
160
|
+
{
|
161
|
+
'start' => 100,
|
162
|
+
'end' => 110,
|
163
|
+
'type' => 'FREE'
|
164
|
+
},
|
165
|
+
{
|
166
|
+
'start' => 110,
|
167
|
+
'end' => 120,
|
168
|
+
'type' => 'BUSY'
|
169
|
+
},
|
170
|
+
{
|
171
|
+
'start' => 120,
|
172
|
+
'end' => 130,
|
173
|
+
'type' => 'FREE'
|
174
|
+
},
|
175
|
+
{
|
176
|
+
'start' => 130,
|
177
|
+
'end' => 140,
|
178
|
+
'type' => 'BUSY'
|
179
|
+
},
|
180
|
+
{
|
181
|
+
'start' => 140,
|
182
|
+
'end' => 200,
|
183
|
+
'type' => 'FREE'
|
184
|
+
}
|
185
|
+
],
|
186
|
+
fb.data
|
187
|
+
)
|
188
|
+
|
189
|
+
fb.add(115, 135, 'BUSY-TENTATIVE')
|
190
|
+
|
191
|
+
assert_equal(
|
192
|
+
[
|
193
|
+
{
|
194
|
+
'start' => 100,
|
195
|
+
'end' => 110,
|
196
|
+
'type' => 'FREE'
|
197
|
+
},
|
198
|
+
{
|
199
|
+
'start' => 110,
|
200
|
+
'end' => 115,
|
201
|
+
'type' => 'BUSY'
|
202
|
+
},
|
203
|
+
{
|
204
|
+
'start' => 115,
|
205
|
+
'end' => 135,
|
206
|
+
'type' => 'BUSY-TENTATIVE'
|
207
|
+
},
|
208
|
+
{
|
209
|
+
'start' => 135,
|
210
|
+
'end' => 140,
|
211
|
+
'type' => 'BUSY'
|
212
|
+
},
|
213
|
+
{
|
214
|
+
'start' => 140,
|
215
|
+
'end' => 200,
|
216
|
+
'type' => 'FREE'
|
217
|
+
}
|
218
|
+
],
|
219
|
+
fb.data
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_add_multiple_overlap_and_merge
|
224
|
+
fb = Tilia::VObject::FreeBusyData.new(100, 200)
|
225
|
+
|
226
|
+
fb.add(110, 120, 'BUSY')
|
227
|
+
fb.add(130, 140, 'BUSY')
|
228
|
+
|
229
|
+
assert_equal(
|
230
|
+
[
|
231
|
+
{
|
232
|
+
'start' => 100,
|
233
|
+
'end' => 110,
|
234
|
+
'type' => 'FREE'
|
235
|
+
},
|
236
|
+
{
|
237
|
+
'start' => 110,
|
238
|
+
'end' => 120,
|
239
|
+
'type' => 'BUSY'
|
240
|
+
},
|
241
|
+
{
|
242
|
+
'start' => 120,
|
243
|
+
'end' => 130,
|
244
|
+
'type' => 'FREE'
|
245
|
+
},
|
246
|
+
{
|
247
|
+
'start' => 130,
|
248
|
+
'end' => 140,
|
249
|
+
'type' => 'BUSY'
|
250
|
+
},
|
251
|
+
{
|
252
|
+
'start' => 140,
|
253
|
+
'end' => 200,
|
254
|
+
'type' => 'FREE'
|
255
|
+
}
|
256
|
+
],
|
257
|
+
fb.data
|
258
|
+
)
|
259
|
+
|
260
|
+
fb.add(115, 135, 'BUSY')
|
261
|
+
|
262
|
+
assert_equal(
|
263
|
+
[
|
264
|
+
{
|
265
|
+
'start' => 100,
|
266
|
+
'end' => 110,
|
267
|
+
'type' => 'FREE'
|
268
|
+
},
|
269
|
+
{
|
270
|
+
'start' => 110,
|
271
|
+
'end' => 140,
|
272
|
+
'type' => 'BUSY'
|
273
|
+
},
|
274
|
+
{
|
275
|
+
'start' => 140,
|
276
|
+
'end' => 200,
|
277
|
+
'type' => 'FREE'
|
278
|
+
}
|
279
|
+
],
|
280
|
+
fb.data
|
281
|
+
)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|