rubyredrick-ri_cal 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/History.txt +19 -2
  2. data/Manifest.txt +6 -3
  3. data/README.txt +130 -44
  4. data/Rakefile +1 -1
  5. data/copyrights.txt +1 -2
  6. data/lib/ri_cal/component/alarm.rb +1 -2
  7. data/lib/ri_cal/component/calendar.rb +25 -9
  8. data/lib/ri_cal/component/event.rb +1 -2
  9. data/lib/ri_cal/component/freebusy.rb +1 -2
  10. data/lib/ri_cal/component/journal.rb +1 -2
  11. data/lib/ri_cal/component/t_z_info_timezone.rb +1 -2
  12. data/lib/ri_cal/component/timezone/daylight_period.rb +1 -2
  13. data/lib/ri_cal/component/timezone/standard_period.rb +1 -2
  14. data/lib/ri_cal/component/timezone/timezone_period.rb +1 -2
  15. data/lib/ri_cal/component/timezone.rb +5 -2
  16. data/lib/ri_cal/component.rb +22 -7
  17. data/lib/ri_cal/core_extensions/date/conversions.rb +8 -7
  18. data/lib/ri_cal/core_extensions/date_time.rb +4 -2
  19. data/lib/ri_cal/core_extensions/object/conversions.rb +1 -1
  20. data/lib/ri_cal/core_extensions/string/conversions.rb +37 -6
  21. data/lib/ri_cal/core_extensions/time/conversions.rb +11 -7
  22. data/lib/ri_cal/core_extensions/time/tzid_access.rb +37 -0
  23. data/lib/ri_cal/core_extensions/time.rb +3 -1
  24. data/lib/ri_cal/floating_timezone.rb +32 -0
  25. data/lib/ri_cal/invalid_property_value.rb +8 -0
  26. data/lib/ri_cal/invalid_timezone_identifer.rb +2 -2
  27. data/lib/ri_cal/occurrence_enumerator.rb +5 -3
  28. data/lib/ri_cal/parser.rb +8 -8
  29. data/lib/ri_cal/properties/alarm.rb +8 -8
  30. data/lib/ri_cal/properties/event.rb +60 -60
  31. data/lib/ri_cal/properties/freebusy.rb +16 -16
  32. data/lib/ri_cal/properties/journal.rb +58 -58
  33. data/lib/ri_cal/properties/timezone_period.rb +23 -23
  34. data/lib/ri_cal/properties/todo.rb +63 -64
  35. data/lib/ri_cal/property_value/array.rb +10 -2
  36. data/lib/ri_cal/property_value/cal_address.rb +1 -2
  37. data/lib/ri_cal/property_value/date.rb +15 -3
  38. data/lib/ri_cal/property_value/date_time/additive_methods.rb +34 -33
  39. data/lib/ri_cal/property_value/date_time/time_machine.rb +175 -174
  40. data/lib/ri_cal/property_value/date_time/timezone_support.rb +70 -52
  41. data/lib/ri_cal/property_value/date_time.rb +47 -77
  42. data/lib/ri_cal/property_value/duration.rb +6 -3
  43. data/lib/ri_cal/property_value/geo.rb +1 -2
  44. data/lib/ri_cal/property_value/integer.rb +1 -2
  45. data/lib/ri_cal/property_value/occurrence_list.rb +79 -26
  46. data/lib/ri_cal/property_value/period.rb +23 -3
  47. data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +1 -2
  48. data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +1 -2
  49. data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +1 -2
  50. data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +1 -2
  51. data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +1 -2
  52. data/lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb +1 -2
  53. data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +1 -2
  54. data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +1 -2
  55. data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +1 -2
  56. data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +1 -2
  57. data/lib/ri_cal/property_value/recurrence_rule/validations.rb +1 -2
  58. data/lib/ri_cal/property_value/recurrence_rule.rb +3 -4
  59. data/lib/ri_cal/property_value/text.rb +1 -2
  60. data/lib/ri_cal/property_value/uri.rb +1 -2
  61. data/lib/ri_cal/property_value/utc_offset.rb +1 -2
  62. data/lib/ri_cal/property_value.rb +42 -11
  63. data/lib/ri_cal/required_timezones.rb +1 -2
  64. data/lib/ri_cal.rb +1 -2
  65. data/ri_cal.gemspec +6 -4
  66. data/spec/ri_cal/component/alarm_spec.rb +1 -2
  67. data/spec/ri_cal/component/calendar_spec.rb +1 -2
  68. data/spec/ri_cal/component/event_spec.rb +168 -13
  69. data/spec/ri_cal/component/freebusy_spec.rb +1 -2
  70. data/spec/ri_cal/component/journal_spec.rb +1 -2
  71. data/spec/ri_cal/component/t_z_info_timezone_spec.rb +1 -2
  72. data/spec/ri_cal/component/timezone_spec.rb +1 -2
  73. data/spec/ri_cal/component/todo_spec.rb +4 -5
  74. data/spec/ri_cal/component_spec.rb +30 -18
  75. data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
  76. data/spec/ri_cal/core_extensions/time/calculations_spec.rb +1 -2
  77. data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +1 -2
  78. data/spec/ri_cal/occurrence_enumerator_spec.rb +23 -2
  79. data/spec/ri_cal/parser_spec.rb +6 -7
  80. data/spec/ri_cal/property_value/date_spec.rb +1 -2
  81. data/spec/ri_cal/property_value/date_time_spec.rb +54 -119
  82. data/spec/ri_cal/property_value/duration_spec.rb +12 -2
  83. data/spec/ri_cal/property_value/occurrence_list_spec.rb +67 -0
  84. data/spec/ri_cal/property_value/period_spec.rb +1 -2
  85. data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +1 -2
  86. data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1 -2
  87. data/spec/ri_cal/property_value/text_spec.rb +1 -2
  88. data/spec/ri_cal/property_value/utc_offset_spec.rb +1 -2
  89. data/spec/ri_cal/property_value_spec.rb +19 -8
  90. data/spec/ri_cal/required_timezones_spec.rb +1 -2
  91. data/spec/ri_cal_spec.rb +1 -2
  92. data/spec/spec_helper.rb +2 -7
  93. data/tasks/ri_cal.rake +20 -13
  94. data/tasks/spec.rake +1 -1
  95. metadata +8 -5
  96. data/lib/ri_cal/core_extensions/date_time/conversions.rb +0 -27
  97. data/lib/ri_cal/time_with_floating_timezone.rb +0 -59
