rubyredrick-ri_cal 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,14 @@
1
+ === 0.0.9
2
+ * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/4
3
+ Missing comparison methods in PropertyValue::Date
4
+ * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/6
5
+ Type of dtstart and dtend (DATE or DATETIME) now preserved on enumeration
1
6
  === 0.0.8
2
- * Fixed http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/1-occurrence-lists-not-picking-up-timewithzone-identifier#ticket-1-2
3
- * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/2-date-property-subtraction-bug
4
- * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/3-fwd-ri_cal-question
7
+ * Fixed http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/1
8
+ EXDATE and RDATE now pick up the timezone from DateTime, Time, and TimeWithZone values
9
+ * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/2
10
+ Missing arithmetic methods in PropertyValue::Date
11
+ * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/3
5
12
  Components with no recurrence rules or rdate properties failed on enumeration, they now
6
13
  will enumerate a single occurrence
7
14
 
data/Manifest.txt CHANGED
@@ -36,6 +36,7 @@ lib/ri_cal/core_extensions/array/conversions.rb
36
36
  lib/ri_cal/core_extensions/date.rb
37
37
  lib/ri_cal/core_extensions/date/conversions.rb
38
38
  lib/ri_cal/core_extensions/date_time.rb
39
+ lib/ri_cal/core_extensions/date_time/conversions.rb
39
40
  lib/ri_cal/core_extensions/object.rb
40
41
  lib/ri_cal/core_extensions/object/conversions.rb
41
42
  lib/ri_cal/core_extensions/string.rb
@@ -22,6 +22,39 @@ module RiCal
22
22
  def to_ri_cal_property_value(timezone_finder = nil)
23
23
  to_ri_cal_date_value(timezone_finder)
24
24
  end
25
+
26
+ unless defined? ActiveSupport
27
+ # A method to keep Time, Date and DateTime instances interchangeable on conversions.
28
+ # In this case, it simply returns +self+.
29
+ def to_date
30
+ self
31
+ end if RUBY_VERSION < '1.9'
32
+
33
+ # Converts a Date instance to a Time, where the time is set to the beginning of the day.
34
+ # The timezone can be either :local or :utc (default :local).
35
+ #
36
+ # ==== Examples
37
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
38
+ #
39
+ # date.to_time # => Sat Nov 10 00:00:00 0800 2007
40
+ # date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007
41
+ #
42
+ # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
43
+ def to_time(form = :local)
44
+ ::Time.send("#{form}_time", year, month, day)
45
+ end
46
+
47
+ # Converts a Date instance to a DateTime, where the time is set to the beginning of the day
48
+ # and UTC offset is set to 0.
49
+ #
50
+ # ==== Examples
51
+ # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
52
+ #
53
+ # date.to_datetime # => Sat, 10 Nov 2007 00:00:00 0000
54
+ def to_datetime
55
+ ::DateTime.civil(year, month, day, 0, 0, 0, 0)
56
+ end if RUBY_VERSION < '1.9'
57
+ end
25
58
  end
26
59
  end
27
60
  end
@@ -0,0 +1,50 @@
1
+ require 'date'
2
+ module RiCal
3
+ module CoreExtensions #:nodoc:
4
+ module DateTime #:nodoc:
5
+ #- ©2009 Rick DeNatale
6
+ #- All rights reserved. Refer to the file README.txt for the license
7
+ #
8
+ module Conversions #:nodoc:
9
+ # Return an RiCal::PropertyValue::DateTime representing the receiver
10
+ def to_ri_cal_date_time_value(timezone_finder = nil) #:nodoc:
11
+ RiCal::PropertyValue::DateTime.new(
12
+ timezone_finder,
13
+ :value => strftime("%Y%m%dT%H%M%S"),
14
+ :params => {"TZID" => self.tzid || :default})
15
+ end
16
+
17
+ alias_method :to_ri_cal_date_or_date_time_value, :to_ri_cal_date_time_value #:nodoc:
18
+ alias_method :to_ri_cal_occurrence_list_value, :to_ri_cal_date_time_value #:nodoc:
19
+
20
+ # Return the natural ri_cal_property for this object
21
+ def to_ri_cal_property_value(timezone_finder = nil) #:nodoc:
22
+ to_ri_cal_date_time_value(timezone_finder)
23
+ end
24
+
25
+ # Return a copy of this object which will be interpreted as a floating time.
26
+ def with_floating_timezone
27
+ dup.set_tzid(:floating)
28
+ end
29
+
30
+ unless defined? ActiveSupport
31
+ # Converts self to a Ruby Date object; time portion is discarded
32
+ def to_date
33
+ ::Date.new(year, month, day)
34
+ end
35
+
36
+ # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class
37
+ # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time
38
+ def to_time
39
+ self.offset == 0 ? ::Time.utc_time(year, month, day, hour, min, sec) : self
40
+ end
41
+
42
+ # To be able to keep Times, Dates and DateTimes interchangeable on conversions
43
+ def to_datetime
44
+ self
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/time/conversions.rb"
1
+ require "#{File.dirname(__FILE__)}/date_time/conversions.rb"
2
2
  require "#{File.dirname(__FILE__)}/time/tzid_access.rb"
