rubyredrick-ri_cal 0.0.11 → 0.5.0
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.
- data/lib/ri_cal/component/event.rb +31 -0
- data/lib/ri_cal/component/journal.rb +9 -0
- data/lib/ri_cal/component/todo.rb +17 -0
- data/lib/ri_cal/occurrence_enumerator.rb +19 -0
- data/lib/ri_cal/properties/event.rb +8 -8
- data/lib/ri_cal/properties/freebusy.rb +3 -3
- data/lib/ri_cal/properties/journal.rb +5 -5
- data/lib/ri_cal/properties/timezone.rb +1 -1
- data/lib/ri_cal/properties/timezone_period.rb +1 -1
- data/lib/ri_cal/properties/todo.rb +9 -8
- data/lib/ri_cal/property_value/date.rb +12 -0
- data/lib/ri_cal/property_value/date_time/timezone_support.rb +1 -1
- data/lib/ri_cal/property_value/date_time.rb +29 -1
- data/lib/ri_cal.rb +1 -1
- data/ri_cal.gemspec +2 -2
- data/spec/ri_cal/component/event_spec.rb +148 -5
- data/spec/ri_cal/component/journal_spec.rb +25 -0
- data/spec/ri_cal/component/todo_spec.rb +52 -0
- data/spec/ri_cal/occurrence_enumerator_spec.rb +62 -0
- data/tasks/ri_cal.rake +1 -1
- metadata +2 -2
@@ -23,7 +23,38 @@ module RiCal
|
|
23
23
|
def self.entity_name #:nodoc:
|
24
24
|
"VEVENT"
|
25
25
|
end
|
26
|
+
|
27
|
+
# Return a date_time representing the time at which the event starts
|
28
|
+
def start_time
|
29
|
+
dtstart_property ? dtstart.to_datetime : nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return a date_time representing the time at which the event starts
|
33
|
+
def finish_property
|
34
|
+
if dtend_property
|
35
|
+
dtend_property
|
36
|
+
elsif duration_property
|
37
|
+
(dtstart_property + duration_property)
|
38
|
+
else
|
39
|
+
dtstart_property
|
40
|
+
end
|
41
|
+
end
|
26
42
|
|
43
|
+
# Return a date_time representing the time at which the event starts
|
44
|
+
def finish_time
|
45
|
+
prop = finish_property
|
46
|
+
prop ? prop.to_finish_time : nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def zulu_occurrence_range_start_time
|
50
|
+
dtstart_property ? dtstart_property.to_zulu_occurrence_range_start_time : nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def zulu_occurrence_range_finish_time
|
54
|
+
prop = finish_property
|
55
|
+
prop ? prop.to_zulu_occurrence_range_finish_time : nil
|
56
|
+
end
|
57
|
+
|
27
58
|
end
|
28
59
|
end
|
29
60
|
end
|
@@ -16,6 +16,15 @@ module RiCal
|
|
16
16
|
def self.entity_name #:nodoc:
|
17
17
|
"VJOURNAL"
|
18
18
|
end
|
19
|
+
|
20
|
+
# Return a date_time representing the time at which the event starts
|
21
|
+
def start_time
|
22
|
+
dtstart.to_datetime
|
23
|
+
end
|
24
|
+
|
25
|
+
# Journals take up no calendar time, so the finish time is always the same as the start_time
|
26
|
+
alias_method :finish_time, :start_time
|
27
|
+
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -21,6 +21,23 @@ module RiCal
|
|
21
21
|
def subcomponent_class #:nodoc:
|
22
22
|
{:alarm => Alarm }
|
23
23
|
end
|
24
|
+
|
25
|
+
# Return a date_time representing the time at which the todo should start
|
26
|
+
def start_time
|
27
|
+
dtstart_property ? dtstart.to_datetime : nil
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return a date_time representing the time at which the todo is due
|
31
|
+
def finish_time
|
32
|
+
if due
|
33
|
+
due_property.to_finish_time
|
34
|
+
elsif duration_property && dtstart_property
|
35
|
+
(dtstart_property + duration_property).to_finish_time
|
36
|
+
else
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
24
41
|
end
|
25
42
|
end
|
26
43
|
end
|
@@ -163,7 +163,26 @@ module RiCal
|
|
163
163
|
def bounded?
|
164
164
|
EnumerationInstance.new(self).bounded?
|
165
165
|
end
|
166
|
+
|
167
|
+
# Return a array whose first element is a UTC DateTime representing the start of the first
|
168
|
+
# occurrence, and whose second element is a UTC DateTime representing the end of the last
|
169
|
+
# occurrence.
|
170
|
+
# If the receiver is not bounded then the second element will be nil.
|
166
171
|
#
|
172
|
+
# The purpose of this method is to provide values which may be used as database attributes so
|
173
|
+
# that a query can find all occurence enumerating components which may have occurrences within
|
174
|
+
# a range of times.
|
175
|
+
def zulu_occurrence_range
|
176
|
+
if bounded?
|
177
|
+
all = occurrences
|
178
|
+
first, last = all.first, all.last
|
179
|
+
else
|
180
|
+
first = occurrences(:count => 1).first
|
181
|
+
last = nil
|
182
|
+
end
|
183
|
+
[first.zulu_occurrence_range_start_time, last ? last.zulu_occurrence_range_finish_time : nil]
|
184
|
+
end
|
185
|
+
|
167
186
|
def set_occurrence_properties!(occurrence) # :nodoc:
|
168
187
|
occurrence_end = occurrence.dtend
|
169
188
|
occurrence_start = occurrence.dtstart
|
@@ -54,7 +54,7 @@ module RiCal
|
|
54
54
|
# set the CREATED property
|
55
55
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
56
56
|
def created_property=(property_value)
|
57
|
-
@created_property = property_value.for_parent(self)
|
57
|
+
@created_property = property_value ? property_value.for_parent(self) : nil
|
58
58
|
end
|
59
59
|
|
60
60
|
# set the value of the CREATED property
|
@@ -120,7 +120,7 @@ module RiCal
|
|
120
120
|
# set the DTSTART property
|
121
121
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
122
122
|
def dtstart_property=(property_value)
|
123
|
-
@dtstart_property = property_value.for_parent(self)
|
123
|
+
@dtstart_property = property_value ? property_value.for_parent(self) : nil
|
124
124
|
end
|
125
125
|
|
126
126
|
# set the value of the DTSTART property
|
@@ -186,7 +186,7 @@ module RiCal
|
|
186
186
|
# set the LAST-MODIFIED property
|
187
187
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
188
188
|
def last_modified_property=(property_value)
|
189
|
-
@last_modified_property = property_value.for_parent(self)
|
189
|
+
@last_modified_property = property_value ? property_value.for_parent(self) : nil
|
190
190
|
end
|
191
191
|
|
192
192
|
# set the value of the LAST-MODIFIED property
|
@@ -318,7 +318,7 @@ module RiCal
|
|
318
318
|
# set the DTSTAMP property
|
319
319
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
320
320
|
def dtstamp_property=(property_value)
|
321
|
-
@dtstamp_property = property_value.for_parent(self)
|
321
|
+
@dtstamp_property = property_value ? property_value.for_parent(self) : nil
|
322
322
|
end
|
323
323
|
|
324
324
|
# set the value of the DTSTAMP property
|
@@ -549,7 +549,7 @@ module RiCal
|
|
549
549
|
# set the RECURRENCE-ID property
|
550
550
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
551
551
|
def recurrence_id_property=(property_value)
|
552
|
-
@recurrence_id_property = property_value.for_parent(self)
|
552
|
+
@recurrence_id_property = property_value ? property_value.for_parent(self) : nil
|
553
553
|
end
|
554
554
|
|
555
555
|
# set the value of the RECURRENCE-ID property
|
@@ -582,7 +582,7 @@ module RiCal
|
|
582
582
|
# set the DTEND property
|
583
583
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
584
584
|
def dtend_property=(property_value)
|
585
|
-
@dtend_property = property_value.for_parent(self)
|
585
|
+
@dtend_property = property_value ? property_value.for_parent(self) : nil
|
586
586
|
@duration_property = nil
|
587
587
|
end
|
588
588
|
|
@@ -1039,8 +1039,8 @@ module RiCal
|
|
1039
1039
|
|
1040
1040
|
# set the value of the RDATE property to a single value
|
1041
1041
|
# one instance of OccurrenceList may be passed to this method
|
1042
|
-
def rdate=(ruby_value)
|
1043
|
-
@rdate_property = [RiCal::PropertyValue::OccurrenceList.convert(self, ruby_value)]
|
1042
|
+
def rdate=(*ruby_value)
|
1043
|
+
@rdate_property = [RiCal::PropertyValue::OccurrenceList.convert(self, *ruby_value)]
|
1044
1044
|
end
|
1045
1045
|
|
1046
1046
|
# add one or more values to the RDATE property
|
@@ -54,7 +54,7 @@ module RiCal
|
|
54
54
|
# set the DTSTART property
|
55
55
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
56
56
|
def dtstart_property=(property_value)
|
57
|
-
@dtstart_property = property_value.for_parent(self)
|
57
|
+
@dtstart_property = property_value ? property_value.for_parent(self) : nil
|
58
58
|
end
|
59
59
|
|
60
60
|
# set the value of the DTSTART property
|
@@ -87,7 +87,7 @@ module RiCal
|
|
87
87
|
# set the DTEND property
|
88
88
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
89
89
|
def dtend_property=(property_value)
|
90
|
-
@dtend_property = property_value.for_parent(self)
|
90
|
+
@dtend_property = property_value ? property_value.for_parent(self) : nil
|
91
91
|
end
|
92
92
|
|
93
93
|
# set the value of the DTEND property
|
@@ -153,7 +153,7 @@ module RiCal
|
|
153
153
|
# set the DTSTAMP property
|
154
154
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
155
155
|
def dtstamp_property=(property_value)
|
156
|
-
@dtstamp_property = property_value.for_parent(self)
|
156
|
+
@dtstamp_property = property_value ? property_value.for_parent(self) : nil
|
157
157
|
end
|
158
158
|
|
159
159
|
# set the value of the DTSTAMP property
|
@@ -54,7 +54,7 @@ module RiCal
|
|
54
54
|
# set the CREATED property
|
55
55
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
56
56
|
def created_property=(property_value)
|
57
|
-
@created_property = property_value.for_parent(self)
|
57
|
+
@created_property = property_value ? property_value.for_parent(self) : nil
|
58
58
|
end
|
59
59
|
|
60
60
|
# set the value of the CREATED property
|
@@ -120,7 +120,7 @@ module RiCal
|
|
120
120
|
# set the DTSTART property
|
121
121
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
122
122
|
def dtstart_property=(property_value)
|
123
|
-
@dtstart_property = property_value.for_parent(self)
|
123
|
+
@dtstart_property = property_value ? property_value.for_parent(self) : nil
|
124
124
|
end
|
125
125
|
|
126
126
|
# set the value of the DTSTART property
|
@@ -153,7 +153,7 @@ module RiCal
|
|
153
153
|
# set the DTSTAMP property
|
154
154
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
155
155
|
def dtstamp_property=(property_value)
|
156
|
-
@dtstamp_property = property_value.for_parent(self)
|
156
|
+
@dtstamp_property = property_value ? property_value.for_parent(self) : nil
|
157
157
|
end
|
158
158
|
|
159
159
|
# set the value of the DTSTAMP property
|
@@ -186,7 +186,7 @@ module RiCal
|
|
186
186
|
# set the LAST-MODIFIED property
|
187
187
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
188
188
|
def last_modified_property=(property_value)
|
189
|
-
@last_modified_property = property_value.for_parent(self)
|
189
|
+
@last_modified_property = property_value ? property_value.for_parent(self) : nil
|
190
190
|
end
|
191
191
|
|
192
192
|
# set the value of the LAST-MODIFIED property
|
@@ -252,7 +252,7 @@ module RiCal
|
|
252
252
|
# set the RECURRENCE-ID property
|
253
253
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
254
254
|
def recurrence_id_property=(property_value)
|
255
|
-
@recurrence_id_property = property_value.for_parent(self)
|
255
|
+
@recurrence_id_property = property_value ? property_value.for_parent(self) : nil
|
256
256
|
end
|
257
257
|
|
258
258
|
# set the value of the RECURRENCE-ID property
|
@@ -54,7 +54,7 @@ module RiCal
|
|
54
54
|
# set the LAST-MODIFIED property
|
55
55
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
56
56
|
def last_modified_property=(property_value)
|
57
|
-
@last_modified_property = property_value.for_parent(self)
|
57
|
+
@last_modified_property = property_value ? property_value.for_parent(self) : nil
|
58
58
|
end
|
59
59
|
|
60
60
|
# set the value of the LAST-MODIFIED property
|
@@ -21,7 +21,7 @@ module RiCal
|
|
21
21
|
# set the DTSTART property
|
22
22
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
23
23
|
def dtstart_property=(property_value)
|
24
|
-
@dtstart_property = property_value.for_parent(self)
|
24
|
+
@dtstart_property = property_value ? property_value.for_parent(self) : nil
|
25
25
|
end
|
26
26
|
|
27
27
|
# set the value of the DTSTART property
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module RiCal
|
2
2
|
module Properties #:nodoc:
|
3
|
-
#- ©2009 Rick DeNatale
|
3
|
+
#- ©2009 Rick DeNatale
|
4
|
+
#- All rights reserved. Refer to the file README.txt for the license
|
4
5
|
#
|
5
6
|
# Properties::Todo provides property accessing methods for the Todo class
|
6
7
|
# This source file is generated by the rical:gen_propmodules rake tasks, DO NOT EDIT
|
@@ -53,7 +54,7 @@ module RiCal
|
|
53
54
|
# set the COMPLETED property
|
54
55
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
55
56
|
def completed_property=(property_value)
|
56
|
-
@completed_property = property_value.for_parent(self)
|
57
|
+
@completed_property = property_value ? property_value.for_parent(self) : nil
|
57
58
|
end
|
58
59
|
|
59
60
|
# set the value of the COMPLETED property
|
@@ -86,7 +87,7 @@ module RiCal
|
|
86
87
|
# set the CREATED property
|
87
88
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
88
89
|
def created_property=(property_value)
|
89
|
-
@created_property = property_value.for_parent(self)
|
90
|
+
@created_property = property_value ? property_value.for_parent(self) : nil
|
90
91
|
end
|
91
92
|
|
92
93
|
# set the value of the CREATED property
|
@@ -152,7 +153,7 @@ module RiCal
|
|
152
153
|
# set the DTSTAMP property
|
153
154
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
154
155
|
def dtstamp_property=(property_value)
|
155
|
-
@dtstamp_property = property_value.for_parent(self)
|
156
|
+
@dtstamp_property = property_value ? property_value.for_parent(self) : nil
|
156
157
|
end
|
157
158
|
|
158
159
|
# set the value of the DTSTAMP property
|
@@ -185,7 +186,7 @@ module RiCal
|
|
185
186
|
# set the DTSTART property
|
186
187
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
187
188
|
def dtstart_property=(property_value)
|
188
|
-
@dtstart_property = property_value.for_parent(self)
|
189
|
+
@dtstart_property = property_value ? property_value.for_parent(self) : nil
|
189
190
|
end
|
190
191
|
|
191
192
|
# set the value of the DTSTART property
|
@@ -251,7 +252,7 @@ module RiCal
|
|
251
252
|
# set the LAST-MODIFIED property
|
252
253
|
# property value should be an instance of RiCal::PropertyValueDateTime
|
253
254
|
def last_modified_property=(property_value)
|
254
|
-
@last_modified_property = property_value.for_parent(self)
|
255
|
+
@last_modified_property = property_value ? property_value.for_parent(self) : nil
|
255
256
|
end
|
256
257
|
|
257
258
|
# set the value of the LAST-MODIFIED property
|
@@ -416,7 +417,7 @@ module RiCal
|
|
416
417
|
# set the RECURRENCE-ID property
|
417
418
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
418
419
|
def recurrence_id_property=(property_value)
|
419
|
-
@recurrence_id_property = property_value.for_parent(self)
|
420
|
+
@recurrence_id_property = property_value ? property_value.for_parent(self) : nil
|
420
421
|
end
|
421
422
|
|
422
423
|
# set the value of the RECURRENCE-ID property
|
@@ -614,7 +615,7 @@ module RiCal
|
|
614
615
|
# set the DUE property
|
615
616
|
# property value should be an instance of either RiCal::PropertyValue::DateTime or RiCal::PropertyValue::Date
|
616
617
|
def due_property=(property_value)
|
617
|
-
@due_property = property_value.for_parent(self)
|
618
|
+
@due_property = property_value ? property_value.for_parent(self) : nil
|
618
619
|
@duration_property = nil
|
619
620
|
end
|
620
621
|
|
@@ -151,6 +151,18 @@ module RiCal
|
|
151
151
|
true
|
152
152
|
end
|
153
153
|
|
154
|
+
def to_zulu_occurrence_range_start_time
|
155
|
+
to_ri_cal_date_time_value.to_zulu_occurrence_range_start_time
|
156
|
+
end
|
157
|
+
|
158
|
+
def to_zulu_occurrence_range_finish_time
|
159
|
+
to_ri_cal_date_time_value.end_of_day.to_zulu_occurrence_range_finish_time
|
160
|
+
end
|
161
|
+
|
162
|
+
def to_finish_time
|
163
|
+
to_ri_cal_date_time_value.end_of_day.to_datetime
|
164
|
+
end
|
165
|
+
|
154
166
|
def for_occurrence(occurrence)
|
155
167
|
if occurrence.start_of_day?
|
156
168
|
occurrence.to_ri_cal_date_value(timezone_finder)
|
@@ -290,7 +290,35 @@ module RiCal
|
|
290
290
|
end
|
291
291
|
|
292
292
|
alias_method :to_ri_cal_ruby_value, :to_datetime
|
293
|
-
|
293
|
+
alias_method :to_finish_time, :to_datetime
|
294
|
+
|
295
|
+
def to_zulu_time
|
296
|
+
utc.to_datetime
|
297
|
+
end
|
298
|
+
|
299
|
+
# If a time is floating, then the utc of it's start time may actually be as early
|
300
|
+
# as 12 hours earlier if the occurrence is being viewed in a time zone just west
|
301
|
+
# of the International Date Line
|
302
|
+
def to_zulu_occurrence_range_start_time
|
303
|
+
if floating?
|
304
|
+
utc.advance(:hours => -12).to_datetime
|
305
|
+
else
|
306
|
+
to_zulu_time
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
# If a time is floating, then the utc of it's start time may actually be as early
|
312
|
+
# as 12 hours later if the occurrence is being viewed in a time zone just east
|
313
|
+
# of the International Date Line
|
314
|
+
def to_zulu_occurrence_range_finish_time
|
315
|
+
if floating?
|
316
|
+
utc.advance(:hours => 12).to_datetime
|
317
|
+
else
|
318
|
+
to_zulu_time
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
294
322
|
def add_date_times_to(required_timezones) #:nodoc:
|
295
323
|
required_timezones.add_datetime(self, tzid) if has_local_timezone?
|
296
324
|
end
|
data/lib/ri_cal.rb
CHANGED
@@ -11,7 +11,7 @@ module RiCal
|
|
11
11
|
autoload :OccurrenceEnumerator, "#{my_dir}/ri_cal/occurrence_enumerator.rb"
|
12
12
|
|
13
13
|
# :stopdoc:
|
14
|
-
VERSION = '0.0
|
14
|
+
VERSION = '0.5.0'
|
15
15
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
16
16
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
17
17
|
|
data/ri_cal.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ri_cal}
|
5
|
-
s.version = "0.0
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["author=Rick DeNatale"]
|
9
|
-
s.date = %q{2009-05-
|
9
|
+
s.date = %q{2009-05-26}
|
10
10
|
s.default_executable = %q{ri_cal}
|
11
11
|
s.description = %q{This is an UNOFFICIAL version. The public official version will be released on RubyForge. Github will be used
|
12
12
|
for interim versions. USE THIS VERSION AT YOUR OWN RISK.
|
@@ -181,6 +181,149 @@ describe RiCal::Component::Event do
|
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
|
+
context ".start_time" do
|
185
|
+
|
186
|
+
it "should be nil if there is no dtstart property" do
|
187
|
+
RiCal.Event.start_time.should be_nil
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should be the same as dtstart for a date time" do
|
191
|
+
event = RiCal.Event {|e| e.dtstart = "20090525T151900"}
|
192
|
+
event.start_time.should == DateTime.civil(2009,05,25,15,19,0,0)
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should be the start of the day of dtstart for a date" do
|
196
|
+
event = RiCal.Event {|e| e.dtstart = "20090525"}
|
197
|
+
event.start_time.should == DateTime.civil(2009,05,25,0,0,0,0)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context ".finish_time" do
|
202
|
+
before(:each) do
|
203
|
+
@event = RiCal.Event {|e| e.dtstart = "20090525T151900"}
|
204
|
+
end
|
205
|
+
|
206
|
+
context "with a given dtend" do
|
207
|
+
it "should be the same as dtend for a date time" do
|
208
|
+
@event.dtend = "20090525T161900"
|
209
|
+
@event.finish_time.should == DateTime.civil(2009,05,25,16,19,0,0)
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
context "with no dtend" do
|
216
|
+
context "and a duration" do
|
217
|
+
it "should be the dtstart plus the duration" do
|
218
|
+
@event.duration = "+P1H"
|
219
|
+
@event.finish_time.should == DateTime.civil(2009,5,25,16,19,0,0)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "and no duration" do
|
224
|
+
context "when the dtstart is not set" do
|
225
|
+
before(:each) do
|
226
|
+
@event.dtstart_property = nil
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should be nil" do
|
230
|
+
@event.finish_time.should be_nil
|
231
|
+
end
|
232
|
+
end
|
233
|
+
context "when the dstart is a datetime" do
|
234
|
+
# For cases where a "VEVENT" calendar component
|
235
|
+
# specifies a "DTSTART" property with a DATE-TIME data type but no
|
236
|
+
# "DTEND" property, the event ends on the same calendar date and time
|
237
|
+
# of day specified by the "DTSTART" property. RFC 2445 p 53
|
238
|
+
it "should be the same as start_time" do
|
239
|
+
@event.finish_time.should == @event.start_time
|
240
|
+
end
|
241
|
+
end
|
242
|
+
context "when the dtstart is a date" do
|
243
|
+
# For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE data type
|
244
|
+
# but no "DTEND" property, the events non-inclusive end is the end of the calendar date specified by
|
245
|
+
# the "DTSTART" property. RFC 2445 p 53
|
246
|
+
|
247
|
+
it "should be the end of the same day as start_time" do
|
248
|
+
@event.dtstart = "20090525"
|
249
|
+
@event.finish_time.should == DateTime.civil(2009,5,25,23,59,59,0)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
context ".zulu_occurrence_range_start_time" do
|
258
|
+
|
259
|
+
it "should be nil if there is no dtstart property" do
|
260
|
+
RiCal.Event.zulu_occurrence_range_start_time.should be_nil
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should be the utc equivalent of dtstart for a date time" do
|
264
|
+
event = RiCal.Event {|e| e.dtstart = "TZID=America/New_York:20090525T151900"}
|
265
|
+
event.zulu_occurrence_range_start_time.should == DateTime.civil(2009,05,25,19,19,0,0)
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should be the utc time of the start of the day of dtstart in the earliest timezone for a date" do
|
269
|
+
event = RiCal.Event {|e| e.dtstart = "20090525"}
|
270
|
+
event.zulu_occurrence_range_start_time.should == DateTime.civil(2009,05,24,12,0,0,0)
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should be the utc time of the dtstart in the earliest timezone if dtstart is a floating datetime" do
|
274
|
+
event = RiCal.Event {|e| e.dtstart = "20090525T151900"}
|
275
|
+
event.zulu_occurrence_range_start_time.should == DateTime.civil(2009,05,25,3,19,0,0)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
context ".zulu_occurrence_range_finish_time" do
|
280
|
+
before(:each) do
|
281
|
+
@event = RiCal.Event {|e| e.dtstart = "TZID=America/New_York:20090525T151900"}
|
282
|
+
end
|
283
|
+
|
284
|
+
context "with a given dtend" do
|
285
|
+
it "should be the utc equivalent of dtend if dtend is a date time" do
|
286
|
+
@event.dtend = "TZID=America/New_York:20090525T161900"
|
287
|
+
@event.zulu_occurrence_range_finish_time.should == DateTime.civil(2009,05,25, 20,19,0,0)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context "with no dtend" do
|
292
|
+
context "and a duration" do
|
293
|
+
it "should be the dtstart plus the duration" do
|
294
|
+
@event.duration = "+P1H"
|
295
|
+
@event.zulu_occurrence_range_finish_time.should == DateTime.civil(2009,5,25,20 ,19,0,0)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
context "and no duration" do
|
300
|
+
context "when the dtstart is not set" do
|
301
|
+
before(:each) do
|
302
|
+
@event.dtstart_property = nil
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should be nil" do
|
306
|
+
@event.zulu_occurrence_range_finish_time.should be_nil
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
context "when the dstart is a datetime" do
|
311
|
+
|
312
|
+
it "should be the same as start_time" do
|
313
|
+
@event.zulu_occurrence_range_finish_time.should == @event.zulu_occurrence_range_start_time
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
context "when the dtstart is a date" do
|
318
|
+
it "should be the utc of end of the same day as start_time in the westermost time zone" do
|
319
|
+
@event.dtstart = "20090525"
|
320
|
+
@event.zulu_occurrence_range_finish_time.should == DateTime.civil(2009,5,26,11,59,59,0)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
184
327
|
context "description property" do
|
185
328
|
before(:each) do
|
186
329
|
@ical_desc = "posted by Joyce per Zan\\nASheville\\, Rayan's Restauratn\\, Biltm\n ore Square"
|
@@ -309,7 +452,7 @@ describe RiCal::Component::Event do
|
|
309
452
|
@it.dtstart = Date.parse("April 22, 2009")
|
310
453
|
unfold(@it.export).should match(/^DTSTART;VALUE=DATE:20090422$/)
|
311
454
|
end
|
312
|
-
|
455
|
+
|
313
456
|
it "should properly fold on export when the description contains a carriage return" do
|
314
457
|
@it.description = "Weather report looks nice, 80 degrees and partly cloudy, so following Michael's suggestion, let's meet at the food court at Crossroads:\n\rhttp://www.shopcrossroadsplaza.c...\n"
|
315
458
|
export_string = @it.export
|
@@ -321,7 +464,7 @@ describe RiCal::Component::Event do
|
|
321
464
|
|
322
465
|
if RiCal::TimeWithZone
|
323
466
|
context "with ActiveSupport loaded" do
|
324
|
-
|
467
|
+
|
325
468
|
context "an event with an timezoned exdate" do
|
326
469
|
before(:each) do
|
327
470
|
@old_timezone = Time.zone
|
@@ -334,15 +477,15 @@ describe RiCal::Component::Event do
|
|
334
477
|
end
|
335
478
|
@event = cal.events.first
|
336
479
|
end
|
337
|
-
|
480
|
+
|
338
481
|
after(:each) do
|
339
482
|
Time.zone = @old_timezone
|
340
483
|
end
|
341
|
-
|
484
|
+
|
342
485
|
it "should pickup the timezone in the exdate property" do
|
343
486
|
@event.exdate.first.first.tzid.should == "America/New_York"
|
344
487
|
end
|
345
|
-
|
488
|
+
|
346
489
|
it "should have the timezone in the ical representation of the exdate property" do
|
347
490
|
@event.exdate_property.to_s.should match(%r{;TZID=America/New_York[:;]})
|
348
491
|
end
|
@@ -9,4 +9,29 @@ describe RiCal::Component::Journal do
|
|
9
9
|
RiCal::Component::Journal.entity_name.should == "VJOURNAL"
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
context ".start_time" do
|
14
|
+
it "should be the same as dtstart for a date time" do
|
15
|
+
event = RiCal.Journal {|e| e.dtstart = "20090525T151900"}
|
16
|
+
event.start_time.should == DateTime.civil(2009,05,25,15,19,0,0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be the start of the day of dtstart for a date" do
|
20
|
+
event = RiCal.Journal {|e| e.dtstart = "20090525"}
|
21
|
+
event.start_time.should == DateTime.civil(2009,05,25,0,0,0,0)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context ".finish_time" do
|
26
|
+
it "should be the same as dtstart for a date time" do
|
27
|
+
event = RiCal.Journal {|e| e.dtstart = "20090525T151900"}
|
28
|
+
event.finish_time.should == DateTime.civil(2009,05,25,15,19,0,0)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be the start of the day of dtstart for a date" do
|
32
|
+
event = RiCal.Journal {|e| e.dtstart = "20090525"}
|
33
|
+
event.finish_time.should == DateTime.civil(2009,05,25,0,0,0,0)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
12
37
|
end
|
@@ -3,6 +3,58 @@
|
|
3
3
|
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
|
4
4
|
|
5
5
|
describe RiCal::Component::Todo do
|
6
|
+
|
7
|
+
context ".start_time" do
|
8
|
+
it "should be the same as dtstart for a date time" do
|
9
|
+
todo = RiCal.Todo {|e| e.dtstart = "20090525T151900"}
|
10
|
+
todo.start_time.should == DateTime.civil(2009,05,25,15,19,0,0)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be the start of the day of dtstart for a date" do
|
14
|
+
todo = RiCal.Todo {|e| e.dtstart = "20090525"}
|
15
|
+
todo.start_time.should == DateTime.civil(2009,05,25,0,0,0,0)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be nil if the dtstart property is not set" do
|
19
|
+
RiCal.Todo.start_time.should be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context ".finish_time" do
|
24
|
+
before(:each) do
|
25
|
+
@todo = RiCal.Todo {|t| t.dtstart = "20090525T151900"}
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with a given due" do
|
29
|
+
it "should be the same as due for a date time" do
|
30
|
+
@todo.due = "20090525T161900"
|
31
|
+
@todo.finish_time.should == DateTime.civil(2009,05,25,16,19,0,0)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with no due" do
|
36
|
+
context "and a duration" do
|
37
|
+
before(:each) do
|
38
|
+
@todo.duration = "+P1H"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be the dtstart plus the duration" do
|
42
|
+
@todo.finish_time.should == DateTime.civil(2009,5,25,16,19,0,0)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be nil if the dtstart property is not set" do
|
46
|
+
@todo.dtstart_property = nil
|
47
|
+
@todo.finish_time.should be_nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and no duration" do
|
52
|
+
it "should be nil" do
|
53
|
+
@todo.finish_time.should be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
6
58
|
|
7
59
|
describe "with both due and duration specified" do
|
8
60
|
before(:each) do
|
@@ -157,6 +157,9 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
|
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
160
|
+
|
161
|
+
describe "#zulu_occurrence_range" do
|
162
|
+
end
|
160
163
|
|
161
164
|
describe "#next_occurence" do
|
162
165
|
|
@@ -507,5 +510,64 @@ ENDCAL
|
|
507
510
|
@event.occurrences.length.should == 0
|
508
511
|
end
|
509
512
|
end
|
513
|
+
|
514
|
+
|
515
|
+
describe "#zulu_occurrence_range" do
|
516
|
+
context "For an unbounded recurring event" do
|
517
|
+
before(:each) do
|
518
|
+
@event = RiCal.Event do |e|
|
519
|
+
e.dtstart = "TZID=America/New_York:20090525T143500"
|
520
|
+
e.dtend = "TZID=America/New_York:20090525T153500"
|
521
|
+
e.add_rrule("FREQ=DAILY")
|
522
|
+
end
|
523
|
+
|
524
|
+
it "should return an array with the first dtstart and nil" do
|
525
|
+
@event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), nil]
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
context "For a bounded recurring event" do
|
531
|
+
before(:each) do
|
532
|
+
@event = RiCal.Event do |e|
|
533
|
+
e.dtstart = "TZID=America/New_York:20090525T143500"
|
534
|
+
e.dtend = "TZID=America/New_York:20090525T153500"
|
535
|
+
e.add_rrule("FREQ=DAILY;COUNT=3")
|
536
|
+
end
|
537
|
+
|
538
|
+
it "should return an array with the first dtstart last dtend converted to utc" do
|
539
|
+
@event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,27,19,35,00, 0)]
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
context "For an event with no recurrence rules" do
|
545
|
+
context "with a non-floating dtstart and dtend" do
|
546
|
+
before(:each) do
|
547
|
+
@event = RiCal.Event do |e|
|
548
|
+
e.dtstart = "TZID=America/New_York:20090525T143500"
|
549
|
+
e.dtend = "TZID=America/New_York:20090525T153500"
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
it "should return an array with dtstart and dtend converted to zulu time" do
|
554
|
+
@event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,25,19,35,00, 0)]
|
555
|
+
end
|
556
|
+
end
|
557
|
+
context "with a floating dtstart and dtend" do
|
558
|
+
before(:each) do
|
559
|
+
@event = RiCal.Event do |e|
|
560
|
+
e.dtstart = "20090525T143500"
|
561
|
+
e.dtend = "20090525T153500"
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
it "should return an array with dtstart in the first timezone and dtend in the last time zone converted to zulu time" do
|
566
|
+
@event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,2,35,00, 0), DateTime.civil(2009,5,26,3,35,00, 0)]
|
567
|
+
end
|
568
|
+
end
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
510
572
|
|
511
573
|
end
|
data/tasks/ri_cal.rake
CHANGED
@@ -159,7 +159,7 @@ class VEntityUpdater
|
|
159
159
|
end
|
160
160
|
@all_props[property] = name.upcase
|
161
161
|
@property_map[name.upcase] = :"#{property}_from_string"
|
162
|
-
parent_set = needs_tz_access ? ".for_parent(self)" : ""
|
162
|
+
parent_set = needs_tz_access ? " ? property_value.for_parent(self) : nil" : ""
|
163
163
|
if type == 'date_time_or_date'
|
164
164
|
line_evaluator = "RiCal::PropertyValue::DateTime.or_date(self, line)"
|
165
165
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyredrick-ri_cal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- author=Rick DeNatale
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-26 00:00:00 -07:00
|
13
13
|
default_executable: ri_cal
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|