@@ -1,6 +1,5 @@
1
1
  module RiCal
2
- #- ©2009 Rick DeNatale
3
- #- All rights reserved. Refer to the file README.txt for the license
2
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
4
3
  #
5
4
  # PropertyValue provides common implementation of various RFC 2445 property value types
6
5
  class PropertyValue
@@ -12,11 +11,19 @@ module RiCal
12
11
  validate_value(options)
13
12
  ({:params => {}}).merge(options).each do |attribute, val|
14
13
  unless attribute == :name
15
- setter = :"#{attribute.to_s}="
14
+ setter = :"#{attribute.to_s.downcase}="
16
15
  send(setter, val)
17
16
  end
18
17
  end
19
18
  end
19
+
20
+ def self.if_valid_string(timezone_finder, string) #:nodoc:
21
+ if valid_string?(string)
22
+ new(timezone_finder, :value => string)
23
+ else
24
+ nil
25
+ end
26
+ end
20
27
 
21
28
  def validate_value(options) #:nodoc:
22
29
  val = options[:value]
@@ -33,7 +40,7 @@ module RiCal
33
40
  options_hash[:params] = params unless params.empty?
34
41
  end
35
42
 
36
- def self.date_or_date_time(parent, separated_line) # :nodoc:
43
+ def self.date_or_date_time(timezone_finder, separated_line) # :nodoc:
37
44
  match = separated_line[:value].match(/(\d\d\d\d)(\d\d)(\d\d)((T?)((\d\d)(\d\d)(\d\d))(Z?))?/)
38
45
  raise Exception.new("Invalid date") unless match
39
46
  if match[5] == "T" # date-time
@@ -43,18 +50,26 @@ module RiCal
43
50
  raise Exception.new("Invalid time, cannot combine Zulu with timezone reference") if parms[:tzid]
