icalendar 1.5.4 → 2.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -1
  3. data/.rspec +2 -0
  4. data/.travis.yml +1 -2
  5. data/History.txt +2 -7
  6. data/README.md +82 -107
  7. data/Rakefile +6 -7
  8. data/icalendar.gemspec +10 -9
  9. data/lib/icalendar.rb +17 -33
  10. data/lib/icalendar/alarm.rb +35 -0
  11. data/lib/icalendar/calendar.rb +17 -100
  12. data/lib/icalendar/component.rb +41 -403
  13. data/lib/icalendar/event.rb +51 -0
  14. data/lib/icalendar/freebusy.rb +27 -0
  15. data/lib/icalendar/has_components.rb +83 -0
  16. data/lib/icalendar/has_properties.rb +156 -0
  17. data/lib/icalendar/journal.rb +39 -0
  18. data/lib/icalendar/parser.rb +75 -403
  19. data/lib/icalendar/timezone.rb +53 -0
  20. data/lib/icalendar/todo.rb +52 -0
  21. data/lib/icalendar/tzinfo.rb +30 -30
  22. data/lib/icalendar/value.rb +80 -0
  23. data/lib/icalendar/values/array.rb +43 -0
  24. data/lib/icalendar/values/binary.rb +31 -0
  25. data/lib/icalendar/values/boolean.rb +17 -0
  26. data/lib/icalendar/values/cal_address.rb +8 -0
  27. data/lib/icalendar/values/date.rb +26 -0
  28. data/lib/icalendar/values/date_time.rb +34 -0
  29. data/lib/icalendar/values/duration.rb +48 -0
  30. data/lib/icalendar/values/float.rb +17 -0
  31. data/lib/icalendar/values/integer.rb +17 -0
  32. data/lib/icalendar/values/period.rb +46 -0
  33. data/lib/icalendar/values/recur.rb +63 -0
  34. data/lib/icalendar/values/text.rb +26 -0
  35. data/lib/icalendar/values/time.rb +34 -0
  36. data/lib/icalendar/values/time_with_zone.rb +31 -0
  37. data/lib/icalendar/values/uri.rb +19 -0
  38. data/lib/icalendar/values/utc_offset.rb +39 -0
  39. data/lib/icalendar/version.rb +5 -0
  40. data/spec/alarm_spec.rb +108 -0
  41. data/spec/calendar_spec.rb +167 -0
  42. data/spec/event_spec.rb +108 -0
  43. data/{test/fixtures/folding.ics → spec/fixtures/nondefault_values.ics} +2 -2
  44. data/{test → spec}/fixtures/single_event.ics +11 -14
  45. data/spec/fixtures/timezone.ics +35 -0
  46. data/spec/freebusy_spec.rb +7 -0
  47. data/spec/journal_spec.rb +7 -0
  48. data/spec/parser_spec.rb +26 -0
  49. data/spec/roundtrip_spec.rb +40 -0
  50. data/spec/spec_helper.rb +25 -0
  51. data/spec/timezone_spec.rb +31 -0
  52. data/spec/todo_spec.rb +24 -0
  53. data/spec/tzinfo_spec.rb +85 -0
  54. data/spec/values/date_time_spec.rb +80 -0
  55. data/spec/values/duration_spec.rb +67 -0
  56. data/spec/values/period_spec.rb +47 -0
  57. data/spec/values/recur_spec.rb +47 -0
  58. data/spec/values/text_spec.rb +72 -0
  59. data/spec/values/utc_offset_spec.rb +41 -0
  60. metadata +129 -88
  61. data/GPL +0 -340
  62. data/examples/create_cal.rb +0 -45
  63. data/examples/parse_cal.rb +0 -20
  64. data/examples/single_event.ics +0 -18
  65. data/lib/hash_attrs.rb +0 -34
  66. data/lib/icalendar/base.rb +0 -47
  67. data/lib/icalendar/component/alarm.rb +0 -47
  68. data/lib/icalendar/component/event.rb +0 -131
  69. data/lib/icalendar/component/freebusy.rb +0 -38
  70. data/lib/icalendar/component/journal.rb +0 -60
  71. data/lib/icalendar/component/timezone.rb +0 -91
  72. data/lib/icalendar/component/todo.rb +0 -64
  73. data/lib/icalendar/conversions.rb +0 -107
  74. data/lib/icalendar/helpers.rb +0 -109
  75. data/lib/icalendar/parameter.rb +0 -33
  76. data/lib/icalendar/rrule.rb +0 -133
  77. data/lib/meta.rb +0 -32
  78. data/script/console +0 -10
  79. data/script/recur1.ics +0 -38
  80. data/script/tryit.rb +0 -13
  81. data/test/component/test_event.rb +0 -253
  82. data/test/component/test_timezone.rb +0 -74
  83. data/test/component/test_todo.rb +0 -31
  84. data/test/fixtures/life.ics +0 -46
  85. data/test/fixtures/nonstandard.ics +0 -25
  86. data/test/fixtures/simplecal.ics +0 -119
  87. data/test/interactive.rb +0 -17
  88. data/test/read_write.rb +0 -23
  89. data/test/test_calendar.rb +0 -167
  90. data/test/test_component.rb +0 -102
  91. data/test/test_conversions.rb +0 -104
  92. data/test/test_helper.rb +0 -7
  93. data/test/test_parameter.rb +0 -91
  94. data/test/test_parser.rb +0 -100
  95. data/test/test_tzinfo.rb +0 -83
  96. data/website/index.html +0 -70
  97. data/website/index.txt +0 -38
  98. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  99. data/website/stylesheets/screen.css +0 -159
  100. data/website/template.html.erb +0 -50
