micahwedemeyer-ri_cal 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/.rvmrc +2 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +21 -0
  4. data/History.txt +402 -0
  5. data/Manifest.txt +161 -0
  6. data/README.txt +410 -0
  7. data/Rakefile +66 -0
  8. data/VERSION +1 -0
  9. data/bin/ri_cal +8 -0
  10. data/component_attributes/alarm.yml +10 -0
  11. data/component_attributes/calendar.yml +4 -0
  12. data/component_attributes/component_property_defs.yml +180 -0
  13. data/component_attributes/event.yml +45 -0
  14. data/component_attributes/freebusy.yml +16 -0
  15. data/component_attributes/journal.yml +35 -0
  16. data/component_attributes/timezone.yml +3 -0
  17. data/component_attributes/timezone_period.yml +11 -0
  18. data/component_attributes/todo.yml +46 -0
  19. data/copyrights.txt +1 -0
  20. data/docs/draft-ietf-calsify-2446bis-08.txt +7280 -0
  21. data/docs/draft-ietf-calsify-rfc2445bis-09.txt +10416 -0
  22. data/docs/incrementers.txt +7 -0
  23. data/docs/rfc2445.pdf +0 -0
  24. data/lib/ri_cal/component/alarm.rb +19 -0
  25. data/lib/ri_cal/component/calendar.rb +257 -0
  26. data/lib/ri_cal/component/event.rb +58 -0
  27. data/lib/ri_cal/component/freebusy.rb +16 -0
  28. data/lib/ri_cal/component/journal.rb +27 -0
  29. data/lib/ri_cal/component/non_standard.rb +33 -0
  30. data/lib/ri_cal/component/t_z_info_timezone.rb +153 -0
  31. data/lib/ri_cal/component/timezone/daylight_period.rb +25 -0
  32. data/lib/ri_cal/component/timezone/standard_period.rb +23 -0
  33. data/lib/ri_cal/component/timezone/timezone_period.rb +76 -0
  34. data/lib/ri_cal/component/timezone.rb +197 -0
  35. data/lib/ri_cal/component/todo.rb +42 -0
  36. data/lib/ri_cal/component.rb +256 -0
  37. data/lib/ri_cal/core_extensions/array/conversions.rb +15 -0
  38. data/lib/ri_cal/core_extensions/array.rb +7 -0
  39. data/lib/ri_cal/core_extensions/date/conversions.rb +56 -0
  40. data/lib/ri_cal/core_extensions/date.rb +13 -0
  41. data/lib/ri_cal/core_extensions/date_time/conversions.rb +50 -0
  42. data/lib/ri_cal/core_extensions/date_time.rb +15 -0
  43. data/lib/ri_cal/core_extensions/object/conversions.rb +20 -0
  44. data/lib/ri_cal/core_extensions/object.rb +8 -0
  45. data/lib/ri_cal/core_extensions/string/conversions.rb +57 -0
  46. data/lib/ri_cal/core_extensions/string.rb +8 -0
  47. data/lib/ri_cal/core_extensions/time/calculations.rb +153 -0
  48. data/lib/ri_cal/core_extensions/time/conversions.rb +42 -0
  49. data/lib/ri_cal/core_extensions/time/tzid_access.rb +50 -0
  50. data/lib/ri_cal/core_extensions/time/week_day_predicates.rb +55 -0
  51. data/lib/ri_cal/core_extensions/time.rb +14 -0
  52. data/lib/ri_cal/core_extensions.rb +11 -0
  53. data/lib/ri_cal/fast_date_time.rb +234 -0
  54. data/lib/ri_cal/floating_timezone.rb +32 -0
  55. data/lib/ri_cal/invalid_property_value.rb +8 -0
  56. data/lib/ri_cal/invalid_timezone_identifier.rb +20 -0
  57. data/lib/ri_cal/occurrence_enumerator.rb +265 -0
  58. data/lib/ri_cal/occurrence_period.rb +17 -0
  59. data/lib/ri_cal/parser.rb +145 -0
  60. data/lib/ri_cal/properties/alarm.rb +390 -0
  61. data/lib/ri_cal/properties/calendar.rb +164 -0
  62. data/lib/ri_cal/properties/event.rb +1523 -0
  63. data/lib/ri_cal/properties/freebusy.rb +593 -0
  64. data/lib/ri_cal/properties/journal.rb +1237 -0
  65. data/lib/ri_cal/properties/timezone.rb +150 -0
  66. data/lib/ri_cal/properties/timezone_period.rb +416 -0
  67. data/lib/ri_cal/properties/todo.rb +1559 -0
  68. data/lib/ri_cal/properties.rb +12 -0
  69. data/lib/ri_cal/property_value/array.rb +27 -0
  70. data/lib/ri_cal/property_value/cal_address.rb +11 -0
  71. data/lib/ri_cal/property_value/date.rb +184 -0
  72. data/lib/ri_cal/property_value/date_time/additive_methods.rb +44 -0
  73. data/lib/ri_cal/property_value/date_time/time_machine.rb +159 -0
  74. data/lib/ri_cal/property_value/date_time/timezone_support.rb +100 -0
  75. data/lib/ri_cal/property_value/date_time.rb +359 -0
  76. data/lib/ri_cal/property_value/duration.rb +110 -0
  77. data/lib/ri_cal/property_value/geo.rb +11 -0
  78. data/lib/ri_cal/property_value/integer.rb +12 -0
  79. data/lib/ri_cal/property_value/occurrence_list.rb +144 -0
  80. data/lib/ri_cal/property_value/period.rb +86 -0
  81. data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +100 -0
  82. data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +79 -0
  83. data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +148 -0
  84. data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +53 -0
  85. data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +31 -0
  86. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb +86 -0
  87. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_hour_incrementer.rb +31 -0
  88. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb +32 -0
  89. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_month_incrementer.rb +52 -0
  90. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_monthday_incrementer.rb +31 -0
  91. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_numbered_day_incrementer.rb +38 -0
  92. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_second_incrementer.rb +32 -0
  93. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb +69 -0
  94. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_yearday_incrementer.rb +31 -0
  95. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/daily_incrementer.rb +28 -0
  96. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb +80 -0
  97. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/hourly_incrementer.rb +23 -0
  98. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/list_incrementer.rb +106 -0
  99. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/minutely_incrementer.rb +23 -0
  100. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/monthly_incrementer.rb +33 -0
  101. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/null_sub_cycle_incrementer.rb +43 -0
  102. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/secondly_incrementer.rb +28 -0
  103. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/weekly_incrementer.rb +37 -0
  104. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb +57 -0
  105. data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer.rb +135 -0
  106. data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +131 -0
  107. data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +64 -0
  108. data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +33 -0
  109. data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +53 -0
  110. data/lib/ri_cal/property_value/recurrence_rule/time_manipulation.rb +42 -0
  111. data/lib/ri_cal/property_value/recurrence_rule/validations.rb +125 -0
  112. data/lib/ri_cal/property_value/recurrence_rule.rb +154 -0
  113. data/lib/ri_cal/property_value/text.rb +44 -0
  114. data/lib/ri_cal/property_value/uri.rb +11 -0
  115. data/lib/ri_cal/property_value/utc_offset.rb +33 -0
  116. data/lib/ri_cal/property_value/zulu_date_time.rb +34 -0
  117. data/lib/ri_cal/property_value.rb +159 -0
  118. data/lib/ri_cal/required_timezones.rb +55 -0
  119. data/lib/ri_cal.rb +187 -0
  120. data/micahwedemeyer-ri_cal.gemspec +227 -0
  121. data/parked_specs/ri_cal/claudio_a_bug_spec.rb +100 -0
  122. data/performance/empty_propval/subject.rb +43 -0
  123. data/performance/paris_eastern/subject.rb +90 -0
  124. data/performance/penultimate_weekday/subject.rb +15 -0
  125. data/performance/psm_big_enum/ical.ics +3171 -0
  126. data/performance/psm_big_enum/subject.rb +16 -0
  127. data/performance/utah_cycling/subject.rb +55 -0
  128. data/sample_ical_files/from_ical_dot_app/test1.ics +38 -0
  129. data/script/benchmark_subject +23 -0
  130. data/script/console +10 -0
  131. data/script/destroy +14 -0
  132. data/script/generate +14 -0
  133. data/script/profile_subject +29 -0
  134. data/script/txt2html +71 -0
  135. data/spec/ri_cal/bugreports_spec.rb +287 -0
  136. data/spec/ri_cal/component/alarm_spec.rb +12 -0
  137. data/spec/ri_cal/component/calendar_spec.rb +88 -0
  138. data/spec/ri_cal/component/event_spec.rb +735 -0
  139. data/spec/ri_cal/component/freebusy_spec.rb +12 -0
  140. data/spec/ri_cal/component/journal_spec.rb +37 -0
  141. data/spec/ri_cal/component/t_z_info_timezone_spec.rb +60 -0
  142. data/spec/ri_cal/component/timezone_spec.rb +236 -0
  143. data/spec/ri_cal/component/todo_spec.rb +112 -0
  144. data/spec/ri_cal/component_spec.rb +224 -0
  145. data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
  146. data/spec/ri_cal/core_extensions/time/calculations_spec.rb +188 -0
  147. data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +45 -0
  148. data/spec/ri_cal/fast_date_time_spec.rb +77 -0
  149. data/spec/ri_cal/inf_loop_spec.rb +78 -0
  150. data/spec/ri_cal/occurrence_enumerator_spec.rb +611 -0
  151. data/spec/ri_cal/parser_spec.rb +337 -0
  152. data/spec/ri_cal/property_value/date_spec.rb +53 -0
  153. data/spec/ri_cal/property_value/date_time_spec.rb +383 -0
  154. data/spec/ri_cal/property_value/duration_spec.rb +126 -0
  155. data/spec/ri_cal/property_value/occurrence_list_spec.rb +72 -0
  156. data/spec/ri_cal/property_value/period_spec.rb +63 -0
  157. data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +21 -0
  158. data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1814 -0
  159. data/spec/ri_cal/property_value/text_spec.rb +25 -0
  160. data/spec/ri_cal/property_value/utc_offset_spec.rb +48 -0
  161. data/spec/ri_cal/property_value_spec.rb +125 -0
  162. data/spec/ri_cal/required_timezones_spec.rb +67 -0
  163. data/spec/ri_cal_spec.rb +53 -0
  164. data/spec/spec.opts +4 -0
  165. data/spec/spec_helper.rb +50 -0
  166. data/tasks/gem_loader/load_active_support.rb +3 -0
  167. data/tasks/gem_loader/load_tzinfo_gem.rb +2 -0
  168. data/tasks/ri_cal.rake +412 -0
  169. data/tasks/spec.rake +102 -0
  170. data/website/images/rubytrends.png +0 -0
  171. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  172. data/website/stylesheets/screen.css +159 -0
  173. metadata +307 -0