44
51
  parms['TZID'] = "UTC"
45
52
  end
46
- PropertyValue::DateTime.new(parent, separated_line.merge(:params => parms))
53
+ PropertyValue::DateTime.new(timezone_finder, separated_line.merge(:params => parms))
47
54
  else
48
- PropertyValue::Date.new(parent, separated_line)
55
+ PropertyValue::Date.new(timezone_finder, separated_line)
49
56
  end
50
57
  end
51
-
52
- def self.from_string(string) # :nodoc:
53
- new(nil, :value => string)
58
+
59
+ def self.date_or_date_time_or_period(timezone_finder, separated_line) #:nodoc:
60
+ if separated_line[:value].include?("/")
61
+ PropertyValue::Period.new(timezone_finder, separated_line)
62
+ else
63
+ date_or_date_time(timezone_finder, separated_line)
64
+ end
54
65
  end
55
66
 
56
- def self.convert(parent, value) #:nodoc:
57
- new(parent, :value => value)
67
+ # def self.from_string(string) # :nodoc:
68
+ # new(nil, :value => string)
69
+ # end
70
+
71
+ def self.convert(timezone_finder, value) #:nodoc:
72
+ new(timezone_finder, :value => value)
58
73
  end
59
74
 
60
75
  # Determine if another object is equivalent to the receiver.
@@ -101,6 +116,22 @@ module RiCal
101
116
  def to_ri_cal_property_value #:nodoc:
102
117
  self
103
118
  end
119
+
120
+ def find_timezone(timezone_identifier) #:nodoc:
121
+ if timezone_finder
122
+ timezone_finder.find_timezone(timezone_identifier)
123
+ else
124
+ raise "Unable to find timezone with tzid #{timezone_identifier}"
125
+ end
126
+ end
127
+
128
+ def default_tzid #:nodoc:
129
+ if timezone_finder
130
+ timezone_finder.default_tzid
131
+ else
132
+ PropertyValue::DateTime.default_tzid
133
+ end
134
+ end
104
135
  end
105
136
  end
106
137
 
@@ -1,6 +1,5 @@
1
1
  module RiCal
2
- #- ©2009 Rick DeNatale
3
- #- All rights reserved. Refer to the file README.txt for the license
2
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
4
3
  #
5
4
  # RequireTimezones collects the timezones used by a given calendar component or set of calendar components
6
5
  # For each timezone we collect it's id, and the earliest and latest times which reference the zone
data/lib/ri_cal.rb CHANGED
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved. Refer to the file README.txt for the license
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
  #
4
3
  # The RiCal module provides the outermost namespace, along with several convenience methods for parsing
5
4
  # and building calendars and calendar components.
data/ri_cal.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ri_cal}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.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-06}
9
+ s.date = %q{2009-05-14}
10
10
  s.default_executable = %q{ri_cal}
11
11
  s.description = %q{This is an UNOFFICIAL version. The public official version will be released on RubyForge. Github will be used
12
12
  for interim versions. USE THIS VERSION AT YOUR OWN RISK.
@@ -16,11 +16,13 @@ A new Ruby implementation of RFC2445 iCalendar.
16
16
  The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide for parsing and generating icalendar files,
17
17
  but do not support important things like enumerating occurrences of repeating events.
18
18
 
19
- This is a clean-slate implementation of RFC2445.}
19
+ This is a clean-slate implementation of RFC2445.
20
+
21
+ A Google group for discussion of this library has been set up http://groups.google.com/group/rical_gem}
20
22
  s.email = ["rick.denatale@gmail.com"]
21
23
  s.executables = ["ri_cal"]
22
24
  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"]
23
- 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/week_day_predicates.rb", "lib/ri_cal/invalid_timezone_identifer.rb", "lib/ri_cal/occurrence_enumerator.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", "lib/ri_cal/time_with_floating_timezone.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/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/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/ri_cal.rake", "tasks/spec.rake"]
25
+ 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/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/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/ri_cal.rake", "tasks/spec.rake"]
24
26
  s.has_rdoc = true
