icalendar 1.5.4 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/.rspec +2 -0
- data/.travis.yml +1 -2
- data/History.txt +2 -7
- data/README.md +82 -107
- data/Rakefile +6 -7
- data/icalendar.gemspec +10 -9
- data/lib/icalendar.rb +17 -33
- data/lib/icalendar/alarm.rb +35 -0
- data/lib/icalendar/calendar.rb +17 -100
- data/lib/icalendar/component.rb +41 -403
- data/lib/icalendar/event.rb +51 -0
- data/lib/icalendar/freebusy.rb +27 -0
- data/lib/icalendar/has_components.rb +83 -0
- data/lib/icalendar/has_properties.rb +156 -0
- data/lib/icalendar/journal.rb +39 -0
- data/lib/icalendar/parser.rb +75 -403
- data/lib/icalendar/timezone.rb +53 -0
- data/lib/icalendar/todo.rb +52 -0
- data/lib/icalendar/tzinfo.rb +30 -30
- data/lib/icalendar/value.rb +80 -0
- data/lib/icalendar/values/array.rb +43 -0
- data/lib/icalendar/values/binary.rb +31 -0
- data/lib/icalendar/values/boolean.rb +17 -0
- data/lib/icalendar/values/cal_address.rb +8 -0
- data/lib/icalendar/values/date.rb +26 -0
- data/lib/icalendar/values/date_time.rb +34 -0
- data/lib/icalendar/values/duration.rb +48 -0
- data/lib/icalendar/values/float.rb +17 -0
- data/lib/icalendar/values/integer.rb +17 -0
- data/lib/icalendar/values/period.rb +46 -0
- data/lib/icalendar/values/recur.rb +63 -0
- data/lib/icalendar/values/text.rb +26 -0
- data/lib/icalendar/values/time.rb +34 -0
- data/lib/icalendar/values/time_with_zone.rb +31 -0
- data/lib/icalendar/values/uri.rb +19 -0
- data/lib/icalendar/values/utc_offset.rb +39 -0
- data/lib/icalendar/version.rb +5 -0
- data/spec/alarm_spec.rb +108 -0
- data/spec/calendar_spec.rb +167 -0
- data/spec/event_spec.rb +108 -0
- data/{test/fixtures/folding.ics → spec/fixtures/nondefault_values.ics} +2 -2
- data/{test → spec}/fixtures/single_event.ics +11 -14
- data/spec/fixtures/timezone.ics +35 -0
- data/spec/freebusy_spec.rb +7 -0
- data/spec/journal_spec.rb +7 -0
- data/spec/parser_spec.rb +26 -0
- data/spec/roundtrip_spec.rb +40 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/timezone_spec.rb +31 -0
- data/spec/todo_spec.rb +24 -0
- data/spec/tzinfo_spec.rb +85 -0
- data/spec/values/date_time_spec.rb +80 -0
- data/spec/values/duration_spec.rb +67 -0
- data/spec/values/period_spec.rb +47 -0
- data/spec/values/recur_spec.rb +47 -0
- data/spec/values/text_spec.rb +72 -0
- data/spec/values/utc_offset_spec.rb +41 -0
- metadata +129 -88
- data/GPL +0 -340
- data/examples/create_cal.rb +0 -45
- data/examples/parse_cal.rb +0 -20
- data/examples/single_event.ics +0 -18
- data/lib/hash_attrs.rb +0 -34
- data/lib/icalendar/base.rb +0 -47
- data/lib/icalendar/component/alarm.rb +0 -47
- data/lib/icalendar/component/event.rb +0 -131
- data/lib/icalendar/component/freebusy.rb +0 -38
- data/lib/icalendar/component/journal.rb +0 -60
- data/lib/icalendar/component/timezone.rb +0 -91
- data/lib/icalendar/component/todo.rb +0 -64
- data/lib/icalendar/conversions.rb +0 -107
- data/lib/icalendar/helpers.rb +0 -109
- data/lib/icalendar/parameter.rb +0 -33
- data/lib/icalendar/rrule.rb +0 -133
- data/lib/meta.rb +0 -32
- data/script/console +0 -10
- data/script/recur1.ics +0 -38
- data/script/tryit.rb +0 -13
- data/test/component/test_event.rb +0 -253
- data/test/component/test_timezone.rb +0 -74
- data/test/component/test_todo.rb +0 -31
- data/test/fixtures/life.ics +0 -46
- data/test/fixtures/nonstandard.ics +0 -25
- data/test/fixtures/simplecal.ics +0 -119
- data/test/interactive.rb +0 -17
- data/test/read_write.rb +0 -23
- data/test/test_calendar.rb +0 -167
- data/test/test_component.rb +0 -102
- data/test/test_conversions.rb +0 -104
- data/test/test_helper.rb +0 -7
- data/test/test_parameter.rb +0 -91
- data/test/test_parser.rb +0 -100
- data/test/test_tzinfo.rb +0 -83
- data/website/index.html +0 -70
- data/website/index.txt +0 -38
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -159
- data/website/template.html.erb +0 -50
data/test/fixtures/life.ics
DELETED
@@ -1,46 +0,0 @@
|
|
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
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
BEGIN:VCALENDAR
|
2
|
-
VERSION:2.0
|
3
|
-
PRODID:bsprodidfortestabc123
|
4
|
-
BEGIN:VEVENT
|
5
|
-
UID:bsuidfortestabc123
|
6
|
-
ORGANIZER:mailto:joebob@random.net
|
7
|
-
ATTACH:http://bush.sucks.org/impeach/him.rhtml
|
8
|
-
ATTACH:http://corporations-dominate.existence.net/why.rhtml
|
9
|
-
SUMMARY:This is a really long summary
|
10
|
-
to test the method of unfolding lines\,
|
11
|
-
so I'm just going to ma
|
12
|
-
ke it
|
13
|
-
a whol
|
14
|
-
e
|
15
|
-
bunch of lines.
|
16
|
-
CLASS:PRIVATE
|
17
|
-
PRIORITY:2
|
18
|
-
CUSTOMFIELD:Not properly noted as custom with X- prefix.
|
19
|
-
GEO:37.386013;-122.0829322
|
20
|
-
DTSTART;TZID=US-Mountain:20050120T170000
|
21
|
-
DTEND:20050120T184500
|
22
|
-
DTSTAMP:20050118T211523Z
|
23
|
-
NAME:SomeName
|
24
|
-
END:VEVENT
|
25
|
-
END:VCALENDAR
|
data/test/fixtures/simplecal.ics
DELETED
@@ -1,119 +0,0 @@
|
|
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
|
data/test/interactive.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# NOTE: you must have installed ruby-breakpoint in order to use this script.
|
4
|
-
# Grab it using gem with "gem install ruby-breakpoint --remote" or download
|
5
|
-
# from the website (http://ruby-breakpoint.rubyforge.org/) then run setup.rb
|
6
|
-
|
7
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'breakpoint'
|
11
|
-
|
12
|
-
require 'icalendar'
|
13
|
-
|
14
|
-
cal = Icalendar::Parser.new(File.new("life.ics")).parse
|
15
|
-
#cal = Icalendar::Calendar.new
|
16
|
-
|
17
|
-
breakpoint
|
data/test/read_write.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
# NOTE: you must have installed ruby-breakpoint in order to use this script.
|
4
|
-
# Grab it using gem with "gem install ruby-breakpoint --remote" or download
|
5
|
-
# from the website (http://ruby-breakpoint.rubyforge.org/) then run setup.rb
|
6
|
-
|
7
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
8
|
-
|
9
|
-
require 'breakpoint'
|
10
|
-
require 'icalendar'
|
11
|
-
|
12
|
-
cals = Icalendar::Parser.new(File.new(ARGV[0])).parse
|
13
|
-
puts "Parsed #{cals.size} calendars"
|
14
|
-
|
15
|
-
cal = cals.first
|
16
|
-
puts "First calendar has:"
|
17
|
-
puts "#{cal.events.size} events"
|
18
|
-
puts "#{cal.todos.size} todos"
|
19
|
-
puts "#{cal.journals.size} journals"
|
20
|
-
|
21
|
-
test = File.new("rw.ics", "w")
|
22
|
-
test.write(cal.to_ical)
|
23
|
-
test.close
|
data/test/test_calendar.rb
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
class TestCalendar < Test::Unit::TestCase
|
6
|
-
include Icalendar
|
7
|
-
# Generate a calendar using the raw api, and then spit it out
|
8
|
-
# as a string. Parse the string and make sure everything matches up.
|
9
|
-
def test_raw_generation
|
10
|
-
# Create a fresh calendar
|
11
|
-
cal = Calendar.new
|
12
|
-
|
13
|
-
cal.calscale = "GREGORIAN"
|
14
|
-
cal.version = "3.2"
|
15
|
-
cal.prodid = "test-prodid"
|
16
|
-
|
17
|
-
# Now generate the string and then parse it so we can verify
|
18
|
-
# that everything was set, generated and parsed correctly.
|
19
|
-
calString = cal.to_ical
|
20
|
-
|
21
|
-
cals = Parser.new(calString).parse
|
22
|
-
|
23
|
-
cal2 = cals.first
|
24
|
-
assert_equal("GREGORIAN", cal2.calscale)
|
25
|
-
assert_equal("3.2", cal2.version)
|
26
|
-
assert_equal("test-prodid", cal2.prodid)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_block_creation
|
30
|
-
cal = Calendar.new
|
31
|
-
cal.event do
|
32
|
-
self.dtend = "19970903T190000Z"
|
33
|
-
self.summary = "This is my summary"
|
34
|
-
end
|
35
|
-
|
36
|
-
event = cal.event
|
37
|
-
event.dtend "19970903T190000Z", {:TZID => "Europe/Copenhagen"}
|
38
|
-
event.summary "This is my summary"
|
39
|
-
|
40
|
-
cal.events.each do |ev|
|
41
|
-
assert_equal("19970903T190000Z", ev.dtend)
|
42
|
-
assert_equal("This is my summary", ev.summary)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_block_creation_with_timezone
|
47
|
-
cal = Calendar.new
|
48
|
-
|
49
|
-
event_start = DateTime.new 1997, 9, 3, 19, 0, 0
|
50
|
-
tz = TZInfo::Timezone.get "Europe/Copenhagen"
|
51
|
-
timezone = tz.ical_timezone event_start
|
52
|
-
cal.add timezone
|
53
|
-
|
54
|
-
cal.event do
|
55
|
-
dtstart event_start
|
56
|
-
dtend "19970903T190000Z"
|
57
|
-
summary "This is my summary"
|
58
|
-
end
|
59
|
-
|
60
|
-
cal.events.each do |ev|
|
61
|
-
assert_equal(event_start, ev.dtstart)
|
62
|
-
assert_equal("19970903T190000Z", ev.dtend)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_create_multiple_event_calendar
|
67
|
-
# Create a fresh calendar
|
68
|
-
Timecop.freeze DateTime.new(2013, 12, 26, 5, 0, 0, '+0000')
|
69
|
-
cal = Calendar.new
|
70
|
-
[1,2,3].each do |t|
|
71
|
-
cal.event do
|
72
|
-
self.dtend = "1997090#{t}T190000Z"
|
73
|
-
self.summary = "This is summary #{t}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
[1,2,3].each do |t|
|
77
|
-
cal.todo do
|
78
|
-
self.summary = "test #{t} todo"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
expected_no_uid = <<-EXPECTED.gsub("\n", "\r\n")
|
82
|
-
BEGIN:VCALENDAR
|
83
|
-
VERSION:2.0
|
84
|
-
CALSCALE:GREGORIAN
|
85
|
-
PRODID:iCalendar-Ruby
|
86
|
-
BEGIN:VEVENT
|
87
|
-
DTEND:19970901T190000Z
|
88
|
-
DTSTAMP:20131226T050000Z
|
89
|
-
SEQUENCE:0
|
90
|
-
SUMMARY:This is summary 1
|
91
|
-
END:VEVENT
|
92
|
-
BEGIN:VEVENT
|
93
|
-
DTEND:19970902T190000Z
|
94
|
-
DTSTAMP:20131226T050000Z
|
95
|
-
SEQUENCE:0
|
96
|
-
SUMMARY:This is summary 2
|
97
|
-
END:VEVENT
|
98
|
-
BEGIN:VEVENT
|
99
|
-
DTEND:19970903T190000Z
|
100
|
-
DTSTAMP:20131226T050000Z
|
101
|
-
SEQUENCE:0
|
102
|
-
SUMMARY:This is summary 3
|
103
|
-
END:VEVENT
|
104
|
-
BEGIN:VTODO
|
105
|
-
DTSTAMP:20131226T050000Z
|
106
|
-
SEQUENCE:0
|
107
|
-
SUMMARY:test 1 todo
|
108
|
-
END:VTODO
|
109
|
-
BEGIN:VTODO
|
110
|
-
DTSTAMP:20131226T050000Z
|
111
|
-
SEQUENCE:0
|
112
|
-
SUMMARY:test 2 todo
|
113
|
-
END:VTODO
|
114
|
-
BEGIN:VTODO
|
115
|
-
DTSTAMP:20131226T050000Z
|
116
|
-
SEQUENCE:0
|
117
|
-
SUMMARY:test 3 todo
|
118
|
-
END:VTODO
|
119
|
-
END:VCALENDAR
|
120
|
-
EXPECTED
|
121
|
-
actual_no_uid = cal.to_ical.gsub /^UID:.*\r\n(?: .*\r\n)*/, ''
|
122
|
-
Timecop.return
|
123
|
-
assert_equal expected_no_uid, actual_no_uid
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_find
|
127
|
-
cal = Calendar.new
|
128
|
-
|
129
|
-
# add some events so we actually have to search
|
130
|
-
10.times do
|
131
|
-
cal.event
|
132
|
-
cal.todo
|
133
|
-
cal.journal
|
134
|
-
cal.freebusy
|
135
|
-
end
|
136
|
-
event = cal.events[5]
|
137
|
-
assert_equal(event, cal.find_event(event.uid))
|
138
|
-
|
139
|
-
todo = cal.todos[5]
|
140
|
-
assert_equal(todo, cal.find_todo(todo.uid))
|
141
|
-
|
142
|
-
journal = cal.journals[5]
|
143
|
-
assert_equal(journal, cal.find_journal(journal.uid))
|
144
|
-
|
145
|
-
freebusy = cal.freebusys[5]
|
146
|
-
assert_equal(freebusy, cal.find_freebusy(freebusy.uid))
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_set_and_get_proprietary_attributes
|
150
|
-
cal = Calendar.new
|
151
|
-
|
152
|
-
cal.x_wr_name = 'Icalendar Calendar'
|
153
|
-
|
154
|
-
calString = cal.to_ical
|
155
|
-
|
156
|
-
cals = Parser.new(calString).parse
|
157
|
-
|
158
|
-
cal2 = cals.first
|
159
|
-
assert_equal(["Icalendar Calendar"], cal2.x_wr_name)
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_respond_to_proprietary_attributes
|
163
|
-
cal = Calendar.new
|
164
|
-
|
165
|
-
assert_respond_to(cal, 'x_wr_name=')
|
166
|
-
end
|
167
|
-
end
|
data/test/test_component.rb
DELETED
@@ -1,102 +0,0 @@
|
|
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
|
-
# Create a calendar with an event for each test.
|
9
|
-
def setup
|
10
|
-
@cal = Icalendar::Calendar.new
|
11
|
-
@event = Icalendar::Event.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_add_remove_component
|
15
|
-
@cal.add_component(@event)
|
16
|
-
assert_equal(1, @cal.events.size)
|
17
|
-
@cal.remove_component(@event)
|
18
|
-
assert_equal(0, @cal.events.size)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_ical_property
|
22
|
-
# No alias but it does have a prop_name
|
23
|
-
assert_equal(false, @event.ip_class?)
|
24
|
-
@event.ip_class = "PRIVATE"
|
25
|
-
assert_equal(true, @event.ip_class?)
|
26
|
-
assert_equal("PRIVATE", @event.ip_class)
|
27
|
-
|
28
|
-
# Check that both dtend and its alias start work correctly
|
29
|
-
date = DateTime.new(2005, 02, 05, 23, 24, 25)
|
30
|
-
@event.dtend = date
|
31
|
-
assert_equal(date.year, @event.dtend.year)
|
32
|
-
|
33
|
-
date2 = DateTime.new(2005, 02, 05, 23, 24, 26)
|
34
|
-
@event.end = date2
|
35
|
-
assert_equal(date2.year, @event.end.year)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_ical_multi_property
|
39
|
-
# Query
|
40
|
-
assert_equal(false, @event.comments?)
|
41
|
-
@event.comments = []
|
42
|
-
assert_equal(true, @event.comments?)
|
43
|
-
|
44
|
-
# Should return an empty array, rather than nil
|
45
|
-
assert_equal(0, @event.comments.size)
|
46
|
-
|
47
|
-
# Add and remove
|
48
|
-
@event.add_comment "c1"
|
49
|
-
@event.add_comment "c2"
|
50
|
-
assert_equal(2, @event.comments.size)
|
51
|
-
assert_equal(["c1","c2"], @event.comments)
|
52
|
-
@event.remove_comment "c1"
|
53
|
-
assert_equal(["c2"], @event.comments)
|
54
|
-
|
55
|
-
# Add using multi setter
|
56
|
-
@event.comments "c3"
|
57
|
-
assert_equal(["c2","c3"], @event.comments)
|
58
|
-
|
59
|
-
# Set & get whole array
|
60
|
-
foo = ["as", "df"]
|
61
|
-
@event.comments = foo
|
62
|
-
assert_equal(foo, @event.comments)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_x_property
|
66
|
-
@event.x_foobar = "my-custom-property"
|
67
|
-
assert_equal(["my-custom-property"], @event.x_foobar)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_method_missing_no_x
|
71
|
-
assert_raise NoMethodError do
|
72
|
-
@event.there_is_no_such_method
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_respond_to_missing
|
77
|
-
component = Icalendar::Component.new('name')
|
78
|
-
assert !component.respond_to?(:there_is_no_such_method)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_respond_to_x_property
|
82
|
-
component = Icalendar::Component.new('name')
|
83
|
-
assert component.respond_to?(:x_foobar)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_geo_constructor
|
87
|
-
geo = Icalendar::Geo.new(1, 2)
|
88
|
-
assert_equal(1, geo.latitude)
|
89
|
-
assert_equal(1, geo.lat)
|
90
|
-
assert_equal(2, geo.longitude)
|
91
|
-
assert_equal(2, geo.long)
|
92
|
-
assert_equal('1;2', geo.to_ical)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_geo_lat_and_long_setter
|
96
|
-
geo = Icalendar::Geo.new(1, 2)
|
97
|
-
geo.lat = 3
|
98
|
-
geo.long = 4
|
99
|
-
assert_equal(3, geo.lat)
|
100
|
-
assert_equal(4, geo.long)
|
101
|
-
end
|
102
|
-
end
|