ri_cal 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,97 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
2
+ require 'rubygems'
3
+
4
+ cals = RiCal.parse_string <<-END_OF_DATA
5
+ BEGIN:VCALENDAR
6
+ METHOD:PUBLISH
7
+ X-WR-TIMEZONE:America/New_York
8
+ PRODID:-//Apple Inc.//iCal 3.0//EN
9
+ CALSCALE:GREGORIAN
10
+ X-WR-CALNAME:Test
11
+ VERSION:2.0
12
+ X-WR-RELCALID:58DB0663-196B-4B6B-A05A-A53049661280
13
+ X-APPLE-CALENDAR-COLOR:#0252D4
14
+ BEGIN:VTIMEZONE
15
+ TZID:Europe/Paris
16
+ BEGIN:DAYLIGHT
17
+ TZOFFSETFROM:+0100
18
+ TZOFFSETTO:+0200
19
+ DTSTART:19810329T020000
20
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
21
+ TZNAME:CEST
22
+ END:DAYLIGHT
23
+ BEGIN:STANDARD
24
+ TZOFFSETFROM:+0200
25
+ TZOFFSETTO:+0100
26
+ DTSTART:19961027T030000
27
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
28
+ TZNAME:CET
29
+ END:STANDARD
30
+ END:VTIMEZONE
31
+ BEGIN:VTIMEZONE
32
+ TZID:US/Eastern
33
+ BEGIN:DAYLIGHT
34
+ TZOFFSETFROM:-0500
35
+ TZOFFSETTO:-0400
36
+ DTSTART:20070311T020000
37
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
38
+ TZNAME:EDT
39
+ END:DAYLIGHT
40
+ BEGIN:STANDARD
41
+ TZOFFSETFROM:-0400
42
+ TZOFFSETTO:-0500
43
+ DTSTART:20071104T020000
44
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
45
+ TZNAME:EST
46
+ END:STANDARD
47
+ END:VTIMEZONE
48
+ BEGIN:VEVENT
49
+ SEQUENCE:3
50
+ TRANSP:OPAQUE
51
+ UID:AC2EFB19-A8A8-49EF-929F-CA0975374ED6
52
+ DTSTART:20090501T000000Z
53
+ DTSTAMP:20090501T174405Z
54
+ SUMMARY:UTC Event
55
+ CREATED:20090501T174347Z
56
+ DTEND:20090501T010000Z
57
+ END:VEVENT
58
+ BEGIN:VEVENT
59
+ SEQUENCE:2
60
+ TRANSP:OPAQUE
61
+ UID:A5517A09-C53E-4E1F-A642-EA47680BF2B6
62
+ DTSTART;TZID=US/Eastern:20090430T140000
63
+ DTSTAMP:20090501T174428Z
64
+ SUMMARY:Eastern Event
65
+ CREATED:20090501T174415Z
66
+ DTEND;TZID=US/Eastern:20090430T150000
67
+ END:VEVENT
68
+ BEGIN:VEVENT
69
+ SEQUENCE:3
70
+ TRANSP:OPAQUE
71
+ UID:B5024763-9197-4A60-A96E-D8D59D578BB2
72
+ DTSTART;TZID=Europe/Paris:20090430T140000
73
+ DTSTAMP:20090501T174509Z
74
+ SUMMARY:Paris Event
75
+ CREATED:20090501T174439Z
76
+ DTEND;TZID=Europe/Paris:20090430T150000
77
+ END:VEVENT
78
+ END:VCALENDAR
79
+ END_OF_DATA
80
+
81
+ cal = cals.first
82
+ event = cal.events.find {|event| event.summary == "Paris Event"}
83
+ date_time = event.dtstart_property
84
+ require 'ruby-prof'
85
+ result = RubyProf.profile do
86
+ date_time.in_time_zone("US/Eastern")
87
+ end
88
+
89
+ printer = RubyProf::GraphHtmlPrinter.new(result)
90
+ profile_file = File.expand_path(File.join(File.dirname(__FILE__), %w[.. profiles profile1.html]))
91
+ File.open(profile_file, "w") do |pf|
92
+ printer.print(pf)
93
+ end
94
+
95
+ system("open #{profile_file}")
96
+ printer = RubyProf::FlatPrinter.new(result)
97
+ printer.print(STDOUT, 0)
@@ -0,0 +1,65 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
2
+ require 'rubygems'
3
+
4
+ cals = RiCal.parse_string <<-ENDCAL
5
+ BEGIN:VCALENDAR
6
+ METHOD:PUBLISH
7
+ PRODID:-//Apple Inc.//iCal 3.0//EN
8
+ CALSCALE:GREGORIAN
9
+ X-WR-CALNAME:Utah Cycling
10
+ X-WR-RELCALID:BF579011-36BF-49C6-8C7D-E96F03DE8055
11
+ VERSION:2.0
12
+ X-WR-TIMEZONE:US/Mountain
13
+ BEGIN:VTIMEZONE
14
+ TZID:US/Mountain
15
+ BEGIN:DAYLIGHT
16
+ TZOFFSETFROM:-0700
17
+ TZOFFSETTO:-0600
18
+ DTSTART:20070311T020000
19
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
20
+ TZNAME:MDT
21
+ END:DAYLIGHT
22
+ BEGIN:STANDARD
23
+ TZOFFSETFROM:-0600
24
+ TZOFFSETTO:-0700
25
+ DTSTART:20071104T020000
26
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
27
+ TZNAME:MST
28
+ END:STANDARD
29
+ END:VTIMEZONE
30
+ BEGIN:VEVENT
31
+ SEQUENCE:11
32
+ TRANSP:OPAQUE
33
+ UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
34
+ DTSTART;TZID=US/Mountain:20090114T163000
35
+ DTSTAMP:20090107T024340Z
36
+ SUMMARY:Wild Rose XC/Skate Training Series
37
+ EXDATE;TZID=US/Mountain:20090114T163000
38
+ EXDATE;TZID=US/Mountain:20090128T163000
39
+ EXDATE;TZID=US/Mountain:20090121T163000
40
+ EXDATE;TZID=US/Mountain:20090211T163000
41
+ EXDATE;TZID=US/Mountain:20090204T163000
42
+ EXDATE;TZID=US/Mountain:20090218T163000
43
+ CREATED:20090107T024012Z
44
+ DTEND;TZID=US/Mountain:20090114T180000
45
+ LOCATION:Mountain Dell Golf Course
46
+ RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
47
+ END:VEVENT
48
+ END:VCALENDAR
49
+ ENDCAL
50
+ event = cals.first.events.first
51
+
52
+ require 'ruby-prof'
53
+ result = RubyProf.profile do
54
+ event.occurrences
55
+ end
56
+
57
+ printer = RubyProf::GraphHtmlPrinter.new(result)
58
+ profile_file = File.expand_path(File.join(File.dirname(__FILE__), %w[.. profiles profile2.html]))
59
+ File.open(profile_file, "w") do |pf|
60
+ printer.print(pf)
61
+ end
62
+
63
+ # system("open #{profile_file}")
64
+ printer = RubyProf::FlatPrinter.new(result)
65
+ printer.print(STDOUT, 0)
@@ -0,0 +1,31 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
2
+ require 'rubygems'
3
+ require "benchmark"
4
+
5
+ calendar_file = File.open(File.join(File.dirname(__FILE__), *%w[ical_files profile3.ics]), 'r')
6
+ calendar = RiCal.parse(calendar_file).first
7
+ cutoff = Date.parse("20100531")
8
+ def code_to_profile(calendar, cutoff, out=STDOUT)
9
+ calendar.events.each do |event|
10
+ event.occurrences(:before => cutoff).each do |instance|
11
+ out.puts "Event #{instance.uid.slice(0..5)}, starting #{instance.dtstart}, ending #{instance.dtend}"
12
+ end
13
+ end
14
+ end
15
+
16
+ devnul = Object.new
17
+ def devnul.puts(string)
18
+ end
19
+
20
+ Benchmark.bmbm do |results|
21
+ results.report("Benchmark:") { code_to_profile(calendar, cutoff, devnul) }
22
+ end
23
+
24
+ require 'ruby-prof'
25
+
26
+ result = RubyProf.profile do
27
+ code_to_profile(calendar, cutoff)
28
+ end
29
+
30
+ printer = RubyProf::FlatPrinter.new(result)
31
+ 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.2"
5
+ s.version = "0.5.3"
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-28}
9
+ s.date = %q{2009-06-01}
10
10
  s.default_executable = %q{ri_cal}