25
27
  s.homepage = %q{http://rical.rubyforge.org/}
26
28
  s.rdoc_options = ["--main", "README.txt"]
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
@@ -1,11 +1,170 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
6
5
  describe RiCal::Component::Event do
7
6
 
8
- describe ".entity_name" do
7
+ context "rdate property methods" do
8
+ before(:each) do
9
+ @event = RiCal.Event do
10
+ rdate "20090101"
11
+ end
12
+ end
13
+
14
+ context "#rdate=" do
15
+
16
+ it "should accept a single Date and replace the existing rdate" do
17
+ @event.rdate = Date.parse("20090102")
18
+ @event.rdate.should == [[Date.parse("20090102")]]
19
+ end
20
+
21
+ it "should accept a single rfc2445 date format string and replace the existing rdate" do
22
+ @event.rdate = "20090102"
23
+ @event.rdate.should == [[Date.parse("20090102")]]
24
+ end
25
+
26
+ it "should accept a single DateTime and replace the existing rdate" do
27
+ @event.rdate = DateTime.parse("20090102T012345")
28
+ @event.rdate.should == [[DateTime.parse("20090102T012345")]]
29
+ end
30
+
31
+ it "should accept a single Time and replace the existing rdate" do
32
+ @event.rdate = Time.local(2009, 1, 2, 1, 23, 45)
33
+ @event.rdate.should == [[DateTime.parse("20090102T012345")]]
34
+ end
35
+
36
+ it "should accept a single rfc2445 date-time format string and replace the existing rdate" do
37
+ @event.rdate = "20090102T012345"
38
+ @event.rdate.should == [[DateTime.parse("20090102T012345")]]
39
+ end
40
+
41
+ it "should accept a tzid prefixed rfc2445 date-time format string and replace the existing rdate" do
42
+ @event.rdate = "TZID=America/New_York:20090102T012345"
43
+ @event.rdate.should == [[DateTime.civil(2009, 1, 2, 1, 23, 45, Rational(-5, 24))]]
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ context "comment property methods" do
51
+ before(:each) do
52
+ @event = RiCal.Event
53
+ @event.comment = "Comment"
54
+ end
55
+
56
+ context "#comment=" do
57
+ it "should result in a single comment for the event" do
58
+ @event.comment.should == ["Comment"]
59
+ end
60
+
61
+ it "should replace existing comments" do
62
+ @event.comment = "Replacement"
63
+ @event.comment.should == ["Replacement"]
64
+ end
65
+ end
66
+
67
+ context "#comments=" do
68
+ it "should result in a multiple comments for the event replacing existing comments" do
69
+ @event.comments = "New1", "New2"
70
+ @event.comment.should == ["New1", "New2"]
71
+ end
72
+ end
73
+
74
+ context "#add_comment" do
75
+ it "should add a single comment" do
76
+ @event.add_comment "New1"
77
+ @event.comment.should == ["Comment", "New1"]
78
+ end
79
+ end
80
+
81
+ context "#add_comments" do
82
+ it "should add multiple comments" do
83
+ @event.add_comments "New1", "New2"
84
+ @event.comment.should == ["Comment", "New1", "New2"]
85
+ end
86
+ end
87
+
88
+ context "#remove_comment" do
89
+ it "should remove a single comment" do
90
+ @event.add_comment "New1"
91
+ @event.remove_comment "Comment"
92
+ @event.comment.should == ["New1"]
93
+ end
94
+ end
95
+
96
+ context "#remove_comments" do
97
+ it "should remove multiple comments" do
98
+ @event.add_comments "New1", "New2", "New3"
99
+ @event.remove_comments "New2", "Comment"
100
+ @event.comment.should == ["New1", "New3"]
101
+ end
102
+ end
103
+ end
104
+
105
+ context ".dtstart=" do
106
+ before(:each) do
107
+ @event = RiCal.Event
108
+ end
109
+
110
+ context "with a datetime only string" do
111
+ before(:each) do
112
+ @event.dtstart = "20090514T202400"
113
+ @it = @event.dtstart
114
+ end
115
+
116
+ it "should interpret it as the correct date-time" do
117
+ @it.should == DateTime.civil(2009, 5, 14, 20, 24, 00, Rational(0,24))
118
+ end
119
+
120
+ it "should interpret it as a floating date" do
121
+ @it.tzid.should == :floating
122
+ end
123
+ end
124
+
125
+ context "with a TZID and datetime string" do
126
+ before(:each) do
127
+ @event.dtstart = "TZID=America/New_York:20090514T202400"
128
+ @it = @event.dtstart
129
+ end
130
+
131
+ it "should interpret it as the correct date-time" do
132
+ @it.should == DateTime.civil(2009, 5, 14, 20, 24, 00, Rational(-5,24))
133
+ end
134
+
135
+ it "should set the tzid to America/New_York" do
136
+ @it.tzid.should == "America/New_York"
137
+ end
138
+ end
139
+
140
+ context "with a zulu datetime only string" do
141
+ before(:each) do
142
+ @event.dtstart = "20090514T202400Z"
143
+ @it = @event.dtstart
144
+ end
145
+
146
+ it "should interpret it as the correct date-time" do
147
+ @it.should == DateTime.civil(2009, 5, 14, 20, 24, 00, Rational(0,24))
148
+ end
149
+
150
+ it "should set the tzid to UTC" do
151
+ @it.tzid.should == "UTC"
152
+ end
153
+ end
154
+
155
+ context "with a date string" do
156
+ before(:each) do
157
+ @event.dtstart = "20090514"
158
+ @it = @event.dtstart
159
+ end
160
+
161
+ it "should interpret it as the correct date-time" do
162
+ @it.should == Date.parse("14 May 2009")
163
+ end
164
+ end
165
+ end
166
+
167
+ context ".entity_name" do
9
168
  it "should be VEVENT" do
10
169
  RiCal::Component::Event.entity_name.should == "VEVENT"
11
170
  end
@@ -63,7 +222,7 @@ describe RiCal::Component::Event do
63
222
  end
64
223
 
65
224
  it "should reset the duration property if the dtend property is set" do
66
- @it.dtend_property = "19970101".to_ri_cal_date_time_value
225
+ @it.dtend_property = "19970101T123456".to_ri_cal_date_time_value
67
226
  @it.duration_property.should be_nil
68
227
  end
69
228
 
@@ -83,12 +242,12 @@ describe RiCal::Component::Event do
83
242
  end
84
243
 
85
244
  it "should reset the dtend property if the duration property is set" do
86
- @it.duration_property = "H1".to_ri_cal_duration_value
245
+ @it.duration_property = "P1H".to_ri_cal_duration_value
87
246
  @it.dtend_property.should be_nil
88
247
  end
89
248
 
90
249
  it "should reset the dtend property if the duration ruby value is set" do
91
- @it.duration = "H1".to_ri_cal_duration_value
250
+ @it.duration = "P1H".to_ri_cal_duration_value
92
251
  @it.dtend_property.should be_nil
93
252
  end
94
253
  end
@@ -112,13 +271,9 @@ describe RiCal::Component::Event do
112
271
  require 'tzinfo'
113
272
 
114
273
  def date_time_with_tzinfo_zone(date_time, timezone="America/New_York")
115
- result = date_time.dup
116
- result.stub!(:acts_like_time?).and_return(true)
117
- time_zone = TZInfo::Timezone.get(timezone)
118
- result.stub!(:time_zone).and_return(time_zone)
119
- result
274
+ date_time.dup.set_tzid(timezone)
120
275
  end
121
-
276
+
122
277
  # Undo the effects of RFC2445 line folding
123
278
  def unfold(string)
124
279
  string.gsub("\n ", "")
@@ -135,7 +290,7 @@ describe RiCal::Component::Event do
135
290
  end
136
291
 
137
292
  it "should properly format dtstart with a UTC date-time" do
138
- @it.dtstart = DateTime.parse("April 22, 2009 1:23:45")
293
+ @it.dtstart = DateTime.parse("April 22, 2009 1:23:45").set_tzid("UTC")
139
294
  unfold(@it.export).should match(/^DTSTART;VALUE=DATE-TIME:20090422T012345Z$/)
140
295
  end
141
296
 
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
  require 'rubygems'
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
  require 'tzinfo'
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
@@ -29,7 +28,7 @@ describe RiCal::Component::Todo do
29
28
  end
30
29
 
31
30
  it "should reset the duration property if the due property is set" do
32
- @it.due_property = "19970101".to_ri_cal_date_time_value
31
+ @it.due_property = "19970101T012345".to_ri_cal_date_time_value
33
32
  @it.duration_property.should be_nil
34
33
  end
35
34
 
@@ -49,12 +48,12 @@ describe RiCal::Component::Todo do
49
48
  end
50
49
 
51
50
  it "should reset the due property if the duration property is set" do
52
- @it.duration_property = "H1".to_ri_cal_duration_value
51
+ @it.duration_property = "P1H".to_ri_cal_duration_value
53
52
  @it.due_property.should be_nil
54
53
  end
55
54
 
56
55
  it "should reset the duration property if the dtend ruby value is set" do
57
- @it.duration = "19970101"
56
+ @it.duration = "P1H"
58
57
  @it.due_property.should == nil
59
58
  end
60
59
  end
@@ -1,7 +1,7 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. spec_helper])
4
+ require 'tzinfo'
5
5
 