@@ -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
@@ -0,0 +1,55 @@
1
+ class Subject
2
+ def initialize(out=STDOUT)
3
+ cals = RiCal.parse_string <<-ENDCAL
4
+ BEGIN:VCALENDAR
5
+ METHOD:PUBLISH
6
+ PRODID:-//Apple Inc.//iCal 3.0//EN
7
+ CALSCALE:GREGORIAN
8
+ X-WR-CALNAME:Utah Cycling
9
+ X-WR-RELCALID:BF579011-36BF-49C6-8C7D-E96F03DE8055
10
+ VERSION:2.0
11
+ X-WR-TIMEZONE:US/Mountain
12
+ BEGIN:VTIMEZONE
13
+ TZID:US/Mountain
14
+ BEGIN:DAYLIGHT
15
+ TZOFFSETFROM:-0700
16
+ TZOFFSETTO:-0600
17
+ DTSTART:20070311T020000
18
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
19
+ TZNAME:MDT
20
+ END:DAYLIGHT
21
+ BEGIN:STANDARD
22
+ TZOFFSETFROM:-0600
23
+ TZOFFSETTO:-0700
24
+ DTSTART:20071104T020000
25
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
26
+ TZNAME:MST
27
+ END:STANDARD
28
+ END:VTIMEZONE
29
+ BEGIN:VEVENT
30
+ SEQUENCE:11
31
+ TRANSP:OPAQUE
32
+ UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
33
+ DTSTART;TZID=US/Mountain:20090114T163000
34
+ DTSTAMP:20090107T024340Z
35
+ SUMMARY:Wild Rose XC/Skate Training Series
36
+ EXDATE;TZID=US/Mountain:20090114T163000
37
+ EXDATE;TZID=US/Mountain:20090128T163000
38
+ EXDATE;TZID=US/Mountain:20090121T163000
39
+ EXDATE;TZID=US/Mountain:20090211T163000
40
+ EXDATE;TZID=US/Mountain:20090204T163000
41
+ EXDATE;TZID=US/Mountain:20090218T163000
42
+ CREATED:20090107T024012Z
43
+ DTEND;TZID=US/Mountain:20090114T180000
44
+ LOCATION:Mountain Dell Golf Course
45
+ RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
46
+ END:VEVENT
47
+ END:VCALENDAR
48
+ ENDCAL
49
+ @event = cals.first.events.first
50
+ end
51
+
52
+ def run
53
+ @event.occurrences
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ BEGIN:VCALENDAR
2
+ METHOD:PUBLISH
3
+ X-WR-TIMEZONE:America/New_York
4
+ PRODID:-//Apple Inc.//iCal 3.0//EN
5
+ CALSCALE:GREGORIAN
6
+ X-WR-CALNAME:test
7
+ VERSION:2.0
8
+ X-WR-RELCALID:1884C7F8-BC8E-457F-94AC-297871967D5E
9
+ X-APPLE-CALENDAR-COLOR:#2CA10B
10
+ BEGIN:VTIMEZONE
11
+ TZID:US/Eastern
12
+ BEGIN:DAYLIGHT
13
+ TZOFFSETFROM:-0500
14
+ TZOFFSETTO:-0400
15
+ DTSTART:20070311T020000
16
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
17
+ TZNAME:EDT
18
+ END:DAYLIGHT
19
+ BEGIN:STANDARD
20
+ TZOFFSETFROM:-0400
21
+ TZOFFSETTO:-0500
22
+ DTSTART:20071104T020000
23
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
24
+ TZNAME:EST
25
+ END:STANDARD
26
+ END:VTIMEZONE
27
+ BEGIN:VEVENT
28
+ SEQUENCE:5
29
+ TRANSP:OPAQUE
30
+ UID:00481E53-9258-4EA7-9F8D-947D3041A3F2
31
+ DTSTART;TZID=US/Eastern:20090224T090000
32
+ DTSTAMP:20090225T000908Z
33
+ SUMMARY:Test Event
34
+ CREATED:20090225T000839Z
35
+ DTEND;TZID=US/Eastern:20090224T100000
36
+ RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090228T045959Z
37
+ END:VEVENT
38
+ END:VCALENDAR
@@ -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
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/ri_cal_newgem.rb'}"
9
+ puts "Loading ri_cal_newgem gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,29 @@
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
+ puts "out_file is #{out_file}"
24
+ printer = RubyProf::CallTreePrinter.new(result)
25
+ puts "got printer"
26
+
27
+ File.open(out_file, 'w') do |f|
28
+ printer.print(f)
29
+ end
data/script/txt2html ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.dirname(__FILE__) + "/../Rakefile"
4
+ require 'rubyforge'
5
+ require 'redcloth'
6
+ require 'syntax/convertors/html'
7
+ require 'erb'
8
+
9
+ download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
10
+ version = $hoe.version
11
+
12
+ def rubyforge_project_id
13
+ RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
14
+ end
15
+
16
+ class Fixnum #:nodoc:
17
+ def ordinal
18
+ # teens
19
+ return 'th' if (10..19).include?(self % 100)
20
+ # others
21
+ case self % 10
22
+ when 1: return 'st'
23
+ when 2: return 'nd'
24
+ when 3: return 'rd'
25
+ else return 'th'
26
+ end
27
+ end
28
+ end
29
+
30
+ class Time
31
+ def pretty
32
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
33
+ end
34
+ end
35
+
36
+ def convert_syntax(syntax, source)
37
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
38
+ end
39
+
40
+ if ARGV.length >= 1
41
+ src, template = ARGV
42
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
43
+ else
44
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
45
+ exit!
46
+ end
47
+
48
+ template = ERB.new(File.open(template).read)
49
+
50
+ title = nil
51
+ body = nil
52
+ File.open(src) do |fsrc|
53
+ title_text = fsrc.readline
54
+ body_text_template = fsrc.read
55
+ body_text = ERB.new(body_text_template).result(binding)
56
+ syntax_items = []
57
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
58
+ ident = syntax_items.length
59
+ element, syntax, source = $1, $2, $3
60
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
61
+ "syntax-temp-#{ident}"
62
+ }
63
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
64
+ body = RedCloth.new(body_text).to_html
65
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
66
+ end
67
+ stat = File.stat(src)
68
+ created = stat.ctime
69
+ modified = stat.mtime
70
+
71
+ $stdout << template.result(binding)
@@ -0,0 +1,287 @@
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
+ describe "http://rick_denatale.lighthouseapp.com/projects/30941/tickets/17" do
6
+ it "should parse this" do
7
+ RiCal.parse_string(<<-ENDCAL)
8
+ BEGIN:VCALENDAR
9
+ PRODID:-//Google Inc//Google Calendar 70.9054//EN
10
+ VERSION:2.0
11
+ CALSCALE:GREGORIAN
12
+ METHOD:PUBLISH
13
+ X-WR-CALNAME:Australian Tech Events
14
+ X-WR-TIMEZONE:Australia/Sydney
15
+ X-WR-CALDESC:TO ADD EVENTS INVITE THIS ADDRESS\;\npf44opfb12hherild7h2pl11b
16
+ 4@group.calendar.google.com\n\nThis is a public calendar to know what's com
17
+ ing up all around the country in the technology industry.\n\nIncludes digit
18
+ al\, internet\, web\, enterprise\, software\, hardware\, and it's various f
19
+ lavours. \n\nFeel free to add real events. Keep it real.
20
+ BEGIN:VTIMEZONE
21
+ TZID:Australia/Perth
22
+ X-LIC-LOCATION:Australia/Perth
23
+ BEGIN:STANDARD
24
+ TZOFFSETFROM:+0800
25
+ TZOFFSETTO:+0800
26
+ TZNAME:WST
27
+ DTSTART:19700101T000000
28
+ END:STANDARD
29
+ END:VTIMEZONE
30
+ BEGIN:VTIMEZONE
31
+ TZID:Australia/Sydney
32
+ X-LIC-LOCATION:Australia/Sydney
33
+ BEGIN:STANDARD
34
+ TZOFFSETFROM:+1100
35
+ TZOFFSETTO:+1000
36
+ TZNAME:EST
37
+ DTSTART:19700405T030000
38
+ RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU
39
+ END:STANDARD
40
+ BEGIN:DAYLIGHT
41
+ TZOFFSETFROM:+1000
42
+ TZOFFSETTO:+1100
43
+ TZNAME:EST
44
+ DTSTART:19701004T020000
45
+ RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=1SU
46
+ END:DAYLIGHT
47
+ END:VTIMEZONE
48
+ BEGIN:VTIMEZONE
49
+ TZID:Australia/Brisbane
50
+ X-LIC-LOCATION:Australia/Brisbane
51
+ BEGIN:STANDARD
52
+ TZOFFSETFROM:+1000
53
+ TZOFFSETTO:+1000
54
+ TZNAME:EST
55
+ DTSTART:19700101T000000
56
+ END:STANDARD
57
+ END:VTIMEZONE
58
+ BEGIN:VEVENT
59
+ DTSTART:20091110T080000Z
60
+ DTEND:20091110T100000Z
61
+ DTSTAMP:20090720T133540Z
62
+ UID:9357CC6B-C4BF-4797-AC5F-83E47C3FDA9E
63
+ URL:thehive.org.au
64
+ CLASS:PUBLIC
65
+ CREATED:20090713T123838Z
66
+ DESCRIPTION:check the website for details
67
+ LAST-MODIFIED:20090713T123838Z
68
+ LOCATION:Melbourne
69
+ SEQUENCE:1
70
+ STATUS:CONFIRMED
71
+ SUMMARY:The Hive MELBOURNE
72
+ TRANSP:OPAQUE
73
+ BEGIN:VALARM
74
+ ACTION:AUDIO
75
+ TRIGGER:-PT5M
76
+ X-WR-ALARMUID:F92A055A-2CD9-4FB2-A22A-BD4834ACEE96
77
+ ATTACH;VALUE=URI:Basso
78
+ END:VALARM
79
+ END:VEVENT
80
+ END:VCALENDAR
81
+ ENDCAL
82
+ end
83
+ end
84
+
85
+ describe "http://rick_denatale.lighthouseapp.com/projects/30941/tickets/18" do
86
+ it "should handle a subcomponent" do
87
+ event = RiCal.Event do |evt|
88
+ evt.alarm do |alarm|
89
+ alarm.trigger = "-PT5M"
90
+ alarm.action = 'AUDIO'
91
+ end
92
+ end
93
+
94
+ lambda {event.export}.should_not raise_error
95
+ end
96
+ end
97
+
98
+ describe "http://rick_denatale.lighthouseapp.com/projects/30941/tickets/19" do
99
+ before(:each) do
100
+ cals = RiCal.parse_string(<<-ENDCAL)
101
+ BEGIN:VCALENDAR
102
+ METHOD:REQUEST
103
+ PRODID:Microsoft CDO for Microsoft Exchange
104
+ VERSION:2.0
105
+ BEGIN:VTIMEZONE
106
+ TZID:(GMT-05.00) Eastern Time (US & Canada)
107
+ X-MICROSOFT-CDO-TZID:10
108
+ BEGIN:STANDARD
109
+ DTSTART:20010101T020000
110
+ TZOFFSETFROM:-0400
111
+ TZOFFSETTO:-0500
112
+ RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU
113
+ END:STANDARD
114
+ BEGIN:DAYLIGHT
115
+ DTSTART:20010101T020000
116
+ TZOFFSETFROM:-0500
117
+ TZOFFSETTO:-0400
118
+ RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU
119
+ END:DAYLIGHT
120
+ END:VTIMEZONE
121
+ BEGIN:VEVENT
122
+ DTSTAMP:20090724T143205Z
123
+ DTSTART;TZID="(GMT-05.00) Eastern Time (US & Canada)":20090804T120000
124
+ SUMMARY:FW: ALL HANDS MEETING
125
+ DTEND;TZID="(GMT-05.00) Eastern Time (US & Canada)":20090804T133000
126
+ DESCRIPTION:Some event
127
+ END:VEVENT
128
+ END:VCALENDAR
129
+ ENDCAL
130
+
131
+ @event = cals.first.events.first
132
+ end
133
+
134
+ it "not raise an error accessing DTSTART" do
135
+ lambda {@event.dtstart}.should_not raise_error
136
+ end
137
+ end
138
+
139
+ describe "freebusy problem" do
140
+ before(:each) do
141
+ cal = RiCal.parse_string(<<ENDCAL)
142
+ BEGIN:VCALENDAR
143
+ METHOD:PUBLISH
144
+ VERSION:2.0
145
+ PRODID:Zimbra-Calendar-Provider
146
+ BEGIN:VFREEBUSY
147
+ ORGANIZER:mailto:bj-wagoner@wiu.edu
148
+ DTSTAMP:20090805T200417Z
149
+ DTSTART:20090705T200417Z
150
+ DTEND:20091006T200417Z
151
+ URL:https://zimbra9.wiu.edu/service/home/bjw101/calendar.ifb?null
152
+ FREEBUSY;FBTYPE=BUSY:20090705T200417Z/20090707T050000Z
153
+ FREEBUSY;FBTYPE=BUSY-TENTATIVE:20090711T050000Z/20090712T050000Z
154
+ END:VFREEBUSY
155
+ END:VCALENDAR
156
+ ENDCAL
157
+ @free_busy = cal.first.freebusys.first
158
+ end
159
+
160
+ it "should have two periods" do
161
+ @free_busy.freebusy.map {|fb| fb.to_s}.should == [
162
+ ";FBTYPE=BUSY:20090705T200417Z/20090707T050000Z",
163
+ ";FBTYPE=BUSY-TENTATIVE:20090711T050000Z/20090712T050000Z"
164
+ ]
165
+ end
166
+ end
167
+
168
+ describe "a calendar including vvenue" do
169
+ before(:each) do
170
+ @cal_string = <<ENDCAL
171
+ BEGIN:VCALENDAR
172
+ VERSION:2.0
173
+ X-WR-CALNAME:Upcoming Event: Film in the Park
174
+ PRODID:-//Upcoming.org/Upcoming ICS//EN
175
+ CALSCALE:GREGORIAN
176
+ METHOD:PUBLISH
177
+ BEGIN:VEVENT
178
+ DTSTART:20090807T201500
179
+ DTEND:20090807T220000
180
+ RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090822T000000
181
+ GEO:-104.997;39.546
182
+ TRANSP:TRANSPARENT
183
+ SUMMARY:Film in the Park
184
+ DESCRIPTION: [Full details at http://upcoming.yahoo.com/event/3082410/ ] Plan to join the HRCA family summer tradition! Bring a blanket and enjoy great FREE family movies! Mark the dates now!
185
+ URL;VALUE=URI:http://upcoming.yahoo.com/event/3082410/
186
+ UID:http://upcoming.yahoo.com/event/3082410/
187
+ DTSTAMP:20090716T103006
188
+ LAST-UPDATED:20090716T103006
189
+ CATEGORIES:Family
190
+ ORGANIZER;CN=mepling95:X-ADDR:http://upcoming.yahoo.com/user/637615/
191
+ LOCATION;VENUE-UID="http://upcoming.yahoo.com/venue/130821/":Civic Green Park @ 9370 Ridgeline Boulevard\, Highlands Ranch\, Colorado 80126 US
192
+ END:VEVENT
193
+ BEGIN:VVENUE
194
+ X-VVENUE-INFO:http://evdb.com/docs/ical-venue/drft-norris-ical-venue.html
195
+ NAME:Civic Green Park
196
+ ADDRESS:9370 Ridgeline Boulevard
197
+ CITY:Highlands Ranch
198
+ REGION;X-ABBREV=co:Colorado
199
+ COUNTRY;X-ABBREV=us:United States
200
+ POSTALCODE:80126
201
+ GEO:39.546;-104.997
202
+ URL;X-LABEL=Venue Info:http://www.hrmafestival.org
203
+ END:VVENUE
204
+ END:VCALENDAR
205
+ ENDCAL
206
+
207
+ @venue_str = <<ENDVENUE
208
+ BEGIN:VVENUE
209
+ X-VVENUE-INFO:http://evdb.com/docs/ical-venue/drft-norris-ical-venue.html
210
+ NAME:Civic Green Park
211
+ ADDRESS:9370 Ridgeline Boulevard
212
+ CITY:Highlands Ranch
213
+ REGION;X-ABBREV=co:Colorado
214
+ COUNTRY;X-ABBREV=us:United States
215
+ POSTALCODE:80126
216
+ GEO:39.546;-104.997
217
+ URL;X-LABEL=Venue Info:http://www.hrmafestival.org
218
+ END:VVENUE
219
+ ENDVENUE
220
+ end
221
+
222
+ it "should parse without error" do
223
+ lambda {RiCal.parse_string(@cal_string)}.should_not raise_error
224
+ end
225
+
226
+ it "should export correctly" do
227
+ export = RiCal.parse_string(@cal_string).first.export
228
+ export.should include(@venue_str)
229
+ end
230
+ end
231
+
232
+ describe "ticket #23" do
233
+ describe "RecurrenceRule" do
234
+ it "should convert the rrule string to a hash" do
235
+ rrule = RiCal::PropertyValue::RecurrenceRule.convert(nil, 'INTERVAL=2;FREQ=WEEKLY;BYDAY=TH,TU')
236
+ rrule.to_options_hash.should == {:freq => 'WEEKLY', :byday => %w{TH TU}, :interval => 2}
237
+ end
238
+ end
239
+ end
240
+
241
+ describe "ticket #26" do
242
+ describe "Date property" do
243
+ it "should handle for_parent" do
244
+ lambda {
245
+ RiCal::PropertyValue::Date.convert(:foo, Date.parse("20090927")).for_parent(:bar)}.should_not raise_error
246
+ end
247
+ end
248
+ end
249
+
250
+ describe "ticket 29:supress-x-rical-tzsource-when-not-relevant" do
251
+ it "should parse its own output" do
252
+ cal_string = %Q(BEGIN:VCALENDAR
253
+ PRODID:-//Google Inc//Google Calendar 70.9054//EN
254
+ BEGIN:VEVENT
255
+ DTSTART:20100610T100000
256
+ DTEND:20100610T110000
257
+ END:VEVENT
258
+ END:VCALENDAR)
259
+ lambda {RiCal.parse_string(RiCal.parse_string(cal_string).first.to_s)}.should_not raise_error
260
+ end
261
+ end
262
+
263
+ describe "X-properties" do
264
+ it "should round-trip the X-WR-CALNAME property" do
265
+ cal_string = %Q(BEGIN:VCALENDAR
266
+ PRODID:-//Markthisdate.com\,0.7
267
+ VERSION:2.0
268
+ CALSCALE:GREGORIAN
269
+ METHOD:PUBLISH
270
+ X-WR-CALNAME: AFC Ajax Eredivisie wedstrijden 2010 - 2011
271
+ END:VCALENDAR)
272
+ cal = RiCal.parse_string(cal_string).first
273
+ cal.x_wr_calname.first.should == " AFC Ajax Eredivisie wedstrijden 2010 - 2011"
274
+ end
275
+
276
+ it "should define x-properties correctly" do
277
+ calendar = RiCal.Calendar
278
+ calendar.add_x_property 'x_wr_calname', 'Lifetracker'
279
+ calendar.export.should == %Q(BEGIN:VCALENDAR
280
+ PRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN
281
+ CALSCALE:GREGORIAN
282
+ VERSION:2.0
283
+ X-WR-CALNAME:Lifetracker
284
+ END:VCALENDAR
285
+ )
286
+ end
287
+ end
@@ -0,0 +1,12 @@
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
+ describe RiCal::Component::Alarm do
6
+
7
+ describe ".entity_name" do
8
+ it "should be VALARM" do
9
+ RiCal::Component::Alarm.entity_name.should == "VALARM"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
+
4
+ require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
+
6
+ describe RiCal::Component::Calendar do
7
+
8
+ context ".entity_name" do
9
+ it "should be VCALENDAR" do
10
+ RiCal::Component::Calendar.entity_name.should == "VCALENDAR"
11
+ end
12
+ end
13
+
14
+ context "a new instance" do
15
+ before(:each) do
16
+ @it = RiCal.Calendar
17
+ end
18
+
19
+ it "should have a tz_source of 'TZ_INFO" do
20
+ @it.tz_source.should == "TZINFO"
21
+ end
22
+
23
+ it "should export a product id with an X-RICAL-TZSOURCE parameter of TZINFO" do
24
+ @it.export.should match(%r{\nPRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN\n})
25
+ end
26
+ end
27
+
28
+ context "an imported instance with a tzinfo source" do
29
+ before(:each) do
30
+ @it = RiCal.parse_string("BEGIN:VCALENDAR\nPRODID;X-RICAL-TZSOURCE=TZINFO:-\/\/com.denhaven2\/NONSGML ri_cal gem\/\/EN\nCALSCALE:GREGORIAN\nVERSION:2.0\nEND:VCALENDAR\n").first
31
+ end
32
+
33
+ it "should have a tz_source of 'TZ_INFO" do
34
+ @it.tz_source.should == "TZINFO"
35
+ end
36
+
37
+ it "should export a product id with an X-RICAL-TZSOURCE parameter of TZINFO" do
38
+ @it.export.should match(%r{\nPRODID;X-RICAL-TZSOURCE=TZINFO:-//com.denhaven2/NONSGML ri_cal gem//EN\n})
39
+ end
40
+ end
41
+
42
+ context "an imported instance without a tzinfo source" do
43
+ before(:each) do
44
+ @it = RiCal.parse_string("BEGIN:VCALENDAR\nPRODID:-//Apple Inc.//iCal 3.0//EN\nEND:VCALENDAR\n").first
45
+ end
46
+
47
+ it "should have a tz_source of nil" do
48
+ @it.tz_source.should be_nil
49
+ end
50
+
51
+ it "should export not export a product id with an X-RICAL-TZSOURCE parameter of TZINFO" do
52
+ @it.export.should_not match(%r{X-RICAL-TZSOURCE=TZINFO:})
53
+ end
54
+ end
55
+
56
+ describe RiCal::Component::Calendar::FoldingStream do
57
+ before(:each) do
58
+ @it = RiCal::Component::Calendar::FoldingStream.new(nil)
59
+ end
60
+
61
+ describe "#utf_safe_split" do
62
+ it "should properly split an ascii string" do
63
+ @it.utf8_safe_split("abcdef", 3).should == ["abc", "def"]
64
+ end
65
+
66
+ it "should return a nil remainder if the string has less than n characters" do
67
+ @it.utf8_safe_split("a",2).should == ["a", nil]
68
+ end
69
+
70
+ it "should return a nil remainder if the string has exactly n characters" do
71
+ @it.utf8_safe_split("ab",2).should == ["ab", nil]
72
+ end
73
+
74
+ it "should not split a 2-byte utf character" do
75
+ @it.utf8_safe_split("Café", 3).should == ["Caf", "é"]
76
+ @it.utf8_safe_split("Café", 4).should == ["Caf", "é"]
77
+ @it.utf8_safe_split("Café", 5).should == ["Café", nil]
78
+ end
79
+
80
+ it "should not split a 3-byte utf character" do
81
+ @it.utf8_safe_split("Prix €200", 5).should == ["Prix ", "€200"]
82
+ @it.utf8_safe_split("Prix €200", 6).should == ["Prix ", "€200"]
83
+ @it.utf8_safe_split("Prix €200", 7).should == ["Prix ", "€200"]
84
+ @it.utf8_safe_split("Prix €200", 8).should == ["Prix €", "200"]
85
+ end
86
+ end
87
+ end
88
+ end