11
11
  s.description = %q{A new Ruby implementation of RFC2445 iCalendar.
12
12
 
@@ -19,12 +19,12 @@ 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", "ri_cal.gemspec", "sample_ical_files/from_ical_dot_app/test1.ics", "script/console", "script/destroy", "script/generate", "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/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"]
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", "profiling/ical_files/profile3.ics", "profiling/profile1.rb", "profiling/profile2.rb", "profiling/profile3.rb", "ri_cal.gemspec", "sample_ical_files/from_ical_dot_app/test1.ics", "script/console", "script/destroy", "script/generate", "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/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"]
26
26
  s.require_paths = ["lib"]
27
- s.rubyforge_project = %q{rical}
27
+ s.rubyforge_project = %q{ri-cal}
28
28
  s.rubygems_version = %q{1.3.2}
29
29
  s.summary = %q{A new Ruby implementation of RFC2445 iCalendar}
30
30
 
@@ -34,13 +34,16 @@ A Google group for discussion of this library has been set up http://groups.goog
34
34
 
35
35
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
36
36
  s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
37
+ s.add_development_dependency(%q<ruby-prof>, [">= 0"])
37
38
  s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
38
39
  else
39
40
  s.add_dependency(%q<newgem>, [">= 1.3.0"])
41
+ s.add_dependency(%q<ruby-prof>, [">= 0"])
40
42
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
41
43
  end
42
44
  else
43
45
  s.add_dependency(%q<newgem>, [">= 1.3.0"])
46
+ s.add_dependency(%q<ruby-prof>, [">= 0"])
44
47
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
45
48
  end
46
49
  end
@@ -11,27 +11,51 @@ describe RiCal::Component::Timezone do
11
11
  end
12
12
  end
13
13
 
14
+ context "for a Timezone with no DST periods" do
15
+ before(:each) do
16
+ @it = RiCal.parse_string rectify_ical <<-'ENDCAL'
17
+ BEGIN:VTIMEZONE
18
+ TZID:Australia/Brisbane
19
+ X-LIC-LOCATION:Australia/Brisbane
20
+ BEGIN:STANDARD
21
+ TZOFFSETFROM:+1000
22
+ TZOFFSETTO:+1000
23
+ TZNAME:EST
24
+ DTSTART:19700101T000000
25
+ END:STANDARD
26
+ END:VTIMEZONE
27
+ ENDCAL
28
+ @it = @it.first
29
+ end
30
+
31
+ context ".periods_for_local" do
32
+ it "should return a single period" do
33
+ @it.periods_for_local(DateTime.parse("20090530T100000")).length.should == 1
34
+ end
35
+ end
36
+ end
37
+
14
38
  context "from an iCal.app calendar for America/New_York starting March 11 2007" do
15
39
  before(:each) do
16
- @it = RiCal.parse_string <<TZEND
17
- BEGIN:VTIMEZONE
18
- TZID:US/Eastern
19
- BEGIN:DAYLIGHT
20
- TZOFFSETFROM:-0500
21
- TZOFFSETTO:-0400
22
- DTSTART:20070311T020000
23
- RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
24
- TZNAME:EDT
25
- END:DAYLIGHT
26
- BEGIN:STANDARD
27
- TZOFFSETFROM:-0400
28
- TZOFFSETTO:-0500
29
- DTSTART:20071104T020000
30
- RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
31
- TZNAME:EST
32
- END:STANDARD
33
- END:VTIMEZONE
34
- TZEND
40
+ @it = RiCal.parse_string rectify_ical <<-'ENDCAL'
41
+ BEGIN:VTIMEZONE
42
+ TZID:US/Eastern
43
+ BEGIN:DAYLIGHT
44
+ TZOFFSETFROM:-0500
45
+ TZOFFSETTO:-0400
46
+ DTSTART:20070311T020000
47
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
48
+ TZNAME:EDT
49
+ END:DAYLIGHT
50
+ BEGIN:STANDARD
51
+ TZOFFSETFROM:-0400
52
+ TZOFFSETTO:-0500
53
+ DTSTART:20071104T020000
54
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
55
+ TZNAME:EST
56
+ END:STANDARD
57
+ END:VTIMEZONE
58
+ ENDCAL
35
59
  @it = @it.first
36
60
  end
37
61
 
@@ -69,7 +93,7 @@ TZEND
69
93
  it "should return a dst period if the dst parameter is true" do
70
94
  @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00"), true).should be_dst
71
95
  end
72
-
96
+
73
97
  it "should return a std period if the dst parameter is false" do
74
98
  @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00"), false).should_not be_dst
75
99
  end
@@ -78,27 +102,21 @@ TZEND
78
102
  context "with a block" do
79
103
  it "should return a period if the block returns a TimezonePeriod" do
80
104
  mock_period = ::RiCal::Component::Timezone::TimezonePeriod.new(nil)
81
- @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00")) { |results|
82
- mock_period
83
- }.should == mock_period
105
+ @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00")) { |results| mock_period}.should == mock_period
84
106
  end
