ri_cal 0.5.3 → 0.6.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/History.txt +11 -0
- data/Manifest.txt +9 -4
- data/README.txt +1 -4
- data/lib/ri_cal.rb +1 -1
- data/lib/ri_cal/component/calendar.rb +0 -1
- data/lib/ri_cal/core_extensions/string/conversions.rb +1 -11
- data/lib/ri_cal/core_extensions/time/conversions.rb +0 -17
- data/lib/ri_cal/core_extensions/time/week_day_predicates.rb +0 -33
- data/lib/ri_cal/fast_date_time.rb +214 -0
- data/lib/ri_cal/occurrence_enumerator.rb +3 -3
- data/lib/ri_cal/property_value/date.rb +19 -25
- data/lib/ri_cal/property_value/date_time.rb +25 -10
- data/lib/ri_cal/property_value/date_time/time_machine.rb +8 -30
- data/lib/ri_cal/property_value/date_time/timezone_support.rb +1 -1
- data/{profiling/profile1.rb → performance/paris_eastern/subject.rb} +13 -20
- data/performance/penultimate_weekday/subject.rb +15 -0
- data/{profiling/ical_files/profile3.ics → performance/psm_big_enum/ical.ics} +0 -0
- data/performance/psm_big_enum/subject.rb +16 -0
- data/{profiling/profile2.rb → performance/utah_cycling/subject.rb} +8 -18
- data/ri_cal.gemspec +3 -3
- data/script/benchmark_subject +23 -0
- data/script/profile_subject +27 -0
- data/spec/ri_cal/component/event_spec.rb +2 -1
- data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +1 -1
- data/spec/ri_cal/fast_date_time_spec.rb +67 -0
- data/spec/ri_cal/occurrence_enumerator_spec.rb +343 -343
- data/tasks/spec.rake +27 -0
- metadata +11 -6
- data/profiling/profile3.rb +0 -31
@@ -66,7 +66,7 @@ module RiCal
|
|
66
66
|
# Returns the value of the receiver as an RFC 2445 iCalendar string
|
67
67
|
def value
|
68
68
|
if @date_time_value
|
69
|
-
@date_time_value.
|
69
|
+
"#{@date_time_value.ical_str}#{tzid == "UTC" ? "Z" : ""}"
|
70
70
|
else
|
71
71
|
nil
|
72
72
|
end
|
@@ -85,16 +85,18 @@ module RiCal
|
|
85
85
|
when nil
|
86
86
|
@date_time_value = nil
|
87
87
|
when String
|
88
|
-
@date_time_value = ::DateTime.parse(val)
|
88
|
+
@date_time_value = FastDateTime.from_date_time(::DateTime.parse(val))
|
89
89
|
if val =~/Z/
|
90
90
|
self.tzid = 'UTC'
|
91
91
|
else
|
92
92
|
@tzid ||= :floating
|
93
93
|
end
|
94
|
-
when
|
94
|
+
when FastDateTime
|
95
95
|
@date_time_value = val
|
96
|
+
when ::DateTime
|
97
|
+
@date_time_value = FastDateTime.from_date_time(val)
|
96
98
|
when ::Date, ::Time
|
97
|
-
@date_time_value = ::DateTime.parse(val.to_s)
|
99
|
+
@date_time_value = FastDateTime.from_date_time(::DateTime.parse(val.to_s))
|
98
100
|
end
|
99
101
|
reset_cached_values
|
100
102
|
end
|
@@ -173,7 +175,11 @@ module RiCal
|
|
173
175
|
# Compare the receiver with another object which must respond to the to_datetime message
|
174
176
|
# The comparison is done using the Ruby DateTime representations of the two objects
|
175
177
|
def <=>(other)
|
176
|
-
@date_time_value
|
178
|
+
other.cmp_fast_date_time_value(@date_time_value)
|
179
|
+
end
|
180
|
+
|
181
|
+
def cmp_fast_date_time_value(other)
|
182
|
+
other <=> @date_time_value
|
177
183
|
end
|
178
184
|
|
179
185
|
# Determine if the receiver and other are in the same month
|
@@ -181,12 +187,21 @@ module RiCal
|
|
181
187
|
[other.year, other.month] == [year, month]
|
182
188
|
end
|
183
189
|
|
190
|
+
def with_date_time_value(date_time_value)
|
191
|
+
PropertyValue::DateTime.new(
|
192
|
+
timezone_finder,
|
193
|
+
:value => date_time_value,
|
194
|
+
:params => (params),
|
195
|
+
:tzid => tzid
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
184
199
|
def nth_wday_in_month(n, which_wday) #:nodoc:
|
185
|
-
@date_time_value.nth_wday_in_month(n, which_wday
|
200
|
+
with_date_time_value(@date_time_value.nth_wday_in_month(n, which_wday))
|
186
201
|
end
|
187
202
|
|
188
203
|
def nth_wday_in_year(n, which_wday) #:nodoc:
|
189
|
-
@date_time_value.nth_wday_in_year(n, which_wday
|
204
|
+
with_date_time_value(@date_time_value.nth_wday_in_year(n, which_wday))
|
190
205
|
end
|
191
206
|
|
192
207
|
def self.civil(year, month, day, hour, min, sec, offset, start, params) #:nodoc:
|
@@ -273,12 +288,12 @@ module RiCal
|
|
273
288
|
|
274
289
|
# Return a Date property for this DateTime
|
275
290
|
def to_ri_cal_date_value(timezone_finder=nil)
|
276
|
-
PropertyValue::Date.new(timezone_finder, :value => @date_time_value.
|
291
|
+
PropertyValue::Date.new(timezone_finder, :value => @date_time_value.ical_date_str)
|
277
292
|
end
|
278
293
|
|
279
294
|
# Return the Ruby DateTime representation of the receiver
|
280
295
|
def to_datetime #:nodoc:
|
281
|
-
@date_time_value
|
296
|
+
@date_time_value.to_datetime
|
282
297
|
end
|
283
298
|
|
284
299
|
# Returns a ruby DateTime object representing the receiver.
|
@@ -302,7 +317,7 @@ module RiCal
|
|
302
317
|
# of the International Date Line
|
303
318
|
def to_zulu_occurrence_range_start_time
|
304
319
|
if floating?
|
305
|
-
|
320
|
+
@date_time_value.advance(:hours => -12, :offset => 0).to_datetime
|
306
321
|
else
|
307
322
|
to_zulu_time
|
308
323
|
end
|
@@ -5,32 +5,10 @@ module RiCal
|
|
5
5
|
#
|
6
6
|
# Methods for DateTime which support getting values at different point in time.
|
7
7
|
module TimeMachine
|
8
|
-
def compute_change(d, options) # :nodoc:
|
9
|
-
::DateTime.civil(
|
10
|
-
options[:year] || d.year,
|
11
|
-
options[:month] || d.month,
|
12
|
-
options[:day] || d.day,
|
13
|
-
options[:hour] || d.hour,
|
14
|
-
options[:min] || (options[:hour] ? 0 : d.min),
|
15
|
-
options[:sec] || ((options[:hour] || options[:min]) ? 0 : d.sec),
|
16
|
-
options[:offset] || d.offset,
|
17
|
-
options[:start] || d.start
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def compute_advance(d, options) # :nodoc:
|
22
|
-
months_advance = (options[:years] || 0) * 12 + (options[:months] || 0)
|
23
|
-
d = d >> months_advance unless months_advance == 0
|
24
|
-
days_advance = (options[:weeks] || 0) * 7 + (options[:days] || 0)
|
25
|
-
d = d + days_advance unless days_advance == 0
|
26
|
-
datetime_advanced_by_date = compute_change(@date_time_value, :year => d.year, :month => d.month, :day => d.day)
|
27
|
-
seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
|
28
|
-
seconds_to_advance == 0 ? datetime_advanced_by_date : datetime_advanced_by_date + RiCal.RationalOffset[seconds_to_advance.round]
|
29
|
-
end
|
30
8
|
|
31
9
|
def advance(options) # :nodoc:
|
32
10
|
PropertyValue::DateTime.new(timezone_finder,
|
33
|
-
:value =>
|
11
|
+
:value => @date_time_value.advance(options),
|
34
12
|
:tzid => @tzid,
|
35
13
|
:params =>(params ? params.dup : nil)
|
36
14
|
)
|
@@ -38,34 +16,34 @@ module RiCal
|
|
38
16
|
|
39
17
|
def change(options) # :nodoc:
|
40
18
|
PropertyValue::DateTime.new(timezone_finder,
|
41
|
-
:value =>
|
19
|
+
:value => @date_time_value.change(options),
|
42
20
|
:tzid => @tzid,
|
43
21
|
:params => (params ? params.dup : nil)
|
44
22
|
)
|
45
23
|
end
|
46
24
|
|
47
25
|
def change_sec(new_sec) #:nodoc:
|
48
|
-
|
26
|
+
change(:sec => new_sec)
|
49
27
|
end
|
50
28
|
|
51
29
|
def change_min(new_min) #:nodoc:
|
52
|
-
|
30
|
+
change(:min => new_min)
|
53
31
|
end
|
54
32
|
|
55
33
|
def change_hour(new_hour) #:nodoc:
|
56
|
-
|
34
|
+
change(:hour => new_hour)
|
57
35
|
end
|
58
36
|
|
59
37
|
def change_day(new_day) #:nodoc:
|
60
|
-
|
38
|
+
change(:day => new_day)
|
61
39
|
end
|
62
40
|
|
63
41
|
def change_month(new_month) #:nodoc:
|
64
|
-
|
42
|
+
change(:month => new_month)
|
65
43
|
end
|
66
44
|
|
67
45
|
def change_year(new_year) #:nodoc:
|
68
|
-
|
46
|
+
change(:year => new_year)
|
69
47
|
end
|
70
48
|
|
71
49
|
# Return a DATE-TIME property representing the receiver on a different day (if necessary) so that
|
@@ -58,7 +58,7 @@ module RiCal
|
|
58
58
|
|
59
59
|
def rational_tz_offset #:nodoc:
|
60
60
|
if has_local_timezone?
|
61
|
-
@rational_tz_offset ||= timezone.rational_utc_offset(@date_time_value)
|
61
|
+
@rational_tz_offset ||= timezone.rational_utc_offset(@date_time_value.to_datetime)
|
62
62
|
else
|
63
63
|
@rational_tz_offset ||= RiCal.RationalOffset[0]
|
64
64
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
cals = RiCal.parse_string <<-END_OF_DATA
|
1
|
+
class Subject
|
2
|
+
def initialize(out=STDOUT)
|
3
|
+
cals = RiCal.parse_string <<-END_OF_DATA
|
5
4
|
BEGIN:VCALENDAR
|
6
5
|
METHOD:PUBLISH
|
7
6
|
X-WR-TIMEZONE:America/New_York
|
@@ -78,20 +77,14 @@ END:VEVENT
|
|
78
77
|
END:VCALENDAR
|
79
78
|
END_OF_DATA
|
80
79
|
|
81
|
-
cal = cals.first
|
82
|
-
event = cal.events.find {|event| event.summary == "Paris Event"}
|
83
|
-
date_time = event.dtstart_property
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
File.open(profile_file, "w") do |pf|
|
92
|
-
printer.print(pf)
|
80
|
+
cal = cals.first
|
81
|
+
event = cal.events.find {|event| event.summary == "Paris Event"}
|
82
|
+
@date_time = event.dtstart_property
|
83
|
+
end
|
84
|
+
|
85
|
+
def run
|
86
|
+
puts "start"
|
87
|
+
@date_time.in_time_zone("US/Eastern")
|
88
|
+
puts "done"
|
89
|
+
end
|
93
90
|
end
|
94
|
-
|
95
|
-
system("open #{profile_file}")
|
96
|
-
printer = RubyProf::FlatPrinter.new(result)
|
97
|
-
printer.print(STDOUT, 0)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'tzinfo'
|
2
|
+
|
3
|
+
|
4
|
+
class Subject
|
5
|
+
def initialize(out=STDOUT)
|
6
|
+
@event = RiCal.Event do |e|
|
7
|
+
e.dtstart = "TZID=America/New_York:19970929T090000"
|
8
|
+
e.rrule = "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
@event.occurrences(:count => 7)
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Subject
|
2
|
+
def initialize(out=STDOUT)
|
3
|
+
calendar_file = File.open(File.join(File.dirname(__FILE__), *%w[ical.ics]), 'r')
|
4
|
+
@calendar = RiCal.parse(calendar_file).first
|
5
|
+
@cutoff = Date.parse("20100531")
|
6
|
+
@out = out
|
7
|
+
end
|
8
|
+
def run
|
9
|
+
cutoff = @cutoff
|
10
|
+
@calendar.events.each do |event|
|
11
|
+
event.occurrences(:before => cutoff).each do |instance|
|
12
|
+
@out.puts "Event #{instance.uid.slice(0..5)}, starting #{instance.dtstart}, ending #{instance.dtend}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
cals = RiCal.parse_string <<-ENDCAL
|
1
|
+
class Subject
|
2
|
+
def initialize(out=STDOUT)
|
3
|
+
cals = RiCal.parse_string <<-ENDCAL
|
5
4
|
BEGIN:VCALENDAR
|
6
5
|
METHOD:PUBLISH
|
7
6
|
PRODID:-//Apple Inc.//iCal 3.0//EN
|
@@ -47,19 +46,10 @@ RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
|
|
47
46
|
END:VEVENT
|
48
47
|
END:VCALENDAR
|
49
48
|
ENDCAL
|
50
|
-
event = cals.first.events.first
|
51
|
-
|
52
|
-
require 'ruby-prof'
|
53
|
-
result = RubyProf.profile do
|
54
|
-
event.occurrences
|
55
|
-
end
|
49
|
+
@event = cals.first.events.first
|
50
|
+
end
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
printer.print(pf)
|
52
|
+
def run
|
53
|
+
@event.occurrences
|
54
|
+
end
|
61
55
|
end
|
62
|
-
|
63
|
-
# system("open #{profile_file}")
|
64
|
-
printer = RubyProf::FlatPrinter.new(result)
|
65
|
-
printer.print(STDOUT, 0)
|
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.
|
5
|
+
s.version = "0.6.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-06-
|
9
|
+
s.date = %q{2009-06-05}
|
10
10
|
s.default_executable = %q{ri_cal}
|
11
11
|
s.description = %q{A new Ruby implementation of RFC2445 iCalendar.
|
12
12
|
|
@@ -19,7 +19,7 @@ A Google group for discussion of this library has been set up http://groups.goog
|
|
19
19
|
s.email = ["rick.denatale@gmail.com"]
|
20
20
|
s.executables = ["ri_cal"]
|
21
21
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt", "copyrights.txt", "docs/draft-ietf-calsify-2446bis-08.txt", "docs/draft-ietf-calsify-rfc2445bis-09.txt", "docs/incrementers.txt"]
|
22
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/ri_cal", "component_attributes/alarm.yml", "component_attributes/calendar.yml", "component_attributes/component_property_defs.yml", "component_attributes/event.yml", "component_attributes/freebusy.yml", "component_attributes/journal.yml", "component_attributes/timezone.yml", "component_attributes/timezone_period.yml", "component_attributes/todo.yml", "copyrights.txt", "docs/draft-ietf-calsify-2446bis-08.txt", "docs/draft-ietf-calsify-rfc2445bis-09.txt", "docs/incrementers.txt", "docs/rfc2445.pdf", "lib/ri_cal.rb", "lib/ri_cal/component.rb", "lib/ri_cal/component/alarm.rb", "lib/ri_cal/component/calendar.rb", "lib/ri_cal/component/event.rb", "lib/ri_cal/component/freebusy.rb", "lib/ri_cal/component/journal.rb", "lib/ri_cal/component/t_z_info_timezone.rb", "lib/ri_cal/component/timezone.rb", "lib/ri_cal/component/timezone/daylight_period.rb", "lib/ri_cal/component/timezone/standard_period.rb", "lib/ri_cal/component/timezone/timezone_period.rb", "lib/ri_cal/component/todo.rb", "lib/ri_cal/core_extensions.rb", "lib/ri_cal/core_extensions/array.rb", "lib/ri_cal/core_extensions/array/conversions.rb", "lib/ri_cal/core_extensions/date.rb", "lib/ri_cal/core_extensions/date/conversions.rb", "lib/ri_cal/core_extensions/date_time.rb", "lib/ri_cal/core_extensions/date_time/conversions.rb", "lib/ri_cal/core_extensions/object.rb", "lib/ri_cal/core_extensions/object/conversions.rb", "lib/ri_cal/core_extensions/string.rb", "lib/ri_cal/core_extensions/string/conversions.rb", "lib/ri_cal/core_extensions/time.rb", "lib/ri_cal/core_extensions/time/calculations.rb", "lib/ri_cal/core_extensions/time/conversions.rb", "lib/ri_cal/core_extensions/time/tzid_access.rb", "lib/ri_cal/core_extensions/time/week_day_predicates.rb", "lib/ri_cal/floating_timezone.rb", "lib/ri_cal/invalid_property_value.rb", "lib/ri_cal/invalid_timezone_identifer.rb", "lib/ri_cal/occurrence_enumerator.rb", "lib/ri_cal/occurrence_period.rb", "lib/ri_cal/parser.rb", "lib/ri_cal/properties/alarm.rb", "lib/ri_cal/properties/calendar.rb", "lib/ri_cal/properties/event.rb", "lib/ri_cal/properties/freebusy.rb", "lib/ri_cal/properties/journal.rb", "lib/ri_cal/properties/timezone.rb", "lib/ri_cal/properties/timezone_period.rb", "lib/ri_cal/properties/todo.rb", "lib/ri_cal/property_value.rb", "lib/ri_cal/property_value/array.rb", "lib/ri_cal/property_value/cal_address.rb", "lib/ri_cal/property_value/date.rb", "lib/ri_cal/property_value/date_time.rb", "lib/ri_cal/property_value/date_time/additive_methods.rb", "lib/ri_cal/property_value/date_time/time_machine.rb", "lib/ri_cal/property_value/date_time/timezone_support.rb", "lib/ri_cal/property_value/duration.rb", "lib/ri_cal/property_value/geo.rb", "lib/ri_cal/property_value/integer.rb", "lib/ri_cal/property_value/occurrence_list.rb", "lib/ri_cal/property_value/period.rb", "lib/ri_cal/property_value/recurrence_rule.rb", "lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb", "lib/ri_cal/property_value/recurrence_rule/enumerator.rb", "lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb", "lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb", "lib/ri_cal/property_value/recurrence_rule/numbered_span.rb", "lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_day.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb", "lib/ri_cal/property_value/recurrence_rule/validations.rb", "lib/ri_cal/property_value/text.rb", "lib/ri_cal/property_value/uri.rb", "lib/ri_cal/property_value/utc_offset.rb", "lib/ri_cal/required_timezones.rb", "
|
22
|
+
s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/ri_cal", "component_attributes/alarm.yml", "component_attributes/calendar.yml", "component_attributes/component_property_defs.yml", "component_attributes/event.yml", "component_attributes/freebusy.yml", "component_attributes/journal.yml", "component_attributes/timezone.yml", "component_attributes/timezone_period.yml", "component_attributes/todo.yml", "copyrights.txt", "docs/draft-ietf-calsify-2446bis-08.txt", "docs/draft-ietf-calsify-rfc2445bis-09.txt", "docs/incrementers.txt", "docs/rfc2445.pdf", "lib/ri_cal.rb", "lib/ri_cal/component.rb", "lib/ri_cal/component/alarm.rb", "lib/ri_cal/component/calendar.rb", "lib/ri_cal/component/event.rb", "lib/ri_cal/component/freebusy.rb", "lib/ri_cal/component/journal.rb", "lib/ri_cal/component/t_z_info_timezone.rb", "lib/ri_cal/component/timezone.rb", "lib/ri_cal/component/timezone/daylight_period.rb", "lib/ri_cal/component/timezone/standard_period.rb", "lib/ri_cal/component/timezone/timezone_period.rb", "lib/ri_cal/component/todo.rb", "lib/ri_cal/core_extensions.rb", "lib/ri_cal/core_extensions/array.rb", "lib/ri_cal/core_extensions/array/conversions.rb", "lib/ri_cal/core_extensions/date.rb", "lib/ri_cal/core_extensions/date/conversions.rb", "lib/ri_cal/core_extensions/date_time.rb", "lib/ri_cal/core_extensions/date_time/conversions.rb", "lib/ri_cal/core_extensions/object.rb", "lib/ri_cal/core_extensions/object/conversions.rb", "lib/ri_cal/core_extensions/string.rb", "lib/ri_cal/core_extensions/string/conversions.rb", "lib/ri_cal/core_extensions/time.rb", "lib/ri_cal/core_extensions/time/calculations.rb", "lib/ri_cal/core_extensions/time/conversions.rb", "lib/ri_cal/core_extensions/time/tzid_access.rb", "lib/ri_cal/core_extensions/time/week_day_predicates.rb", "lib/ri_cal/fast_date_time.rb", "lib/ri_cal/floating_timezone.rb", "lib/ri_cal/invalid_property_value.rb", "lib/ri_cal/invalid_timezone_identifer.rb", "lib/ri_cal/occurrence_enumerator.rb", "lib/ri_cal/occurrence_period.rb", "lib/ri_cal/parser.rb", "lib/ri_cal/properties/alarm.rb", "lib/ri_cal/properties/calendar.rb", "lib/ri_cal/properties/event.rb", "lib/ri_cal/properties/freebusy.rb", "lib/ri_cal/properties/journal.rb", "lib/ri_cal/properties/timezone.rb", "lib/ri_cal/properties/timezone_period.rb", "lib/ri_cal/properties/todo.rb", "lib/ri_cal/property_value.rb", "lib/ri_cal/property_value/array.rb", "lib/ri_cal/property_value/cal_address.rb", "lib/ri_cal/property_value/date.rb", "lib/ri_cal/property_value/date_time.rb", "lib/ri_cal/property_value/date_time/additive_methods.rb", "lib/ri_cal/property_value/date_time/time_machine.rb", "lib/ri_cal/property_value/date_time/timezone_support.rb", "lib/ri_cal/property_value/duration.rb", "lib/ri_cal/property_value/geo.rb", "lib/ri_cal/property_value/integer.rb", "lib/ri_cal/property_value/occurrence_list.rb", "lib/ri_cal/property_value/period.rb", "lib/ri_cal/property_value/recurrence_rule.rb", "lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb", "lib/ri_cal/property_value/recurrence_rule/enumerator.rb", "lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb", "lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb", "lib/ri_cal/property_value/recurrence_rule/numbered_span.rb", "lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_day.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb", "lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb", "lib/ri_cal/property_value/recurrence_rule/validations.rb", "lib/ri_cal/property_value/text.rb", "lib/ri_cal/property_value/uri.rb", "lib/ri_cal/property_value/utc_offset.rb", "lib/ri_cal/required_timezones.rb", "performance/paris_eastern/subject.rb", "performance/penultimate_weekday/subject.rb", "performance/psm_big_enum/ical.ics", "performance/psm_big_enum/subject.rb", "performance/utah_cycling/subject.rb", "ri_cal.gemspec", "sample_ical_files/from_ical_dot_app/test1.ics", "script/benchmark_subject", "script/console", "script/destroy", "script/generate", "script/profile_subject", "script/txt2html", "spec/ri_cal/component/alarm_spec.rb", "spec/ri_cal/component/calendar_spec.rb", "spec/ri_cal/component/event_spec.rb", "spec/ri_cal/component/freebusy_spec.rb", "spec/ri_cal/component/journal_spec.rb", "spec/ri_cal/component/t_z_info_timezone_spec.rb", "spec/ri_cal/component/timezone_spec.rb", "spec/ri_cal/component/todo_spec.rb", "spec/ri_cal/component_spec.rb", "spec/ri_cal/core_extensions/string/conversions_spec.rb", "spec/ri_cal/core_extensions/time/calculations_spec.rb", "spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb", "spec/ri_cal/fast_date_time_spec.rb", "spec/ri_cal/occurrence_enumerator_spec.rb", "spec/ri_cal/parser_spec.rb", "spec/ri_cal/property_value/date_spec.rb", "spec/ri_cal/property_value/date_time_spec.rb", "spec/ri_cal/property_value/duration_spec.rb", "spec/ri_cal/property_value/occurrence_list_spec.rb", "spec/ri_cal/property_value/period_spec.rb", "spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb", "spec/ri_cal/property_value/recurrence_rule_spec.rb", "spec/ri_cal/property_value/text_spec.rb", "spec/ri_cal/property_value/utc_offset_spec.rb", "spec/ri_cal/property_value_spec.rb", "spec/ri_cal/required_timezones_spec.rb", "spec/ri_cal_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/gem_loader/load_active_support.rb", "tasks/gem_loader/load_tzinfo_gem.rb", "tasks/ri_cal.rake", "tasks/spec.rake"]
|
23
23
|
s.has_rdoc = true
|
24
24
|
s.homepage = %q{http://ri-cal.rubyforge.org/}
|
25
25
|
s.rdoc_options = ["--main", "README.txt"]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/benchmark_subject
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
|
5
|
+
require 'rubygems'
|
6
|
+
subject_name = ARGV[0] || "paris_eastern"
|
7
|
+
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. performance], [subject_name], "subject"))
|
9
|
+
|
10
|
+
devnul = Object.new
|
11
|
+
def devnul.puts(string)
|
12
|
+
end
|
13
|
+
|
14
|
+
subject = Subject.new(devnul)
|
15
|
+
|
16
|
+
require 'benchmark'
|
17
|
+
|
18
|
+
Benchmark.bmbm do |results|
|
19
|
+
results.report("Benchmark #{subject_name}:") { subject.run }
|
20
|
+
end
|
21
|
+
|
22
|
+
puts
|
23
|
+
puts
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/profile_subject
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
|
5
|
+
require 'rubygems'
|
6
|
+
subject_name = ARGV[0] || "paris_eastern"
|
7
|
+
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. performance], [subject_name], "subject"))
|
9
|
+
|
10
|
+
devnul = Object.new
|
11
|
+
def devnul.puts(string)
|
12
|
+
end
|
13
|
+
|
14
|
+
subject = Subject.new(devnul)
|
15
|
+
|
16
|
+
require 'ruby-prof'
|
17
|
+
|
18
|
+
result = RubyProf.profile do
|
19
|
+
subject.run
|
20
|
+
end
|
21
|
+
|
22
|
+
out_file = File.expand_path(File.join(File.dirname(__FILE__), %w[.. performance_data], "#{subject_name}.calltree"))
|
23
|
+
printer = RubyProf::CallTreePrinter.new(result)
|
24
|
+
|
25
|
+
File.open(out_file, 'w') do |f|
|
26
|
+
printer.print(f)
|
27
|
+
end
|
@@ -267,7 +267,8 @@ describe RiCal::Component::Event do
|
|
267
267
|
|
268
268
|
it "should be the utc time of the start of the day of dtstart in the earliest timezone for a date" do
|
269
269
|
event = RiCal.Event {|e| e.dtstart = "20090525"}
|
270
|
-
event.zulu_occurrence_range_start_time
|
270
|
+
result = event.zulu_occurrence_range_start_time
|
271
|
+
result.should == DateTime.civil(2009,05,24,12,0,0,0)
|
271
272
|
end
|
272
273
|
|
273
274
|
it "should be the utc time of the dtstart in the earliest timezone if dtstart is a floating datetime" do
|
@@ -7,7 +7,7 @@ describe RiCal::CoreExtensions::Time::WeekDayPredicates do
|
|
7
7
|
describe ".nth_wday_in_month" do
|
8
8
|
it "should return Feb 28, 2005 for the 4th Monday for a date in February 2005" do
|
9
9
|
expected = RiCal::PropertyValue::Date.new(nil, :value => "20050228")
|
10
|
-
it =Date.parse("Feb 7, 2005").nth_wday_in_month(4, 1)
|
10
|
+
it = Date.parse("Feb 7, 2005").nth_wday_in_month(4, 1)
|
11
11
|
it.should == expected
|
12
12
|
end
|
13
13
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
4
|
+
|
5
|
+
module RiCal
|
6
|
+
|
7
|
+
describe RiCal::FastDateTime do
|
8
|
+
context "#==" do
|
9
|
+
it "should detect equal FastDateTimes" do
|
10
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).should ==
|
11
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should detect unequal FastDateTimes" do
|
15
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).should_not ==
|
16
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 10, 0)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "#advance" do
|
20
|
+
it "should advance one second" do
|
21
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:seconds => 1).should ==
|
22
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 1, 0)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should advance minus one second" do
|
26
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:seconds => -1).should ==
|
27
|
+
FastDateTime.new(2009, 5, 29, 19, 2, 59, 0)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should advance 70 seconds" do
|
31
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:seconds => 70).should ==
|
32
|
+
FastDateTime.new(2009, 5, 29, 19, 4, 10, 0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should advance -70 seconds" do
|
36
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:seconds => -70).should ==
|
37
|
+
FastDateTime.new(2009, 5, 29, 19, 1, 50, 0)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should advance one minute" do
|
41
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:minutes => 1).should ==
|
42
|
+
FastDateTime.new(2009, 5, 29, 19, 4, 0, 0)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should advance minus one minute" do
|
46
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:minutes => -1).should ==
|
47
|
+
FastDateTime.new(2009, 5, 29, 19, 2, 0, 0)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should advance 70 minutes" do
|
51
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:minutes => 70).should ==
|
52
|
+
FastDateTime.new(2009, 5, 29, 20, 13, 0, 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should advance -70 minutes" do
|
56
|
+
FastDateTime.new(2009, 5, 29, 19, 3, 0, 0).advance(:minutes => -70).should ==
|
57
|
+
FastDateTime.new(2009, 5, 29, 17, 53, 0, 0)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should advance properly over a date" do
|
61
|
+
FastDateTime.new(2009, 5, 29, 23, 3, 0, 0).advance(:minutes => 70).should ==
|
62
|
+
FastDateTime.new(2009, 5, 30, 0, 13, 0, 0)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|