6
6
  describe RiCal::Component do
7
7
 
@@ -28,28 +28,40 @@ describe RiCal::Component do
28
28
  context "building a calendar with time zones" do
29
29
  it 'should allow specifying the time zone identifier' do
30
30
  event = RiCal.Event do
31
- dtstart [DateTime.parse("Feb 20, 1962 14:47:39"), 'US/Pacific']
31
+ dtstart DateTime.parse("Feb 20, 1962 14:47:39").set_tzid('US/Pacific')
32
32
  end
33
33
  event.dtstart_property.should == dt_prop(DateTime.parse("Feb 20, 1962 14:47:39"), tzid = 'US/Pacific')
34
34
  end
35
35
 
36
36
  context "adding an exception date" do
37
37
 
38
- it "should test stuff"
39
- # before(:each) do
40
- # @event = RiCal.Event do
41
- # add_exdate [DateTime.parse("Feb 20, 1962 14:47:39"), 'US/Pacific']
42
- # end
43
- # @prop = @event.exdate_property.first
44
- # end
45
- #
46
- # it "should produce an OccurrenceList for the property" do
47
- # @prop.should be_instance_of(RiCal::PropertyValue::OccurrenceList)
48
- # end
49
- #
50
- # it "should have the right exdate value" do
51
- # @event.exdate.should == ""
52
- # end
38
+ before(:each) do
39
+ @cal = RiCal.Calendar do
40
+ event do
41
+ add_exdate 'US/Eastern', "19620220T144739"
42
+ end
43
+ end
44
+ @event = @cal.events.first
45
+ @prop = @event.exdate_property.first
46
+ end
47
+
48
+ it "should produce an OccurrenceList for the property" do
49
+ @prop.should be_instance_of(RiCal::PropertyValue::OccurrenceList)
50
+ end
51
+
52
+ it "should have a property with the right ical representation" do
53
+ @prop.to_s.should == ";TZID=US/Eastern:19620220T144739"
54
+ end
55
+
56
+ context "its ruby_value" do
57
+ it "should have the right value" do
58
+ @prop.ruby_value.should == [DateTime.civil(1962, 2, 20, 14, 47, 39, Rational(-5, 24))]
59
+ end
60
+
61
+ it "should have the right tzid" do
62
+ @prop.ruby_value.first.tzid.should == "US/Eastern"
63
+ end
64
+ end
53
65
  end