85
-
107
+
86
108
  it "should return a period if the block returns a single element array" do
87
109
  mock_period = :foo
88
- @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00")) { |results|
89
- [ mock_period]
90
- }.should == mock_period
110
+ @it.period_for_local(DateTime.parse("Nov 1, 2009 2:00")) { |results| [ mock_period]}.should == mock_period
91
111
  end
92
-
112
+
93
113
  it "should raise TZInfo::PeriodNotFound if the block returns a multi-element array" do
94
114
  lambda {
95
- @it.period_for_local(DateTime.parse("Mar 8, 2009 2:30")) {|results| [1,2]}
96
- }.should raise_error(TZInfo::PeriodNotFound)
115
+ @it.period_for_local(DateTime.parse("Mar 8, 2009 2:30")) {|results| [1,2]}}.should raise_error(TZInfo::PeriodNotFound)
116
+ end
97
117
  end
98
-
99
118
  end
100
119
  end
101
- end
102
120
 
103
121
  context ".periods_for_local" do
104
122
  context "for the date on which DST begins springing ahead e.g. Mar 8, 2009" do
@@ -150,66 +168,66 @@ TZEND
150
168
  end
151
169
  end
152
170
  end
153
-
171
+
154
172
  context "Bug report from paulsm" do
155
- before(:each) do
156
- cals = RiCal.parse_string <<ENDCAL
157
- BEGIN:VCALENDAR
158
- X-WR-TIMEZONE:America/New_York
159
- PRODID:-//Apple Inc.//iCal 3.0//EN
160
- CALSCALE:GREGORIAN
161
- X-WR-CALNAME:test
162
- VERSION:2.0
163
- X-WR-RELCALID:1884C7F8-BC8E-457F-94AC-297871967D5E
164
- X-APPLE-CALENDAR-COLOR:#2CA10B
165
- BEGIN:VTIMEZONE
166
- TZID:US/Eastern
167
- BEGIN:DAYLIGHT
168
- TZOFFSETFROM:-0500
169
- TZOFFSETTO:-0400
170
- DTSTART:20070311T020000
171
- RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
172
- TZNAME:EDT
173
- END:DAYLIGHT
174
- BEGIN:STANDARD
175
- TZOFFSETFROM:-0400
176
- TZOFFSETTO:-0500
177
- DTSTART:20071104T020000
178
- RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
179
- TZNAME:EST
180
- END:STANDARD
181
- END:VTIMEZONE
182
- BEGIN:VEVENT
183
- SEQUENCE:5
184
- TRANSP:OPAQUE
185
- UID:00481E53-9258-4EA7-9F8D-947D3041A3F2
186
- DTSTART;TZID=US/Eastern:20090224T090000
187
- DTSTAMP:20090225T000908Z
188
- SUMMARY:Test Event
189
- CREATED:20090225T000839Z
190
- DTEND;TZID=US/Eastern:20090224T100000
191
- RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090228T045959Z
192
- END:VEVENT
193
- END:VCALENDAR
194
- ENDCAL
173
+ before(:each) do
174
+ cals = RiCal.parse_string rectify_ical <<-'ENDCAL'
175
+ BEGIN:VCALENDAR
176
+ X-WR-TIMEZONE:America/New_York
177
+ PRODID:-//Apple Inc.//iCal 3.0//EN
178
+ CALSCALE:GREGORIAN
179
+ X-WR-CALNAME:test
180
+ VERSION:2.0
181
+ X-WR-RELCALID:1884C7F8-BC8E-457F-94AC-297871967D5E
182
+ X-APPLE-CALENDAR-COLOR:#2CA10B
183
+ BEGIN:VTIMEZONE
184
+ TZID:US/Eastern
185
+ BEGIN:DAYLIGHT
186
+ TZOFFSETFROM:-0500
187
+ TZOFFSETTO:-0400
188
+ DTSTART:20070311T020000
189
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
190
+ TZNAME:EDT
191
+ END:DAYLIGHT
192
+ BEGIN:STANDARD
193
+ TZOFFSETFROM:-0400
194
+ TZOFFSETTO:-0500
195
+ DTSTART:20071104T020000
196
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
197
+ TZNAME:EST
198
+ END:STANDARD
199
+ END:VTIMEZONE
200
+ BEGIN:VEVENT
201
+ SEQUENCE:5
202
+ TRANSP:OPAQUE
203
+ UID:00481E53-9258-4EA7-9F8D-947D3041A3F2
204
+ DTSTART;TZID=US/Eastern:20090224T090000
205
+ DTSTAMP:20090225T000908Z
206
+ SUMMARY:Test Event
207
+ CREATED:20090225T000839Z
208
+ DTEND;TZID=US/Eastern:20090224T100000
209
+ RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090228T045959Z
210
+ END:VEVENT
211
+ END:VCALENDAR
212
+ ENDCAL
195
213
  @event = cals.first.events.first
196
214
  end
197
-
215
+
198
216
  context "the events dtstart" do
199
217
  it "should be the right DateTime" do
200
218
  @event.dtstart.should == DateTime.civil(2009, 2, 24, 9, 0, 0, Rational(-5, 24))
201
219
  end
202
-
220
+
203
221
  it "should have the right tzid" do
204
222
  @event.dtstart.tzid.should == "US/Eastern"
205
223
  end
206
224
  end
207
-
225
+
208
226
  context "the events dtend" do
209
227
  it "should be the right DateTime" do
210
228
  @event.dtend.should == DateTime.civil(2009, 2, 24, 10, 0, 0, Rational(-5, 24))
211
229
  end
212
-
230
+
213
231
  it "should have the right tzid" do
214
232
  @event.dtend.tzid.should == "US/Eastern"
215
233
  end