3
3
  require "#{File.dirname(__FILE__)}/time/week_day_predicates.rb"
4
4
  require "#{File.dirname(__FILE__)}/time/calculations.rb"
@@ -11,5 +11,5 @@ class DateTime #:nodoc:
11
11
  include RiCal::CoreExtensions::Time::WeekDayPredicates
12
12
  include RiCal::CoreExtensions::Time::Calculations
13
13
  include RiCal::CoreExtensions::Time::TzidAccess
14
- include RiCal::CoreExtensions::Time::Conversions
14
+ include RiCal::CoreExtensions::DateTime::Conversions
15
15
  end
@@ -25,6 +25,36 @@ module RiCal
25
25
  def with_floating_timezone
26
26
  dup.set_tzid(:floating)
27
27
  end
28
+
29
+ unless defined? ActiveSupport
30
+ # Converts a Time object to a Date, dropping hour, minute, and second precision.
31
+ #
32
+ # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
33
+ # my_time.to_date # => Mon, 12 Nov 2007
34
+ #
35
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
36
+ # your_time.to_date # => Tue, 13 Jan 2009
37
+ def to_date
38
+ ::Date.new(year, month, day)
39
+ end
40
+
41
+ # A method to keep Time, Date and DateTime instances interchangeable on conversions.
42
+ # In this case, it simply returns +self+.
43
+ def to_time
44
+ self
45
+ end
46
+
47
+ # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
48
+ #
49
+ # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
50
+ # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
51
+ #
52
+ # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
53
+ # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
54
+ def to_datetime
55
+ ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
56
+ end
57
+ end
28
58
  end
29
59
  end
30
60
  end
@@ -94,7 +94,7 @@ module RiCal
94
94
  # TODO: Need to research this, I beleive that this should also take the end time into account,
95
95
  # but I need to research
96
96
  def exclusion_match?(occurrence, exclusion)
97
- exclusion && occurrence[:start] == occurrence[:start]
97
+ exclusion && occurrence[:start] == exclusion[:start]
98
98
  end
99
99
 
100
100
  # Also exclude occurrences before the :starting date_time
@@ -172,15 +172,11 @@ module RiCal
172
172
  @rdate_property = nil
173
173
  @exdate_property = nil
174
174
  @recurrence_id_property = occurrence_start
175
- @dtstart_property = occurrence_start
176
- if occurrence_end
177
- @dtend_property = occurrence_end
178
- else
179
- if dtend
180
- my_duration = @dtend_property - @dtstart_property
181
- @dtend_property = occurrence_start + my_duration
182
- end
175
+ if @dtend_property && !occurrence_end
176
+ occurrence_end = occurrence_start + (@dtend_property - @dtstart_property)
183
177
  end
178
+ @dtstart_property = dtstart_property.for_occurrence(occurrence_start)
179
+ @dtend_property = dtend_property.for_occurrence(occurrence_end) if @dtend_property
184
180
  self
185
181
  end
186
182
 
@@ -148,5 +148,17 @@ module RiCal
148
148
  :end => date_time.advance(:hours => 24, :seconds => -1)}
149
149
  end
150
150
  end
151
+
152
+ def start_of_day?
153
+ true
154
+ end
155
+
156
+ def for_occurrence(occurrence)
157
+ if occurrence.start_of_day?
158
+ occurrence.to_ri_cal_date_value(timezone_finder)
159
+ else
160
+ occurrence.for_parent(timezone_finder)
161
+ end
162
+ end
151
163
  end
152
164
  end