data/lib/meta.rb DELETED
@@ -1,32 +0,0 @@
1
- # A set of methods to help create meta-programming gizmos.
2
- class Object
3
- # The metaclass is the singleton behind every object.
4
- def metaclass
5
- class << self
6
- self
7
- end
8
- end
9
-
10
- # Evaluates the block in the context of the metaclass
11
- def meta_eval(&blk)
12
- metaclass.instance_eval(&blk)
13
- end
14
-
15
- # Acts like an include except it adds the module's methods
16
- # to the metaclass so they act like class methods.
17
- def meta_include mod
18
- meta_eval do
19
- include mod
20
- end
21
- end
22
-
23
- # Adds methods to a metaclass
24
- def meta_def name, &blk
25
- meta_eval { define_method name, &blk }
26
- end
27
-
28
- # Defines an instance method within a class
29
- def class_def name, &blk
30
- class_eval { define_method name, &blk }
31
- end
32
- end
data/script/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/icalendar.rb'}"
9
- puts "Loading icalendar gem"
10
- exec "#{irb} #{libs} --simple-prompt"
data/script/recur1.ics DELETED
@@ -1,38 +0,0 @@
1
- BEGIN:VCALENDAR
2
- METHOD:PUBLISH
3
- X-WR-TIMEZONE:US/Eastern
4
- PRODID:-//Apple Inc.//iCal 3.0//EN
5
- CALSCALE:GREGORIAN
6
- X-WR-CALNAME:recur1
7
- VERSION:2.0
8
- X-WR-RELCALID:9122B9C1-EE7E-479C-9567-DB9F075F1844
9
- X-APPLE-CALENDAR-COLOR:#492BA1
10
- BEGIN:VTIMEZONE
11
- TZID:US/Eastern
12
- BEGIN:DAYLIGHT
13
- TZOFFSETFROM:-0500
14
- TZOFFSETTO:-0400
15
- DTSTART:20070311T020000
16
- RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
17
- TZNAME:EDT
18
- END:DAYLIGHT
19
- BEGIN:STANDARD
20
- TZOFFSETFROM:-0400
21
- TZOFFSETTO:-0500
22
- DTSTART:20071104T020000
23
- RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
24
- TZNAME:EST
25
- END:STANDARD
26
- END:VTIMEZONE
27
- BEGIN:VEVENT
28
- SEQUENCE:8
29
- TRANSP:OPAQUE
30
- UID:59B21F50-301E-457D-B57E-78EDE83987E0
31
- DTSTART;TZID=US/Eastern:20080908T100000
32
- DTSTAMP:20081016T174123Z
33
- SUMMARY:Recurring Event
34
- CREATED:20081016T174021Z
35
- DTEND;TZID=US/Eastern:20080908T110000
36
- RRULE:FREQ=DAILY;INTERVAL=2;UNTIL=20080915T035959Z
37
- END:VEVENT
38
- END:VCALENDAR
data/script/tryit.rb DELETED
@@ -1,13 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
-
3
- require 'icalendar'
4
-
5
- require 'date'
6
- cal = nil
7
-
8
- File.open(File.expand_path(File.dirname(__FILE__) + '/recur1.ics')) do |file|
9
- cal = Icalendar.parse(file).first
10
- end
11
- event = cal.events.first
12
- debugger
13
- puts event.to_ical
@@ -1,253 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
2
-
3
- require 'test/unit'
4
- require 'icalendar'
5
-
6
- unless defined? 1.days
7
- class Integer
8
- def days
9
- self * 60 * 60 * 24
10
- end
11
- end
12
- end
13
-
14
-
15
- class TestEvent < Test::Unit::TestCase
16
-
17
- # Create a calendar with an event for each test.
18
- def setup
19
- @cal = Icalendar::Calendar.new
20
- @event = Icalendar::Event.new
21
- end
22
-
23
- def test_new
24
- assert(@event)
25
- end
26
-
27
- # Properties that can only occur once per event
28
- def test_single_properties
29
- @event.ip_class = "PRIVATE"
30
-
31
- @cal.add_event(@event)
32
-
33
- cals = Icalendar::Parser.new(@cal.to_ical).parse
34
- cal2 = cals.first
35
- event2 = cal2.events.first
36
-
37
- assert_equal("PRIVATE", event2.ip_class)
38
- end
39
-
40
- def test_proprietary_attributes
41
- @cal.add_event @event
42
- @event.x_custom_property = 'My Custom Property'
43
-
44
- result = Icalendar::Parser.new(@cal.to_ical).parse.first.events.first
45
-
46
- assert_equal ['My Custom Property'], result.x_custom_property
47
- end
48
- end
49
-
50
- class TestEventWithSpecifiedTimezone < Test::Unit::TestCase
51
-
52
- def setup
53
- src = <<EOS
54
- BEGIN:VCALENDAR
55
- METHOD:PUBLISH
56
- CALSCALE:GREGORIAN
57
- VERSION:2.0
58
- BEGIN:VEVENT
59
- UID:19970901T130000Z-123401@host.com
60
- DTSTAMP:19970901T1300Z
61
- DTSTART;TZID=America/Chicago:19970903T163000
62
- DTEND;TZID=America/Chicago:19970903T190000
63
- SUMMARY:Annual Employee Review
64
- CLASS:PRIVATE
65
- CATEGORIES:BUSINESS,HUMAN RESOURCES
66
- END:VEVENT
67
- END:VCALENDAR
68
- EOS
69
- @calendar = Icalendar.parse(src).first
70
- @event = @calendar.events.first
71
- end
72
-
73
- def test_event_is_parsed
74
- assert_not_nil(@event)
75
- end
76
-
77
- def test_dtstart_should_understand_icalendar_tzid
78
- assert_respond_to(@event.dtstart, :icalendar_tzid)
79
- end
80
-
81
- def test_dtstart_tzid_should_be_correct
82
- # puts "#{@event.dtstart.icalendar_tzid} #{@event.dtstart}"
83
- assert_equal("America/Chicago",@event.dtstart.icalendar_tzid)
84
- end
85
-
86
- def test_dtend_tzid_should_be_correct
87
- assert_equal("America/Chicago",@event.dtend.icalendar_tzid)
88
- end
89
-
90
- end
91
-
92
- class TestEventWithZuluTimezone < Test::Unit::TestCase
93
-
94
- def setup
95
- src = <<EOS
96
- BEGIN:VCALENDAR
97
- METHOD:PUBLISH
98
- CALSCALE:GREGORIAN
99
- VERSION:2.0
100
- BEGIN:VEVENT
101
- UID:19970901T130000Z-123401@host.com
102
- DTSTAMP:19970901T1300Z
103
- DTSTART:19970903T163000Z
104
- DTEND:19970903T190000Z
105
- SUMMARY:Annual Employee Review
106
- CLASS:PRIVATE
107
- CATEGORIES:BUSINESS,HUMAN RESOURCES
108
- END:VEVENT
109
- END:VCALENDAR
110
- EOS
111
- @calendar = Icalendar.parse(src).first
112
- @event = @calendar.events.first
113
- end
114
-
115
- def test_event_is_parsed
116
- assert_not_nil(@event)
117
- end
118
-
119
- def test_dtstart_tzid_should_be_correct
120
- # puts "#{@event.dtstart.icalendar_tzid} #{@event.dtstart}"
121
- assert_equal("UTC",@event.dtstart.icalendar_tzid)
122
- end
123
-
124
- def test_dtend_tzid_should_be_correct
125
- assert_equal("UTC",@event.dtend.icalendar_tzid)
126
- end
127
-
128
- end
129
-
130
- class TestEventWithFloatingTimezone < Test::Unit::TestCase
131
-
132
- def setup
133
- src = <<EOS
134
- BEGIN:VCALENDAR
135
- METHOD:PUBLISH
136
- CALSCALE:GREGORIAN
137
- VERSION:2.0
138
- BEGIN:VEVENT
139
- UID:19970901T130000Z-123401@host.com
140
- DTSTAMP:19970901T1300Z
141
- DTSTART:19970903T163000
142
- DTEND:19970903T190000
143
- SUMMARY:Annual Employee Review
144
- CLASS:PRIVATE
145
- CATEGORIES:BUSINESS,HUMAN RESOURCES
146
- END:VEVENT
147
- END:VCALENDAR
148
- EOS
149
- @calendar = Icalendar.parse(src).first
150
- @event = @calendar.events.first
151
- end
152
-
153
- def test_event_is_parsed
154
- assert_not_nil(@event)
155
- end
156
-
157
- def test_dtstart_tzid_should_be_nil
158
- # puts "#{@event.dtstart.icalendar_tzid.inspect} #{@event.dtstart}"
159
- assert_nil(@event.dtstart.icalendar_tzid)
160
- end
161
-
162
- def test_dtend_tzid_should_be_nil
163
- assert_nil(@event.dtend.icalendar_tzid)
164
- end
165
-
166
- end
167
-
168
- class TestAllDayEventWithoutTime < Test::Unit::TestCase
169
-
170
- def setup
171
- src = <<EOS
172
- BEGIN:VCALENDAR
173
- VERSION:2.0
174
- X-WR-CALNAME:New Event
175
- PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
176
- X-WR-RELCALID:3A016BE7-8932-4456-8ABD-C8F7EEC5963A
177
- X-WR-TIMEZONE:Europe/London
178
- CALSCALE:GREGORIAN
179
- METHOD:PUBLISH
180
- BEGIN:VEVENT
181
- DTSTART;VALUE=DATE:20090110
182
- DTEND;VALUE=DATE:20090111
183
- SUMMARY:New Event
184
- UID:3829F33C-F601-49AC-A3A5-C3AC4A6A3483
185
- SEQUENCE:4
186
- DTSTAMP:20090109T184719Z
187
- END:VEVENT
188
- END:VCALENDAR
189
- EOS
190
- @calendar = Icalendar.parse(src).first
191
- @event = @calendar.events.first
192
- end
193
-
194
- def test_event_is_parsed
195
- assert_not_nil(@event)
196
- end
197
-
198
- def test_dtstart_set_correctly
199
- assert_equal("20090110", @event.dtstart.to_ical)
200
- end
201
-
202
- end
203
-
204
- class TestRecurringEventWithCount < Test::Unit::TestCase
205
- # DTSTART;TZID=US-Eastern:19970902T090000
206
- # RRULE:FREQ=DAILY;COUNT=10
207
- # ==> (1997 9:00 AM EDT)September 2-11
208
-
209
- def setup
210
- src = <<EOS
211
- BEGIN:VCALENDAR
212
- METHOD:PUBLISH
213
- CALSCALE:GREGORIAN
214
- VERSION:2.0
215
- BEGIN:VEVENT
216
- UID:19970901T130000Z-123401@host.com
217
- DTSTAMP:19970901T1300Z
218
- DTSTART:19970902T090000Z
219
- DTEND:19970902T100000Z
220
- RRULE:FREQ=DAILY;COUNT=10
221
- SUMMARY:Annual Employee Review
222
- CLASS:PRIVATE
223
- CATEGORIES:BUSINESS,HUMAN RESOURCES
224
- END:VEVENT
225
- END:VCALENDAR
226
- EOS
227
- @calendar = Icalendar.parse(src).first
228
- @event = @calendar.events.first
229
- end
230
-
231
- def test_event_is_parsed
232
- assert_not_nil(@event)
233
- end
234
-
235
- def test_recurrence_rules_should_return_a_recurrence_rule_array
236
- assert_equal 1, @event.recurrence_rules.length
237
- assert_kind_of(Icalendar::RRule, @event.recurrence_rules.first)
238
- end
239
-
240
- def test_occurrences_after_with_start_before_start_at_should_return_count_occurrences
241
- assert_equal 10, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).length
242
- end
243
-
244
- # def test_occurrences_after_with_start_before_start_at_should_return_an_event_with_the_dtstart_as_the_first_event
245
- # assert_equal @event.dtstart.to_s, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).first.dtstart.to_s
246
- # end
247
- #
248
- # def test_occurrences_after_with_start_before_start_at_should_return_events_with_the_correct_dtstart_values
249
- # expected = (0..9).map {|delta| (@event.dtstart + delta).to_s}
250
- # assert_equal expected, @event.occurrences_starting(Time.utc(1997, 9, 2, 8, 30, 0, 0)).map {|occurence| occurence.dtstart.to_s}
251
- # end
252
- end
253
-
@@ -1,74 +0,0 @@
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\nDTSTART:19701101T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:CST\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0600\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:19700308TO20000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:CDT\r\nTZOFFSETFROM:-0600\r\nTZOFFSETTO:-0500\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
-
43
- array1 = @testTimezone.split("\r\n").sort
44
- array2 = @cal.timezones.first.to_ical.split("\r\n").sort
45
- assert_equal(array1, array2)
46
- end
47
-
48
- def test_block_creation
49
- @cal.timezone do
50
- timezone_id "America/Chicago"
51
-
52
- daylight do
53
- timezone_offset_from "-0600"
54
- timezone_offset_to "-0500"
55
- timezone_name "CDT"
56
- dtstart "19700308TO20000"
57
- add_recurrence_rule "FREQ=YEARLY;BYMONTH=3;BYDAY=2SU"
58
- end
59
-
60
- standard do
61
- timezone_offset_from "-0500"
62
- timezone_offset_to "-0600"
63
- timezone_name "CST"
64
- dtstart "19701101T020000"
65
- add_recurrence_rule "FREQ=YEARLY;BYMONTH=11;BYDAY=1SU"
66
- end
67
- end
68
-
69
- # This isn't completely correct, but close enough to get around the ordering issue
70
- array1 = @testTimezone.split("\r\n").sort
71
- array2 = @cal.timezones.first.to_ical.split("\r\n").sort
72
- assert_equal(array1, array2)
73
- end
74
- end
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- require 'date'
4
-
5
- class TestTodo < Test::Unit::TestCase
6
- include Icalendar
7
-
8
- def test_todo_fields
9
-
10
- cal = Calendar.new
11
-
12
- cal.todo do
13
- summary "Plan next vacations"
14
- description "Let's have a break"
15
- percent 50
16
- seq 1
17
- add_category "TRAVEL"
18
- add_category "SPORTS"
19
- end
20
-
21
- calString = cal.to_ical
22
-
23
- assert_match(/PERCENT-COMPLETE:50/, calString)
24
- assert_match(/DESCRIPTION:Let's have a break/, calString)
25
- assert_match(/CATEGORIES:TRAVEL,SPORTS/, calString)
26
- assert_match(/SEQUENCE:1/, calString)
27
-
28
- end
29
- end
30
-
31
-