paulsm-icalendar 1.1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +56 -0
- data/GPL +340 -0
- data/README +266 -0
- data/Rakefile +109 -0
- data/docs/rfcs/itip_notes.txt +69 -0
- data/docs/rfcs/rfc2425.pdf +0 -0
- data/docs/rfcs/rfc2426.pdf +0 -0
- data/docs/rfcs/rfc2445.pdf +0 -0
- data/docs/rfcs/rfc2446.pdf +0 -0
- data/docs/rfcs/rfc2447.pdf +0 -0
- data/docs/rfcs/rfc3283.txt +738 -0
- data/examples/create_cal.rb +45 -0
- data/examples/parse_cal.rb +20 -0
- data/examples/single_event.ics +18 -0
- data/lib/hash_attrs.rb +34 -0
- data/lib/icalendar.rb +39 -0
- data/lib/icalendar/base.rb +43 -0
- data/lib/icalendar/calendar.rb +113 -0
- data/lib/icalendar/component.rb +442 -0
- data/lib/icalendar/component/alarm.rb +44 -0
- data/lib/icalendar/component/event.rb +129 -0
- data/lib/icalendar/component/freebusy.rb +38 -0
- data/lib/icalendar/component/journal.rb +61 -0
- data/lib/icalendar/component/timezone.rb +105 -0
- data/lib/icalendar/component/todo.rb +64 -0
- data/lib/icalendar/conversions.rb +150 -0
- data/lib/icalendar/helpers.rb +109 -0
- data/lib/icalendar/parameter.rb +33 -0
- data/lib/icalendar/parser.rb +396 -0
- data/lib/icalendar/rrule.rb +126 -0
- data/lib/icalendar/tzinfo.rb +121 -0
- data/lib/meta.rb +32 -0
- data/test/calendar_test.rb +71 -0
- data/test/component/event_test.rb +256 -0
- data/test/component/timezone_test.rb +67 -0
- data/test/component/todo_test.rb +13 -0
- data/test/component_test.rb +76 -0
- data/test/conversions_test.rb +97 -0
- data/test/coverage/STUB +0 -0
- data/test/fixtures/folding.ics +23 -0
- data/test/fixtures/life.ics +46 -0
- data/test/fixtures/simplecal.ics +119 -0
- data/test/fixtures/single_event.ics +23 -0
- data/test/interactive.rb +17 -0
- data/test/parameter_test.rb +29 -0
- data/test/parser_test.rb +84 -0
- data/test/read_write.rb +23 -0
- metadata +108 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'icalendar'
|
5
|
+
|
6
|
+
class TestTimezone < Test::Unit::TestCase
|
7
|
+
|
8
|
+
# Create a calendar with an event for each test.
|
9
|
+
def setup
|
10
|
+
@cal = Icalendar::Calendar.new
|
11
|
+
# Define a test timezone
|
12
|
+
@testTimezone = %Q(BEGIN:VTIMEZONE\r\nTZID:America/Chicago\r\nBEGIN:STANDARD\r\nTZOFFSETTO:-0600\r\nRRULE:FREQ=YEARLY\\;BYMONTH=11\\;BYDAY=1SU\r\nDTSTART:19701101T020000\r\nTZOFFSETFROM:-0500\r\nTZNAME:CST\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nTZOFFSETTO:-0500\r\nRRULE:FREQ=YEARLY\\;BYMONTH=3\\;BYDAY=2SU\r\nDTSTART:19700308TO20000\r\nTZOFFSETFROM:-0600\r\nTZNAME:CDT\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\n)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_new
|
16
|
+
@tz = Icalendar::Timezone.new
|
17
|
+
assert(@tz)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_raw_generation
|
21
|
+
timezone = Icalendar::Timezone.new
|
22
|
+
daylight = Icalendar::Daylight.new
|
23
|
+
standard = Icalendar::Standard.new
|
24
|
+
|
25
|
+
timezone.timezone_id = "America/Chicago"
|
26
|
+
|
27
|
+
daylight.timezone_offset_from = "-0600"
|
28
|
+
daylight.timezone_offset_to = "-0500"
|
29
|
+
daylight.timezone_name = "CDT"
|
30
|
+
daylight.dtstart = "19700308TO20000"
|
31
|
+
daylight.recurrence_rules = ["FREQ=YEARLY;BYMONTH=3;BYDAY=2SU"]
|
32
|
+
|
33
|
+
standard.timezone_offset_from = "-0500"
|
34
|
+
standard.timezone_offset_to = "-0600"
|
35
|
+
standard.timezone_name = "CST"
|
36
|
+
standard.dtstart = "19701101T020000"
|
37
|
+
standard.recurrence_rules = ["FREQ=YEARLY;BYMONTH=11;BYDAY=1SU"]
|
38
|
+
|
39
|
+
timezone.add(standard)
|
40
|
+
timezone.add(daylight)
|
41
|
+
@cal.add(timezone)
|
42
|
+
assert_equal(@testTimezone, @cal.timezones.first.to_ical)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_block_creation
|
46
|
+
@cal.timezone do
|
47
|
+
timezone_id "America/Chicago"
|
48
|
+
|
49
|
+
daylight do
|
50
|
+
timezone_offset_from "-0600"
|
51
|
+
timezone_offset_to "-0500"
|
52
|
+
timezone_name "CDT"
|
53
|
+
dtstart "19700308TO20000"
|
54
|
+
add_recurrence_rule "FREQ=YEARLY;BYMONTH=3;BYDAY=2SU"
|
55
|
+
end
|
56
|
+
|
57
|
+
standard do
|
58
|
+
timezone_offset_from "-0500"
|
59
|
+
timezone_offset_to "-0600"
|
60
|
+
timezone_name "CST"
|
61
|
+
dtstart "19701101T020000"
|
62
|
+
add_recurrence_rule "FREQ=YEARLY;BYMONTH=11;BYDAY=1SU"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
assert_equal(@testTimezone, @cal.timezones.first.to_ical)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'icalendar'
|
6
|
+
|
7
|
+
class TestComponent < Test::Unit::TestCase
|
8
|
+
|
9
|
+
# Create a calendar with an event for each test.
|
10
|
+
def setup
|
11
|
+
@cal = Icalendar::Calendar.new
|
12
|
+
@event = Icalendar::Event.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_add_remove_component
|
16
|
+
@cal.add_component(@event)
|
17
|
+
assert_equal(1, @cal.events.size)
|
18
|
+
@cal.remove_component(@event)
|
19
|
+
assert_equal(0, @cal.events.size)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_ical_property
|
23
|
+
# No alias but it does have a prop_name
|
24
|
+
assert_equal(false, @event.ip_class?)
|
25
|
+
@event.ip_class = "PRIVATE"
|
26
|
+
assert_equal(true, @event.ip_class?)
|
27
|
+
assert_equal("PRIVATE", @event.ip_class)
|
28
|
+
|
29
|
+
# Check that both dtend and its alias start work correctly
|
30
|
+
date = DateTime.new(2005, 02, 05, 23, 24, 25)
|
31
|
+
@event.dtend = date
|
32
|
+
assert_equal(date.year, @event.dtend.year)
|
33
|
+
|
34
|
+
date2 = DateTime.new(2005, 02, 05, 23, 24, 26)
|
35
|
+
@event.end = date2
|
36
|
+
assert_equal(date2.year, @event.end.year)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_ical_multi_property
|
40
|
+
# Query
|
41
|
+
assert_equal(false, @event.comments?)
|
42
|
+
@event.comments = []
|
43
|
+
assert_equal(true, @event.comments?)
|
44
|
+
|
45
|
+
# Should return an empty array, rather than nil
|
46
|
+
assert_equal(0, @event.comments.size)
|
47
|
+
|
48
|
+
# Add and remove
|
49
|
+
@event.add_comment "c1"
|
50
|
+
@event.add_comment "c2"
|
51
|
+
assert_equal(2, @event.comments.size)
|
52
|
+
assert_equal(["c1","c2"], @event.comments)
|
53
|
+
@event.remove_comment "c1"
|
54
|
+
assert_equal(["c2"], @event.comments)
|
55
|
+
|
56
|
+
# Set & get whole array
|
57
|
+
foo = ["as", "df"]
|
58
|
+
@event.comments = foo
|
59
|
+
assert_equal(foo, @event.comments)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_x_property
|
63
|
+
@event.x_foobar = "my-custom-property"
|
64
|
+
assert_equal("my-custom-property", @event.x_foobar)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_respond_to_missing
|
68
|
+
component = Icalendar::Component.new('name')
|
69
|
+
assert !component.respond_to?(:there_is_no_such_method)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_respond_to_x_property
|
73
|
+
component = Icalendar::Component.new('name')
|
74
|
+
assert component.respond_to?(:x_foobar)
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'icalendar'
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
class TestConversions < Test::Unit::TestCase
|
9
|
+
include Icalendar
|
10
|
+
|
11
|
+
RESULT = <<EOS
|
12
|
+
BEGIN:VCALENDAR
|
13
|
+
VERSION:2.0
|
14
|
+
CALSCALE:GREGORIAN
|
15
|
+
PRODID:iCalendar-Ruby
|
16
|
+
BEGIN:VEVENT
|
17
|
+
SEQUENCE:2
|
18
|
+
ORGANIZER:mailto:joe@example.com?subject=Ruby
|
19
|
+
DTSTART:20060720
|
20
|
+
UID:foobar
|
21
|
+
X-TIME-OF-DAY:101736
|
22
|
+
GEO:46.01\\;8.57
|
23
|
+
DTSTAMP:20060720T174052
|
24
|
+
CATEGORIES:foo\\,bar\\,baz
|
25
|
+
DESCRIPTION:desc
|
26
|
+
LAST-MODIFIED:19960817T133000
|
27
|
+
END:VEVENT
|
28
|
+
END:VCALENDAR
|
29
|
+
EOS
|
30
|
+
|
31
|
+
def setup
|
32
|
+
@cal = Calendar.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_to_ical_conversions
|
36
|
+
@cal.event do
|
37
|
+
# String
|
38
|
+
description "desc"
|
39
|
+
|
40
|
+
# Fixnum
|
41
|
+
sequence 2
|
42
|
+
|
43
|
+
# Float by way of Geo class
|
44
|
+
geo(Geo.new(46.01, 8.57))
|
45
|
+
|
46
|
+
# Array
|
47
|
+
categories ["foo", "bar"]
|
48
|
+
add_category "baz"
|
49
|
+
|
50
|
+
# Last Modified
|
51
|
+
last_modified DateTime.parse("1996-08-17T13:30:00")
|
52
|
+
|
53
|
+
# URI
|
54
|
+
organizer(URI::MailTo.build(['joe@example.com', 'subject=Ruby']))
|
55
|
+
|
56
|
+
# Date
|
57
|
+
start Date.parse("2006-07-20")
|
58
|
+
|
59
|
+
# DateTime
|
60
|
+
timestamp DateTime.parse("2006-07-20T17:40:52+0200")
|
61
|
+
|
62
|
+
# Time
|
63
|
+
x_time_of_day Time.at(123456).utc
|
64
|
+
|
65
|
+
uid "foobar"
|
66
|
+
end
|
67
|
+
|
68
|
+
assert_equal(RESULT.gsub("\n", "\r\n"), @cal.to_ical)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_to_ical_folding
|
72
|
+
@cal.x_wr_calname = 'Test Long Description'
|
73
|
+
|
74
|
+
@cal.event do
|
75
|
+
url 'http://test.com/events/644'
|
76
|
+
dtend DateTime.parse('20061215T180000')
|
77
|
+
dtstart DateTime.parse('20061215T160000')
|
78
|
+
timestamp DateTime.parse('20061215T114034')
|
79
|
+
seq 1001
|
80
|
+
uid 'foobar'
|
81
|
+
summary 'DigiWorld 2006'
|
82
|
+
|
83
|
+
description "FULL DETAILS:\nhttp://test.com/events/570\n\n" +
|
84
|
+
"Cary Brothers walks the same musical ground as Pete Yorn, Nick Drake, " +
|
85
|
+
"Jeff Buckley and others; crafting emotional melodies, with strong vocals " +
|
86
|
+
"and thoughtful lyrics. Brett Dennen has "that thing." " +
|
87
|
+
"Inspired fans describe it: "lush shimmering vocals, an intricately " +
|
88
|
+
"groovin' guitar style, a lyrical beauty rare in a young songwriter," +
|
89
|
+
"" and "this soulful blend of everything that feels good." " +
|
90
|
+
"Rising up around him is music; transcending genres, genders and generations."
|
91
|
+
end
|
92
|
+
|
93
|
+
folded = File.read(File.join(File.dirname(__FILE__), 'fixtures/folding.ics')).gsub("\n", "\r\n")
|
94
|
+
assert_equal(folded, @cal.to_ical)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data/test/coverage/STUB
ADDED
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION:2.0
|
3
|
+
CALSCALE:GREGORIAN
|
4
|
+
PRODID:iCalendar-Ruby
|
5
|
+
X-WR-CALNAME:Test Long Description
|
6
|
+
BEGIN:VEVENT
|
7
|
+
SEQUENCE:1001
|
8
|
+
DTEND:20061215T180000
|
9
|
+
URL:http://test.com/events/644
|
10
|
+
DTSTART:20061215T160000
|
11
|
+
UID:foobar
|
12
|
+
DTSTAMP:20061215T114034
|
13
|
+
DESCRIPTION:FULL DETAILS:\nhttp://test.com/events/570\n\nCary Brothers walk
|
14
|
+
s the same musical ground as Pete Yorn\, Nick Drake\, Jeff Buckley and othe
|
15
|
+
rs\; crafting emotional melodies\, with strong vocals and thoughtful lyrics
|
16
|
+
. Brett Dennen has "\;that thing."\; Inspired fans describe it: &qu
|
17
|
+
ot\;lush shimmering vocals\, an intricately groovin'\; guitar style\, a
|
18
|
+
lyrical beauty rare in a young songwriter\,"\; and "\;this soulful
|
19
|
+
blend of everything that feels good."\; Rising up around him is music\;
|
20
|
+
transcending genres\, genders and generations.
|
21
|
+
SUMMARY:DigiWorld 2006
|
22
|
+
END:VEVENT
|
23
|
+
END:VCALENDAR
|
@@ -0,0 +1,46 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION:2.0
|
3
|
+
X-WR-CALNAME:Life
|
4
|
+
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
|
5
|
+
X-WR-RELCALID:69FB0467-7E07-4DE7-901D-B70242B3DB25
|
6
|
+
X-WR-TIMEZONE:America/Chicago
|
7
|
+
CALSCALE:GREGORIAN
|
8
|
+
METHOD:PUBLISH
|
9
|
+
BEGIN:VTIMEZONE
|
10
|
+
TZID:America/Chicago
|
11
|
+
LAST-MODIFIED:20050825T194346Z
|
12
|
+
BEGIN:DAYLIGHT
|
13
|
+
DTSTART:20050403T080000
|
14
|
+
TZOFFSETTO:-0500
|
15
|
+
TZOFFSETFROM:+0000
|
16
|
+
TZNAME:CDT
|
17
|
+
END:DAYLIGHT
|
18
|
+
BEGIN:STANDARD
|
19
|
+
DTSTART:20051030T020000
|
20
|
+
TZOFFSETTO:-0600
|
21
|
+
TZOFFSETFROM:-0500
|
22
|
+
TZNAME:CST
|
23
|
+
END:STANDARD
|
24
|
+
END:VTIMEZONE
|
25
|
+
BEGIN:VEVENT
|
26
|
+
UID:bsuidfortestabc123
|
27
|
+
ORGANIZER:mailto:joebob@random.net
|
28
|
+
ATTACH:http://bush.sucks.org/impeach/him.rhtml
|
29
|
+
ATTACH:http://corporations-dominate.existence.net/why.rhtml
|
30
|
+
LAST-MODIFIED:20050825T194346Z
|
31
|
+
SUMMARY:This is a really long summary
|
32
|
+
to test the method of unfolding lines
|
33
|
+
so I'm just going to ma
|
34
|
+
ke it
|
35
|
+
a whol
|
36
|
+
e
|
37
|
+
bunch of lines.
|
38
|
+
CLASS:PRIVATE
|
39
|
+
PRIORITY:2
|
40
|
+
GEO:37.386013;-122.0829322
|
41
|
+
DTSTART;TZID=US-Mountain:20050120T170000
|
42
|
+
DTEND:20050120T184500
|
43
|
+
DTSTAMP:20050118T211523Z
|
44
|
+
END:VEVENT
|
45
|
+
END:VCALENDAR
|
46
|
+
|
@@ -0,0 +1,119 @@
|
|
1
|
+
BEGIN:VCALENDAR
|
2
|
+
VERSION
|
3
|
+
:2.0
|
4
|
+
PRODID
|
5
|
+
:-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
|
6
|
+
BEGIN:VEVENT
|
7
|
+
UID
|
8
|
+
:a08863de-1dd1-11b2-9445-d6248402dd19
|
9
|
+
SUMMARY
|
10
|
+
:Hybrid Embedded Systems. This is a really long summary
|
11
|
+
to test the method of unfolding lines
|
12
|
+
so I'm just going to ma
|
13
|
+
ke it
|
14
|
+
a whole
|
15
|
+
bunch of lines.
|
16
|
+
CATEGORIES
|
17
|
+
:Personal
|
18
|
+
STATUS
|
19
|
+
:CONFIRMED
|
20
|
+
CLASS
|
21
|
+
:PRIVATE
|
22
|
+
RRULE
|
23
|
+
:FREQ=WEEKLY;INTERVAL=1;BYDAY=TH
|
24
|
+
DTSTART
|
25
|
+
:20050120T170000
|
26
|
+
DTEND
|
27
|
+
:20050120T184500
|
28
|
+
DTSTAMP
|
29
|
+
:20050118T211523Z
|
30
|
+
END:VEVENT
|
31
|
+
BEGIN:VEVENT
|
32
|
+
UID
|
33
|
+
:6226e2f6-1dd2-11b2-9ad7-9b8d2d642229
|
34
|
+
SUMMARY
|
35
|
+
:Databases
|
36
|
+
LOCATION
|
37
|
+
:ECCS 1b12
|
38
|
+
CATEGORIES
|
39
|
+
:Personal
|
40
|
+
STATUS
|
41
|
+
:CONFIRMED
|
42
|
+
CLASS
|
43
|
+
:PRIVATE
|
44
|
+
X-MOZILLA-ALARM-DEFAULT-LENGTH
|
45
|
+
:30
|
46
|
+
X-MOZILLA-LASTALARMACK
|
47
|
+
:20050118T141054
|
48
|
+
RRULE
|
49
|
+
:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE
|
50
|
+
DTSTART
|
51
|
+
:20050117T173000
|
52
|
+
DTEND
|
53
|
+
:20050117T184500
|
54
|
+
DTSTAMP
|
55
|
+
:20050118T210648Z
|
56
|
+
LAST-MODIFIED
|
57
|
+
:20050118T211954Z
|
58
|
+
BEGIN:VALARM
|
59
|
+
TRIGGER
|
60
|
+
;VALUE=DURATION
|
61
|
+
:-PT30M
|
62
|
+
END:VALARM
|
63
|
+
END:VEVENT
|
64
|
+
BEGIN:VEVENT
|
65
|
+
UID
|
66
|
+
:d8f4468a-1dd1-11b2-9e0a-bbe95143dbed
|
67
|
+
SUMMARY
|
68
|
+
:Software Radios
|
69
|
+
LOCATION
|
70
|
+
:ECCR 1b06
|
71
|
+
CATEGORIES
|
72
|
+
:Personal
|
73
|
+
STATUS
|
74
|
+
:CONFIRMED
|
75
|
+
CLASS
|
76
|
+
:PRIVATE
|
77
|
+
X-MOZILLA-ALARM-DEFAULT-LENGTH
|
78
|
+
:30
|
79
|
+
X-MOZILLA-LASTALARMACK
|
80
|
+
:20050118T141351
|
81
|
+
RRULE
|
82
|
+
:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE
|
83
|
+
DTSTART
|
84
|
+
:20050117T100000
|
85
|
+
DTEND
|
86
|
+
:20050117T111500
|
87
|
+
DTSTAMP
|
88
|
+
:20050118T211304Z
|
89
|
+
LAST-MODIFIED
|
90
|
+
:20050118T212016Z
|
91
|
+
BEGIN:VALARM
|
92
|
+
TRIGGER
|
93
|
+
;VALUE=DURATION
|
94
|
+
:-PT30M
|
95
|
+
END:VALARM
|
96
|
+
END:VEVENT
|
97
|
+
BEGIN:VEVENT
|
98
|
+
UID
|
99
|
+
:9acd4cc8-1dd1-11b2-a65e-b276ad1df3b9
|
100
|
+
SUMMARY
|
101
|
+
:Israel & Palestine peace accord talk...
|
102
|
+
LOCATION
|
103
|
+
:Chem. 140
|
104
|
+
CATEGORIES
|
105
|
+
:Personal
|
106
|
+
STATUS
|
107
|
+
:CONFIRMED
|
108
|
+
CLASS
|
109
|
+
:PRIVATE
|
110
|
+
DTSTART
|
111
|
+
:20050118T193000
|
112
|
+
DTEND
|
113
|
+
:20050118T203000
|
114
|
+
DTSTAMP
|
115
|
+
:20050118T212943Z
|
116
|
+
LAST-MODIFIED
|
117
|
+
:20050118T213355Z
|
118
|
+
END:VEVENT
|
119
|
+
END:VCALENDAR
|