@@ -253,8 +253,8 @@ module RiCal
253
253
 
254
254
 
255
255
  # Return an RiCal::PropertyValue::DateTime representing the receiver.
256
- def to_ri_cal_date_time_value
257
- self
256
+ def to_ri_cal_date_time_value(timezone=nil)
257
+ for_parent(timezone)
258
258
  end
259
259
 
260
260
  def iso_year_and_week_one_start(wkst) #:nodoc:
@@ -269,6 +269,11 @@ module RiCal
269
269
  def to_ri_cal_date_or_date_time_value(timezone_finder = nil) #:nodoc:
270
270
  self.for_parent(timezone_finder)
271
271
  end
272
+
273
+ # Return a Date property for this DateTime
274
+ def to_ri_cal_date_value(timezone_finder=nil)
275
+ PropertyValue::Date.new(timezone_finder, :value => @date_time_value.strftime("%Y%m%d"))
276
+ end
272
277
 
273
278
  # Return the Ruby DateTime representation of the receiver
274
279
  def to_datetime #:nodoc:
@@ -289,6 +294,14 @@ module RiCal
289
294
  def add_date_times_to(required_timezones) #:nodoc:
290
295
  required_timezones.add_datetime(self, tzid) if has_local_timezone?
291
296
  end
297
+
298
+ def start_of_day?
299
+ [hour, min, sec] == [0,0,0]
300
+ end
301
+
302
+ def for_occurrence(occurrence)
303
+ occurrence.to_ri_cal_date_time_value(timezone_finder)
304
+ end
292
305
  end
293
306
  end
294
307
  end
data/lib/ri_cal.rb CHANGED
@@ -11,7 +11,7 @@ module RiCal
11
11
  autoload :OccurrenceEnumerator, "#{my_dir}/ri_cal/occurrence_enumerator.rb"
12
12
 
13
13
  # :stopdoc:
14
- VERSION = '0.0.8'
14
+ VERSION = '0.0.9'
15
15
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
16
16
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
17
17
 
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.8"
5
+ s.version = "0.0.9"
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-19}
9
+ s.date = %q{2009-05-21}
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.
@@ -22,7 +22,7 @@ A Google group for discussion of this library has been set up http://groups.goog
22
22
  s.email = ["rick.denatale@gmail.com"]
23
23
  s.executables = ["ri_cal"]
24
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"]
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/gem_loader/load_active_support.rb", "tasks/gem_loader/load_tzinfo_gem.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/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/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"]
26
26
  s.has_rdoc = true
