rubyredrick-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/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/time_machine.rb +8 -30
- data/lib/ri_cal/property_value/date_time/timezone_support.rb +1 -1
- data/lib/ri_cal/property_value/date_time.rb +25 -10
- data/lib/ri_cal.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
|
@@ -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
|