54
66
  end
55
67
 
@@ -0,0 +1,78 @@
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::CoreExtensions::String::Conversions do
6
+ context "#to_ri_cal_date_time_value" do
7
+
8
+ it "should produce a DateTime property for a valid RFC 2445 datetime string" do
9
+ "20090304T123456".to_ri_cal_date_time_value.should == RiCal::PropertyValue::DateTime.new(nil, :value => "20090304T123456")
10
+ end
11
+
12
+ it "should produce a DateTime property for a valid RFC 2445 datetime string with a TZID parameter" do
13
+ "TZID=America/New_York:20090304T123456".to_ri_cal_date_time_value.should == RiCal::PropertyValue::DateTime.new(nil, :params => {"TZID" => "America/New_York"}, :value => "20090304T123456")
14
+ end
15
+
16
+ it "should raise an InvalidPropertyValue error if the string is not a valid RFC 2445 datetime string" do
17
+ lambda {"20090304".to_ri_cal_date_time_value}.should raise_error(RiCal::InvalidPropertyValue)
18
+ end
19
+ end
20
+
21
+ context "#to_ri_cal_duration_value" do
22
+
23
+ it "should produce a Duration property for a valid RFC 2445 duration string" do
24
+ "P1H".to_ri_cal_duration_value.should == RiCal::PropertyValue::Duration.new(nil, :value => "P1H")
25
+ end
26
+
27
+ it "should raise an InvalidPropertyValue error if the string is not a valid RFC 2445 datetime string" do
28
+ lambda {"20090304".to_ri_cal_duration_value}.should raise_error(RiCal::InvalidPropertyValue)
29
+ end
30
+ end
31
+
32
+ context "#to_ri_cal_date_or_date_time_value" do
33
+
34
+ it "should produce a DateTime property for a valid RFC 2445 datetime string" do
35
+ "20090304T123456".to_ri_cal_date_or_date_time_value.should == RiCal::PropertyValue::DateTime.new(nil, :value => "20090304T123456")
36
+ end
37
+
38
+ it "should produce a DateTime property for a valid RFC 2445 datetime string with a TZID parameter" do
39
+ "TZID=America/New_York:20090304T123456".to_ri_cal_date_or_date_time_value.should == RiCal::PropertyValue::DateTime.new(nil, :params => {"TZID" => "America/New_York"}, :value => "20090304T123456")
40
+ end
41
+
42
+ it "should produce a Date property for a valid RFC 2445 date string" do
43
+ "20090304".to_ri_cal_date_or_date_time_value.should == RiCal::PropertyValue::Date.new(nil, :value => "20090304")
44
+ end
45
+
46
+
47
+ it "should raise an InvalidPropertyValue error if the string is not a valid RFC 2445 date or datetime string" do
48
+ lambda {"2009/03/04".to_ri_cal_date_or_date_time_value}.should raise_error(RiCal::InvalidPropertyValue)
49
+ end
50
+ end
51
+
52
+ context "#to_ri_cal_occurrence_list_value" do
53
+
54
+ it "should produce a DateTime property for a valid RFC 2445 datetime string" do
55
+ "20090304T123456".to_ri_cal_occurrence_list_value.should == RiCal::PropertyValue::DateTime.new(nil, :value => "20090304T123456")
56
+ end
57
+
58
+ it "should produce a DateTime property for a valid RFC 2445 datetime string with a TZID parameter" do
59
+ "TZID=America/New_York:20090304T123456".to_ri_cal_occurrence_list_value.should == RiCal::PropertyValue::DateTime.new(nil, :params => {"TZID" => "America/New_York"}, :value => "20090304T123456")
60
+ end
61
+
62
+ it "should produce a Date property for a valid RFC 2445 date string" do
63
+ "20090304".to_ri_cal_occurrence_list_value.should == RiCal::PropertyValue::Date.new(nil, :value => "20090304")
64
+ end
65
+
66
+ it "should produce a Period property for a valid RFC 2445 period string (two time format)" do
67
+ "20090304T012345/20090304T023456".to_ri_cal_occurrence_list_value.should == RiCal::PropertyValue::Period.new(nil, :value => "20090304T012345/20090304T023456")
68
+ end
69
+
70
+ it "should produce a Period property for a valid RFC 2445 period string (time and duration format)" do
71
+ "20090304T012345/P1H".to_ri_cal_occurrence_list_value.should == RiCal::PropertyValue::Period.new(nil, :value => "20090304T012345/P1H")
72
+ end
73
+
74
+ it "should raise an InvalidPropertyValue error if the string is not a valid RFC 2445 date or datetime string" do
75
+ lambda {"foobar".to_ri_cal_date_or_date_time_value}.should raise_error(RiCal::InvalidPropertyValue)
76
+ end
77
+ end
78
+ end
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper])
5
4
 
@@ -1,5 +1,4 @@
1
- #- ©2009 Rick DeNatale
2
- #- All rights reserved
1
+ #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
3
2
 
4
3
  require File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper])
5
4