27
27
  s.homepage = %q{http://rical.rubyforge.org/}
28
28
  s.rdoc_options = ["--main", "README.txt"]
@@ -309,6 +309,14 @@ describe RiCal::Component::Event do
309
309
  @it.dtstart = Date.parse("April 22, 2009")
310
310
  unfold(@it.export).should match(/^DTSTART;VALUE=DATE:20090422$/)
311
311
  end
312
+
313
+ it "should properly fold on export" do
314
+ @it.description = "Weather report looks nice, 80 degrees and partly cloudy, so following Michael's suggestion, let's meet at the food court at Crossroads:\n\nhttp://www.shopcrossroadsplaza.c...\n"
315
+ export_string = @it.export
316
+ export_string.should match(%r(^DESCRIPTION:Weather report looks nice\\, 80 degrees and partly cloudy\\, so$))
317
+ export_string.should match(%r(^ following Michael's suggestion\\, let's meet at the food court at Crossr$))
318
+ export_string.should match(%r(^ oads:\\n\\nhttp://www.shopcrossroadsplaza\.c\.\.\.\\n$))
319
+ end
312
320
  end
313
321
 
314
322
  if RiCal::TimeWithZone
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  # Note that this is more of a functional spec
10
10
  describe RiCal::OccurrenceEnumerator do
11
-
11
+
12
12
  Fr13Unbounded_Zulu = <<-TEXT
13
13
  BEGIN:VEVENT
14
14
  DTSTART:19970902T090000Z
@@ -45,24 +45,24 @@ TEXT
45
45
  before(:each) do
46
46
  @it = RiCal.parse_string(Fr13Unbounded_Zulu).first
47
47
  end
48
-
48
+
49
49
  it "should raise an ArgumentError with no options to limit result" do
50
50
  lambda {@it.occurrences}.should raise_error(ArgumentError)
51
51
  end
52
-
52
+
53
53
  it "should have the right five occurrences when :count => 5 option is used" do
54
54
  result = @it.occurrences(:count => 5)
55
55
  result.should == Fr13UnboundedZuluExpectedFive
56
56
  end
57
-
57
+
58
58
  end
59
59
  end
60
-
60
+
61
61
  describe ".occurrences" do
62
62
  before(:each) do
63
63
  @it = RiCal.parse_string(Fr13Unbounded_Zulu).first
64
64
  end
65
-
65
+
66
66
  describe "with :starting specified" do
67
67
  it "should exclude dates before :starting" do
68
68
  result = @it.occurrences(:starting => Fr13UnboundedZuluExpectedFive[1].dtstart,
@@ -70,7 +70,7 @@ TEXT
70
70
  result.map{|o|o.dtstart}.should == Fr13UnboundedZuluExpectedFive[1..-2].map{|e| e.dtstart}
71
71
  end
72
72
  end
73
-
73
+
74
74
  describe "with :before specified" do
75
75
  it "should exclude dates after :before" do
76
76
  result = @it.occurrences(:before => Fr13UnboundedZuluExpectedFive[3].dtstart,
@@ -79,7 +79,7 @@ TEXT
79
79
  end
80
80
  end
81
81
  end
82
-
82
+
83
83
 
84
84
  describe ".each" do
85
85
  describe " for Every Friday the 13th, forever" do
@@ -105,7 +105,7 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
105
105
  before(:each) do
106
106
  @merger = RiCal::OccurrenceEnumerator::OccurrenceMerger
107
107
  end
108
-
108
+
109
109
  describe ".for" do
110
110
  it "should return an EmptyEnumerator if the rules parameter is nil" do
111
111
  @merger.for(nil, nil).should == RiCal::OccurrenceEnumerator::EmptyRulesEnumerator
@@ -114,23 +114,23 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
114
114
  it "should return an EmptyEnumerator if the rules parameter is empty" do
115
115
  @merger.for(nil, []).should == RiCal::OccurrenceEnumerator::EmptyRulesEnumerator
116
116
  end
117
-
117
+
118
118
  describe "with a single rrule" do
119
119
  before(:each) do
120
120
  @component = mock("component", :dtstart => :dtstart_value)
121
121
  @rrule = mock("rrule", :enumerator => :rrule_enumerator)
122
122
  end
123
-
123
+
124
124
  it "should return the enumerator the rrule" do
125
125
  @merger.for(@component, [@rrule]).should == :rrule_enumerator
126
126
  end
127
-
127
+
128
128
  it "should pass the component to the enumerator instantiation" do
129
129
  @rrule.should_receive(:enumerator).with(@component)
130
130
  @merger.for(@component, [@rrule])
131
131
  end
132
132
  end
133
-
133
+
134
134
  describe "with multiple rrules" do
135
135
  before(:each) do
136
136
  @component = mock("component", :dtstart => :dtstart_value)
@@ -139,25 +139,25 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
139
139
  @rrule1 = mock("rrule", :enumerator => @enum1)
140
140
  @rrule2 = mock("rrule", :enumerator => @enum2)
141
141
  end
142
-
142
+
143
143
  it "should return an instance of RiCal::OccurrenceEnumerator::OccurrenceMerger" do
144
144
  @merger.for(@component, [@rrule1, @rrule2]).should be_kind_of(RiCal::OccurrenceEnumerator::OccurrenceMerger)
145
145
  end
146
-
146
+
147
147
  it "should pass the component to the enumerator instantiation" do
148
148
  @rrule1.should_receive(:enumerator).with(@component).and_return(@enum1)
149
149
  @rrule2.should_receive(:enumerator).with(@component).and_return(@enum2)
150
150
  @merger.for(@component, [@rrule1, @rrule2])
151
151
  end
152
-
152
+
153
153
  it "should preload the next occurrences" do
154
154
  @enum1.should_receive(:next_occurrence).and_return(:occ1)
155
155
  @enum2.should_receive(:next_occurrence).and_return(:occ2)
156
- @merger.for(@component, [@rrule1, @rrule2])
156
+ @merger.for(@component, [@rrule1, @rrule2])
157
157
  end
158
158
  end
159
159
  end
160
-
160
+
161
161
  describe "#next_occurence" do
162
162
 
163
163
  describe "with unique nexts" do
@@ -168,28 +168,28 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
168
168
  @rrule2 = mock("rrule", :enumerator => @enum2)
169
169
  @it = @merger.new(0, [@rrule1, @rrule2])
170
170
  end
171
-
171
+
172
172
  it "should return the earliest occurrence" do
173
173
  @it.next_occurrence.should == 2
174
174
  end
175
-
175
+
176
176
  it "should advance the enumerator which returned the result" do
177
177
  @enum2.should_receive(:next_occurrence).and_return(4)
178
178
  @it.next_occurrence
179
179
  end
180
-
180
+
181
181
  it "should not advance the other enumerator" do
182
182
  @enum1.should_not_receive(:next_occurrence)
183
183
  @it.next_occurrence
184
184
  end
185
-
185
+
186
186
  it "should properly update the next array" do
187
187
  @enum2.stub!(:next_occurrence).and_return(4)
188
188
  @it.next_occurrence
189
189
  @it.nexts.should == [3, 4]
190
190
  end
191
191
  end
192
-
192
+
193
193
  describe "with duplicated nexts" do
194
194
  before(:each) do
195
195
  @enum1 = mock_enumerator("rrule_enumerator1", 2)
@@ -198,26 +198,26 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
198
198
  @rrule2 = mock("rrule", :enumerator => @enum2)
199
199
  @it = @merger.new(0, [@rrule1, @rrule2])
200
200
  end
201
-
201
+
202
202
  it "should return the earliest occurrence" do
203
203
  @it.next_occurrence.should == 2
204
204
  end
205
-
205
+
206
206
  it "should advance both enumerators" do
207
207
  @enum1.should_receive(:next_occurrence).and_return(5)
208
208
  @enum2.should_receive(:next_occurrence).and_return(4)
209
209
  @it.next_occurrence
210
210
  end
211
-
211
+
212
212
  it "should properly update the next array" do
213
213
  @enum1.stub!(:next_occurrence).and_return(5)
214
214
  @enum2.stub!(:next_occurrence).and_return(4)
215
215
  @it.next_occurrence
216
216
  @it.nexts.should == [5, 4]
217
217
  end
218
-
218
+
219
219
  end
220
-
220
+
221
221
  describe "with all enumerators at end" do
222
222
  before(:each) do
223
223
  @enum1 = mock_enumerator("rrule_enumerator1", nil)
@@ -226,11 +226,11 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
226
226
  @rrule2 = mock("rrule", :enumerator => @enum2)
227
227
  @it = @merger.new(0, [@rrule1, @rrule2])
228
228
  end
229
-
229
+
230
230
  it "should return nil" do
231
231
  @it.next_occurrence.should == nil
232
232
  end
233
-
233
+
234
234
  it "should not advance the enumerators which returned the result" do
235
235
  @enum1.should_not_receive(:next_occurrence)
236
236
  @enum2.should_not_receive(:next_occurrence)
@@ -238,10 +238,42 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
238
238
  end
239
239
  end
240
240
  end
241
+
242
+ context "Ticket #4 from paulsm" do
243
+ it "should produce 4 occurrences" do
244
+ cal = RiCal.parse_string <<ENDCAL
245
+ BEGIN:VCALENDAR
246
+ METHOD:PUBLISH
247
+ PRODID:-//Apple Inc.//iCal 3.0//EN
248
+ CALSCALE:GREGORIAN
249
+ X-WR-CALNAME:Australian32Holidays
250
+ X-WR-CALDESC:Australian Public Holidays. Compiled from http://www.indust
251
+ rialrelations.nsw.gov.au/holidays/default.html and the links for the oth
252
+ er states at the bottom of that page
253
+ X-WR-RELCALID:AC1E4CE8-6690-49F6-A144-2F8891DFFD8D
254
+ VERSION:2.0
255
+ X-WR-TIMEZONE:Australia/Sydney
256
+ BEGIN:VEVENT
257
+ SEQUENCE:8
258
+ TRANSP:OPAQUE
259
+ UID:5B5579F3-2137-11D7-B491-00039301B0C2
260
+ DTSTART;VALUE=DATE:20020520
261
+ DTSTAMP:20060602T045619Z
262
+ SUMMARY:Adelaide Cup Carnival and Volunteers Day (SA)
263
+ EXDATE;VALUE=DATE:20060515
264
+ CREATED:20080916T000924Z
265
+ DTEND;VALUE=DATE:20020521
266
+ RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20070520;BYMONTH=5;BYDAY=3MO
267
+ END:VEVENT
268
+ END:VCALENDAR
269
+ ENDCAL
270
+ cal.first.events.first.occurrences.length.should == 4
271
+ end
272
+ end
241
273
 
242
- context "Bug report from paulsm" do
243
- before(:each) do
244
- cals = RiCal.parse_string <<ENDCAL
274
+ context "Ticket #2 from paulsm" do
275
+ before(:each) do
276
+ cals = RiCal.parse_string <<ENDCAL
245
277
  BEGIN:VCALENDAR
246
278
  X-WR-TIMEZONE:America/New_York
247
279
  PRODID:-//Apple Inc.//iCal 3.0//EN
@@ -327,10 +359,67 @@ END:VCALENDAR
327
359
  ENDCAL
328
360
  @event = cals.first.events.first
329
361
  end
330
-
362
+
331
363
  it "should be able to enumerate occurrences" do
332
364
  @event.occurrences.should == [@event]
333
365
  end
334
366
  end
367
+
368
+ context "An event with a DATE dtstart, Ticket #6" do
369
+ before(:each) do
370
+ cal = RiCal.parse_string <<ENDCAL
371
+ BEGIN:VCALENDAR
372
+ PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
373
+ VERSION:2.0
374
+ BEGIN:VEVENT
375
+ CREATED:20090520T092032Z
376
+ LAST-MODIFIED:20090520T092052Z
377
+ DTSTAMP:20090520T092032Z
378
+ UID:d41c124a-65c3-400e-bd04-1d2ee7b98352
379
+ SUMMARY:event2
380
+ RRULE:FREQ=MONTHLY;INTERVAL=1
381
+ DTSTART;VALUE=DATE:20090603
382
+ DTEND;VALUE=DATE:20090604
383
+ TRANSP:TRANSPARENT
384
+ END:VEVENT
385
+ END:VCALENDAR
386
+ ENDCAL
387
+ @occurrences = cal.first.events.first.occurrences(
388
+ :after => Date.parse('01/01/1990'),
389
+ :before => Date.parse("01/01/2010")
390
+ )
391
+ end
335
392
 
336
- end
393
+ it "should produce the right dtstart values" do
394
+ @occurrences.map {|o| o.dtstart}.should == [
395
+ Date.parse("2009-06-03"),
396
+ Date.parse("2009-07-03"),
397
+ Date.parse("2009-08-03"),
398
+ Date.parse("2009-09-03"),
399
+ Date.parse("2009-10-03"),
400
+ Date.parse("2009-11-03"),
401
+ Date.parse("2009-12-03")
402
+ ]
403
+ end
404
+
405
+ it "should produce events whose dtstarts are all dates" do
406
+ @occurrences.all? {|o| o.dtstart.class == ::Date}.should be_true
407
+ end
408
+
409
+ it "should produce the right dtend values" do
410
+ @occurrences.map {|o| o.dtend}.should == [
411
+ Date.parse("2009-06-04"),
412
+ Date.parse("2009-07-04"),
413
+ Date.parse("2009-08-04"),
414
+ Date.parse("2009-09-04"),
415
+ Date.parse("2009-10-04"),
416
+ Date.parse("2009-11-04"),
417
+ Date.parse("2009-12-04")
418
+ ]
419
+ end
420
+
421
+ it "should produce events whose dtstends are all dates" do
422
+ @occurrences.all? {|o| o.dtend.class == ::Date}.should be_true
423
+ end
424
+ end
425
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyredrick-ri_cal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - author=Rick DeNatale
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-19 00:00:00 -07:00
12
+ date: 2009-05-21 00:00:00 -07:00
13
13
  default_executable: ri_cal
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -86,6 +86,7 @@ files:
86
86
  - lib/ri_cal/core_extensions/date.rb
87
87
  - lib/ri_cal/core_extensions/date/conversions.rb
88
88
  - lib/ri_cal/core_extensions/date_time.rb
89
+ - lib/ri_cal/core_extensions/date_time/conversions.rb
89
90
  - lib/ri_cal/core_extensions/object.rb
90
91
  - lib/ri_cal/core_extensions/object/conversions.rb
91
92
  - lib/ri_cal/core_extensions/string.rb