README.txt in rubyredrick-ri_cal-0.0.2 vs README.txt in rubyredrick-ri_cal-0.0.3

- old
+ new

@@ -12,29 +12,32 @@ The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide for parsing and generating icalendar files, but do not support important things like enumerating occurrences of repeating events. This is a clean-slate implementation of RFC2445. +A Google group for discussion of this library has been set up http://groups.google.com/group/rical_gem + == FEATURES/PROBLEMS: * All examples of recurring events in RFC 2445 are handled. RSpec examples are provided for them. == SYNOPSIS: === Components and properties -An iCalendar calendar comprises subcomponents like Events, Timezones and Todos. Each component may have -properties, for example an event has a dtstart property which defines the time (and date) on which the event -starts. +An iCalendar calendar comprises subcomponents like Events, Timezones and Todos. Each component may +have properties, for example an event has a dtstart property which defines the time (and date) on +which the event starts. -RiCal components will provide reasonable ruby objects as the values of these properties, and allow the properties -to be set to ruby objects which are reasonable for the particular property. For example time properties like dtstart -can be set to a ruby Time, DateTime or Date object, and will return a DateTime or Date object when queried. +RiCal components will provide reasonable ruby objects as the values of these properties, and allow +the properties to be set to ruby objects which are reasonable for the particular property. For +example time properties like dtstart can be set to a ruby Time, DateTime or Date object, and will +return a DateTime or Date object when queried. -The methods for accessing the properties of each type of component are defined in a module with the same name -as the component class in the RiCal::properties module. For example the property accessing methods for -RiCal::Component::Event are defined in RiCal::Properties::Event +The methods for accessing the properties of each type of component are defined in a module with the +same name as the component class in the RiCal::properties module. For example the property +accessing methods for RiCal::Component::Event are defined in RiCal::Properties::Event === Creating Calendars and Calendar Components RiCal provides a builder DSL for creating calendars and calendar components. An example @@ -49,16 +52,18 @@ description "Segment 51" end end end -This style is for compatibility with the iCalendar and vpim to ease migration. The downside is that the block is evaluated -in the context of a different object which cause surprising if the block contains direct instance variable references or -implicit references to self. Note that, in this style, one must use 'declarative' method calls like dtstart to set values -rather than more natural attribute writer methods, like dtstart= +This style is for compatibility with the iCalendar and vpim to ease migration. The downside is that +the block is evaluated in the context of a different object which can cause surprises if the block +contains direct instance variable references or implicit references to self. Note that, in this +style, one must use 'declarative' method calls like dtstart to set values rather than more natural +attribute writer methods, like dtstart= -Alternatively you can pass a block with a single argument, in this case the component being built will be passed as that argument +Alternatively you can pass a block with a single argument, in this case the component being built +will be passed as that argument RiCal.Calendar do |cal| cal.event do |event| event.description = "MA-6 First US Manned Spaceflight" event.dtstart = DateTime.parse("2/20/1962 14:47:39") @@ -69,67 +74,148 @@ description "Segment 51" end end end -As the example shows, the two styles can be mixed, the inner block which builds the alarm uses the first style. +As the example shows, the two styles can be mixed, the inner block which builds the alarm uses the +first style. -The blocks are evaluated in the context of an object which builds the calendar or calendar component. method names -starting with add_ or remove_ are sent to the component, method names which correspond to a property value setter of -the object being built will cause that setter to be sent to the component with the provided value. +The blocks are evaluated in the context of an object which builds the calendar or calendar +component. method names starting with add_ or remove_ are sent to the component, method names which +correspond to a property value setter of the object being built will cause that setter to be sent +to the component with the provided value. -A method corresponding to the name of one of the components sub component will create the sub component and -evaluate the block in the context of the new subcomponent. +A method corresponding to the name of one of the components sub component will create the sub +component and evaluate a block if given in the context of the new subcomponent. -=== Times, Time zones, and Floating Times +==== Multiply occurring properties +Certain RFC Components have properties which may be specified multiple times, for example, an Event +may have zero or more comment properties, A component will have a family of methods for +building/manipulating such a property, e.g. + +Event#comment:: will return an array of comment strings. +Event#comment=:: takes a single comment string and gives the event a single comment property, + replacing any existing comment property collection. +Event#comments=:: takes multiple comment string arguments and gives the event a comment property for each, + replacing any existing comment property collection. +Event#add_comment:: takes a single comment string argument and adds a comment property. +Event#add_comments:: takes multiple comment string arguments and adds a comment property for each. +Event#remove_comment:: takes a single comment string argument and removes an existing comment property with that value. +Event#remove_comments:: takes multiple comment string argument and removes an existing comment property with that value. + + +==== Times, Time zones, and Floating Times + RFC2445 describes three different kinds of DATE-TIME values with respect to time zones: - 1. date-times with a local time. These have no actual time zone, instead they are to be interpreted in the local time zone of the viewer. These floating times are used for things like the New Years celebration which is observed at local midnight whether you happen to be in Paris, London, or New York. + 1. date-times with a local time. These have no actual time zone, instead they are to be + interpreted in the local time zone of the viewer. These floating times are used for things + like the New Years celebration which is observed at local midnight whether you happen to be + in Paris, London, or New York. - 2. date-times with UTC time. An application would either display these with an indication of the time zone, or convert them to the viewer's time zone, perhaps depending on user settings. + 2. date-times with UTC time. An application would either display these with an indication of + the time zone, or convert them to the viewer's time zone, perhaps depending on user settings. 3. date-times with a specified time zone. RiCal can be given ruby Time, DateTime, or Date objects for the value of properties requiring an -iCalendar DATE-TIME value. It can also be given a two element array where the first element is a Time or DateTime, -and the second is a string representation of the time zone identifier. +iCalendar DATE-TIME value. It can also be given a string -Note that a date only DATE-TIME value has no time zone by definition, effectively such values float and describe -a date as viewed by the user in his/her local time zone. +Note that a date only DATE-TIME value has no time zone by definition, effectively such values float +and describe a date as viewed by the user in his/her local time zone. -When a Ruby Time or DateTime instance is used to set properties with with a DATE-TIME value, it needs to determine -which of the three types it represents. RiCal is designed to make use of the TimeWithZone support which has been -part of the ActiveSupport component of Ruby on Rails since Rails 2.2. However it's been carefully designed not -to require Rails or ActiveSupport, but to dynamically detect the presence of the TimeWithZone support. +When a Ruby Time or DateTime instance is used to set properties with with a DATE-TIME value, it +needs to determine which of the three types it represents. RiCal is designed to make use of the +TimeWithZone support which has been part of the ActiveSupport component of Ruby on Rails since +Rails 2.2. However it's been carefully designed not to require Rails or ActiveSupport, but to +dynamically detect the presence of the TimeWithZone support. +RiCal adds accessor methods for a tzid attribute to the Ruby Time, and DateTime classes as well as +a set_tzid method which sets the tzid attribute and returns the receiver for convenience in +building calendars. If ActiveSupport::TimeWithZone is defined, a tzid instance method is defined +which returns the identifier of the time zone. + When the value of a DATE-TIME property is set to a value, the following processing occurs: -* If the object responds to both the :acts_as_time, and :timezone methods then the result of the timezone method (assumed to be an instance of TZInfoTimezone) is used as a specific local time zone. + * If the value is a string, then it must be a valid rfc 2445 date or datetime string optionally + preceded by a parameter specification e.g + + "20010911" will be interpreted as a date + + "20090530T123000Z" will be interpreted as the time May 30, 2009 at 12:30:00 UTC + + "20090530T123000" will be interpreted as the time May 30, 2009 with a floating time zone + + "TZID=America/New_York:20090530T123000" will be interpreted as the time May 30, 2009 in the time zone identified by "America/New_York" + + * If the value is a Date it will be interpreted as that date + * If the value is a Time, DateTime, or TimeWithZone then the tzid attribute will determine the + time zone. If tzid returns nil then the default tzid will be used. + +==== Default TZID -* If not then the default time zone id is used. The normal default timezone id is "UTC". You can set the default by calling ::RiCal::PropertyValue::DateTime.default_tzid = timezone_identifier, where timezone_identifier isa string, or nil. If you set the default tzid to 'none' or :none, then Times or DateTimes without timezones will be treated as floating times. +The PropertyValue::DateTime class has a default_tzid attribute which is initialized to "UTC". -Note it is likely that in a future version of RiCal that the default timezone will be set on a Calendar by Calendar -basis rather than on the DateTime property class. +The Component::Calendar class also has a default_tzid attribute, which may be set, but if it is not +set the default_tzid of the PropertyValue::DateTime class will be used. -Also note that time zone identifiers are not standardized by RFC 2445. For an RiCal originated calendar -time zone identifiers recognized by the TZInfo gem, or the TZInfo implementation provided by ActiveSupport as the case -may be may be used. The valid time zone identifiers for a non-RiCal generated calendar imported into RiCalendar -are determined by the VTIMEZONE compoents within the imported calendar. +To set the interpreting of Times and DateTimes which have no tzid as floating times, set the +default_tzid for Component::Calendar and/or PropertyValue::DateTime to :floating. -If you use a timezone identifer within a calendar which is not defined within the calendar it will detected at the time -you try to convert a timezone. In this case an InvalidTimezoneIdentifier error will be raised by the conversion method. +Also note that time zone identifiers are not standardized by RFC 2445. For an RiCal originated +calendar time zone identifiers recognized by the TZInfo gem, or the TZInfo implementation provided +by ActiveSupport as the case may be may be used. The valid time zone identifiers for a non-RiCal +generated calendar imported into RiCalendar are determined by the VTIMEZONE compoents within the +imported calendar. -To explicitly set a floating time you can use the method #with_floating_timezone on Time or DateTime instances as in +If you use a timezone identifer within a calendar which is not defined within the calendar it will +detected at the time you try to convert a timezone. In this case an InvalidTimezoneIdentifier error +will be raised by the conversion method. +To explicitly set a floating time you can use the method #with_floating_timezone on Time or +DateTime instances as in + event.dtstart = Time.parse("1/1/2010 00:00:00").with_floating_timezone + +or the equivalent +event.dtstart = Time.parse("1/1/2010 00:00:00").set_tzid(:floating) + +==== RDATE, and EXDATE properties (Occurrence Lists) + +A calendar component which supports recurrence properties (e.g. Event) may have zero or more RDATE +and or EXDATE properties. Each RDATE/EXDATE property in turn specifies one or more occurrences to +be either added to or removed from the component's recurrence list. Each element of the list may be +either a DATE, a DATETIME, or a PERIOD, or the RFC 2445 string representation of one of these: + + event.rdate = "20090305" + event.rdate = "20090305T120000" + event.rdate = "20090305T120000/P1H30M" + +It can also have multiple occurrences, specified as multiple parameters: + + event.rdate = "20090305T120000", "20090405T120000" + event.rdate = DateTime.parse("12 December, 2005 3:00 pm"), DateTime.civil(2001, 3, 4, 15, 30, 0) + + +Multiple string values can be combined separated by commas: + + event.rdate = "20090305T120000,20090405T120000" + + +An occurrence list has one set of parameters, so only one timezone can be used, the timezone may +be set explicitly via the first argument. If the first argument is a string, it is first split on +commas. Then if the first segment (up to the first comma if any) is not a valid RFC 2445 +representation of a DATE, DATETIME, or PERIOD, then it will be used as the timezone for the +occurrence list. Otherwise the arguments must have the same time zone or an InvalidPropertyValue +error will be raised. === Parsing RiCal can parse icalendar data from either a string or a Ruby io object. -The data may consist of one or more icalendar calendars, or one or more icalendar components (e.g. one or more -VEVENT, or VTODO objects.) +The data may consist of one or more icalendar calendars, or one or more icalendar components (e.g. +one or more VEVENT, or VTODO objects.) In either case the result will be an array of components. ==== From a string RiCal.parse_string <<ENDCAL BEGIN:VCALENDAR \ No newline at end of file