awallis-ri_cal 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +402 -0
- data/Manifest.txt +161 -0
- data/README.txt +410 -0
- data/Rakefile +69 -0
- data/VERSION +1 -0
- data/bin/ri_cal +8 -0
- data/component_attributes/alarm.yml +10 -0
- data/component_attributes/calendar.yml +4 -0
- data/component_attributes/component_property_defs.yml +180 -0
- data/component_attributes/event.yml +45 -0
- data/component_attributes/freebusy.yml +16 -0
- data/component_attributes/journal.yml +35 -0
- data/component_attributes/timezone.yml +3 -0
- data/component_attributes/timezone_period.yml +11 -0
- data/component_attributes/todo.yml +46 -0
- data/copyrights.txt +1 -0
- data/docs/draft-ietf-calsify-2446bis-08.txt +7280 -0
- data/docs/draft-ietf-calsify-rfc2445bis-09.txt +10416 -0
- data/docs/incrementers.txt +7 -0
- data/docs/rfc2445.pdf +0 -0
- data/lib/ri_cal.rb +187 -0
- data/lib/ri_cal/component.rb +256 -0
- data/lib/ri_cal/component/alarm.rb +19 -0
- data/lib/ri_cal/component/calendar.rb +257 -0
- data/lib/ri_cal/component/event.rb +58 -0
- data/lib/ri_cal/component/freebusy.rb +16 -0
- data/lib/ri_cal/component/journal.rb +27 -0
- data/lib/ri_cal/component/non_standard.rb +33 -0
- data/lib/ri_cal/component/t_z_info_timezone.rb +153 -0
- data/lib/ri_cal/component/timezone.rb +197 -0
- data/lib/ri_cal/component/timezone/daylight_period.rb +25 -0
- data/lib/ri_cal/component/timezone/standard_period.rb +23 -0
- data/lib/ri_cal/component/timezone/timezone_period.rb +76 -0
- data/lib/ri_cal/component/todo.rb +42 -0
- data/lib/ri_cal/core_extensions.rb +11 -0
- data/lib/ri_cal/core_extensions/array.rb +7 -0
- data/lib/ri_cal/core_extensions/array/conversions.rb +15 -0
- data/lib/ri_cal/core_extensions/date.rb +13 -0
- data/lib/ri_cal/core_extensions/date/conversions.rb +56 -0
- data/lib/ri_cal/core_extensions/date_time.rb +15 -0
- data/lib/ri_cal/core_extensions/date_time/conversions.rb +50 -0
- data/lib/ri_cal/core_extensions/object.rb +8 -0
- data/lib/ri_cal/core_extensions/object/conversions.rb +20 -0
- data/lib/ri_cal/core_extensions/string.rb +8 -0
- data/lib/ri_cal/core_extensions/string/conversions.rb +57 -0
- data/lib/ri_cal/core_extensions/time.rb +14 -0
- data/lib/ri_cal/core_extensions/time/calculations.rb +153 -0
- data/lib/ri_cal/core_extensions/time/conversions.rb +42 -0
- data/lib/ri_cal/core_extensions/time/tzid_access.rb +50 -0
- data/lib/ri_cal/core_extensions/time/week_day_predicates.rb +55 -0
- data/lib/ri_cal/fast_date_time.rb +234 -0
- data/lib/ri_cal/floating_timezone.rb +32 -0
- data/lib/ri_cal/invalid_property_value.rb +8 -0
- data/lib/ri_cal/invalid_timezone_identifier.rb +20 -0
- data/lib/ri_cal/occurrence_enumerator.rb +265 -0
- data/lib/ri_cal/occurrence_period.rb +17 -0
- data/lib/ri_cal/parser.rb +145 -0
- data/lib/ri_cal/properties.rb +12 -0
- data/lib/ri_cal/properties/alarm.rb +390 -0
- data/lib/ri_cal/properties/calendar.rb +164 -0
- data/lib/ri_cal/properties/event.rb +1523 -0
- data/lib/ri_cal/properties/freebusy.rb +593 -0
- data/lib/ri_cal/properties/journal.rb +1237 -0
- data/lib/ri_cal/properties/timezone.rb +150 -0
- data/lib/ri_cal/properties/timezone_period.rb +416 -0
- data/lib/ri_cal/properties/todo.rb +1559 -0
- data/lib/ri_cal/property_value.rb +159 -0
- data/lib/ri_cal/property_value/array.rb +27 -0
- data/lib/ri_cal/property_value/cal_address.rb +11 -0
- data/lib/ri_cal/property_value/date.rb +184 -0
- data/lib/ri_cal/property_value/date_time.rb +359 -0
- data/lib/ri_cal/property_value/date_time/additive_methods.rb +44 -0
- data/lib/ri_cal/property_value/date_time/time_machine.rb +159 -0
- data/lib/ri_cal/property_value/date_time/timezone_support.rb +100 -0
- data/lib/ri_cal/property_value/duration.rb +110 -0
- data/lib/ri_cal/property_value/geo.rb +11 -0
- data/lib/ri_cal/property_value/integer.rb +12 -0
- data/lib/ri_cal/property_value/occurrence_list.rb +144 -0
- data/lib/ri_cal/property_value/period.rb +86 -0
- data/lib/ri_cal/property_value/recurrence_rule.rb +154 -0
- data/lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb +100 -0
- data/lib/ri_cal/property_value/recurrence_rule/enumerator.rb +79 -0
- data/lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb +148 -0
- data/lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb +53 -0
- data/lib/ri_cal/property_value/recurrence_rule/numbered_span.rb +31 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer.rb +135 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb +86 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_hour_incrementer.rb +31 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb +32 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_month_incrementer.rb +52 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_monthday_incrementer.rb +31 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_numbered_day_incrementer.rb +38 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_second_incrementer.rb +32 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb +69 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_yearday_incrementer.rb +31 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/daily_incrementer.rb +28 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb +80 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/hourly_incrementer.rb +23 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/list_incrementer.rb +106 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/minutely_incrementer.rb +23 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/monthly_incrementer.rb +33 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/null_sub_cycle_incrementer.rb +43 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/secondly_incrementer.rb +28 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/weekly_incrementer.rb +37 -0
- data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb +57 -0
- data/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +131 -0
- data/lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb +64 -0
- data/lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb +33 -0
- data/lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb +53 -0
- data/lib/ri_cal/property_value/recurrence_rule/time_manipulation.rb +42 -0
- data/lib/ri_cal/property_value/recurrence_rule/validations.rb +125 -0
- data/lib/ri_cal/property_value/text.rb +44 -0
- data/lib/ri_cal/property_value/uri.rb +11 -0
- data/lib/ri_cal/property_value/utc_offset.rb +33 -0
- data/lib/ri_cal/property_value/zulu_date_time.rb +34 -0
- data/lib/ri_cal/required_timezones.rb +55 -0
- data/parked_specs/ri_cal/claudio_a_bug_spec.rb +100 -0
- data/performance/empty_propval/subject.rb +43 -0
- data/performance/paris_eastern/subject.rb +90 -0
- data/performance/penultimate_weekday/subject.rb +15 -0
- data/performance/psm_big_enum/ical.ics +3171 -0
- data/performance/psm_big_enum/subject.rb +16 -0
- data/performance/utah_cycling/subject.rb +55 -0
- data/ri_cal.gemspec +244 -0
- data/script/benchmark_subject +23 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/profile_subject +29 -0
- data/script/txt2html +71 -0
- data/spec/ri_cal/bugreports_spec.rb +276 -0
- data/spec/ri_cal/component/alarm_spec.rb +12 -0
- data/spec/ri_cal/component/calendar_spec.rb +88 -0
- data/spec/ri_cal/component/event_spec.rb +735 -0
- data/spec/ri_cal/component/freebusy_spec.rb +12 -0
- data/spec/ri_cal/component/journal_spec.rb +37 -0
- data/spec/ri_cal/component/t_z_info_timezone_spec.rb +60 -0
- data/spec/ri_cal/component/timezone_spec.rb +236 -0
- data/spec/ri_cal/component/todo_spec.rb +112 -0
- data/spec/ri_cal/component_spec.rb +224 -0
- data/spec/ri_cal/core_extensions/string/conversions_spec.rb +78 -0
- data/spec/ri_cal/core_extensions/time/calculations_spec.rb +188 -0
- data/spec/ri_cal/core_extensions/time/week_day_predicates_spec.rb +45 -0
- data/spec/ri_cal/fast_date_time_spec.rb +77 -0
- data/spec/ri_cal/inf_loop_spec.rb +78 -0
- data/spec/ri_cal/occurrence_enumerator_spec.rb +611 -0
- data/spec/ri_cal/parser_spec.rb +337 -0
- data/spec/ri_cal/property_value/date_spec.rb +53 -0
- data/spec/ri_cal/property_value/date_time_spec.rb +383 -0
- data/spec/ri_cal/property_value/duration_spec.rb +126 -0
- data/spec/ri_cal/property_value/occurrence_list_spec.rb +72 -0
- data/spec/ri_cal/property_value/period_spec.rb +63 -0
- data/spec/ri_cal/property_value/recurrence_rule/recurring_year_day_spec.rb +21 -0
- data/spec/ri_cal/property_value/recurrence_rule_spec.rb +1814 -0
- data/spec/ri_cal/property_value/text_spec.rb +25 -0
- data/spec/ri_cal/property_value/utc_offset_spec.rb +48 -0
- data/spec/ri_cal/property_value_spec.rb +125 -0
- data/spec/ri_cal/required_timezones_spec.rb +67 -0
- data/spec/ri_cal_spec.rb +53 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +50 -0
- data/tasks/gem_loader/load_active_support.rb +3 -0
- data/tasks/gem_loader/load_tzinfo_gem.rb +2 -0
- data/tasks/ri_cal.rake +412 -0
- data/tasks/spec.rake +102 -0
- metadata +255 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class NegativeSetposEnumerator < Enumerator # :nodoc:
|
7
|
+
|
8
|
+
def initialize(recurrence_rule, component, setpos_list)
|
9
|
+
super
|
10
|
+
@current_set = []
|
11
|
+
@valids = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def next_occurrence
|
15
|
+
while true
|
16
|
+
result = advance
|
17
|
+
if result >= start_time
|
18
|
+
@count += 1
|
19
|
+
return recurrence_rule.exhausted?(@count, result) ? nil : result_occurrence_period(result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
def advance
|
27
|
+
if @valids.empty?
|
28
|
+
fill_set
|
29
|
+
@valids = @setpos_list.map {|sp| sp < 0 ? @current_set.length + sp : sp - 1}
|
30
|
+
current_time_index = @current_set.index(@start_time)
|
31
|
+
if current_time_index
|
32
|
+
@valids << current_time_index
|
33
|
+
end
|
34
|
+
@valids = @valids.uniq.sort
|
35
|
+
end
|
36
|
+
@current_set[@valids.shift]
|
37
|
+
end
|
38
|
+
|
39
|
+
def fill_set
|
40
|
+
@current_set = [next_time]
|
41
|
+
while true
|
42
|
+
self.next_time = @incrementer.next_time(next_time)
|
43
|
+
if recurrence_rule.in_same_set?(@current_set.last, next_time)
|
44
|
+
@current_set << next_time
|
45
|
+
else
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class NumberedSpan # :nodoc:
|
7
|
+
attr_reader :source
|
8
|
+
def initialize(source, rule = nil)
|
9
|
+
@source = source
|
10
|
+
@rule = rule
|
11
|
+
end
|
12
|
+
|
13
|
+
def valid?
|
14
|
+
(1..last).include?(source) || (-last..-1).include?(source)
|
15
|
+
end
|
16
|
+
|
17
|
+
def ==(another)
|
18
|
+
self.class == another.class && source == another.source
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
source.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def ordinal
|
26
|
+
@source
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
|
8
|
+
attr_accessor :sub_cycle_incrementer, :current_occurrence, :outer_range
|
9
|
+
attr_accessor :outer_incrementers
|
10
|
+
attr_accessor :contains_daily_incrementer, :contains_weeknum_incrementer
|
11
|
+
attr_reader :leaf_iterator
|
12
|
+
parent_path = "ri_cal/property_value/recurrence_rule/occurrence_incrementer"
|
13
|
+
|
14
|
+
autoload :ByDayIncrementer, "#{parent_path}/by_day_incrementer.rb"
|
15
|
+
autoload :ByHourIncrementer, "#{parent_path}/by_hour_incrementer.rb"
|
16
|
+
autoload :ByMinuteIncrementer, "#{parent_path}/by_minute_incrementer.rb"
|
17
|
+
autoload :ByMonthIncrementer, "#{parent_path}/by_month_incrementer.rb"
|
18
|
+
autoload :ByMonthdayIncrementer, "#{parent_path}/by_monthday_incrementer.rb"
|
19
|
+
autoload :ByNumberedDayIncrementer, "#{parent_path}/by_numbered_day_incrementer.rb"
|
20
|
+
autoload :BySecondIncrementer, "#{parent_path}/by_second_incrementer.rb"
|
21
|
+
autoload :ByYeardayIncrementer, "#{parent_path}/by_yearday_incrementer.rb"
|
22
|
+
autoload :ByWeekNoIncrementer, "#{parent_path}/by_weekno_incrementer.rb"
|
23
|
+
autoload :DailyIncrementer, "#{parent_path}/daily_incrementer.rb"
|
24
|
+
autoload :FrequencyIncrementer, "#{parent_path}/frequency_incrementer.rb"
|
25
|
+
autoload :HourlyIncrementer, "#{parent_path}/hourly_incrementer.rb"
|
26
|
+
autoload :ListIncrementer, "#{parent_path}/list_incrementer.rb"
|
27
|
+
autoload :MinutelyIncrementer, "#{parent_path}/minutely_incrementer.rb"
|
28
|
+
autoload :MonthlyIncrementer, "#{parent_path}/monthly_incrementer.rb"
|
29
|
+
autoload :NullSubCycleIncrementer, "#{parent_path}/null_sub_cycle_incrementer.rb"
|
30
|
+
autoload :SecondlyIncrementer, "#{parent_path}/secondly_incrementer.rb"
|
31
|
+
autoload :WeeklyIncrementer, "#{parent_path}/weekly_incrementer.rb"
|
32
|
+
autoload :YearlyIncrementer, "#{parent_path}/yearly_incrementer.rb"
|
33
|
+
|
34
|
+
include RecurrenceRule::TimeManipulation
|
35
|
+
|
36
|
+
def initialize(rrule, sub_cycle_incrementer)
|
37
|
+
self.sub_cycle_incrementer = sub_cycle_incrementer
|
38
|
+
@outermost = true
|
39
|
+
self.outer_incrementers = []
|
40
|
+
if sub_cycle_incrementer
|
41
|
+
self.contains_daily_incrementer = sub_cycle_incrementer.daily_incrementer? ||
|
42
|
+
sub_cycle_incrementer.contains_daily_incrementer?
|
43
|
+
self.contains_weeknum_incrementer = sub_cycle_incrementer.weeknum_incrementer?||
|
44
|
+
sub_cycle_incrementer.contains_weeknum_incrementer?
|
45
|
+
sub_cycle_incrementer.add_outer_incrementer(self)
|
46
|
+
else
|
47
|
+
self.sub_cycle_incrementer = NullSubCycleIncrementer
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_rrule(recurrence_rule, start_time)
|
52
|
+
YearlyIncrementer.from_rrule(recurrence_rule, start_time)
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_outer_incrementer(incrementer)
|
56
|
+
@outermost = false
|
57
|
+
self.outer_incrementers << incrementer
|
58
|
+
sub_cycle_incrementer.add_outer_incrementer(incrementer)
|
59
|
+
end
|
60
|
+
|
61
|
+
def outermost?
|
62
|
+
@outermost
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_s
|
66
|
+
if sub_cycle_incrementer
|
67
|
+
"#{self.short_name}->#{sub_cycle_incrementer}"
|
68
|
+
else
|
69
|
+
self.short_name
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def short_name
|
74
|
+
@short_name ||= self.class.name.split("::").last
|
75
|
+
end
|
76
|
+
|
77
|
+
# Return the next time after previous_occurrence generated by this incrementer
|
78
|
+
# But the occurrence is outside the current cycle of any outer incrementer(s) return
|
79
|
+
# nil which will cause the outer incrementer to step to its next cycle
|
80
|
+
def next_time(previous_occurrence)
|
81
|
+
@previous_occurrence = previous_occurrence
|
82
|
+
if current_occurrence
|
83
|
+
sub_occurrence = @sub_cycle_incrementer.next_time(previous_occurrence)
|
84
|
+
else #first time
|
85
|
+
sub_occurrence = @sub_cycle_incrementer.first_sub_occurrence(previous_occurrence, update_cycle_range(previous_occurrence))
|
86
|
+
end
|
87
|
+
if sub_occurrence
|
88
|
+
candidate = sub_occurrence
|
89
|
+
else
|
90
|
+
candidate = next_cycle(previous_occurrence)
|
91
|
+
end
|
92
|
+
if in_outer_cycle?(candidate)
|
93
|
+
candidate
|
94
|
+
else
|
95
|
+
nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def update_cycle_range(date_time)
|
100
|
+
self.current_occurrence = date_time
|
101
|
+
(date_time..end_of_occurrence(date_time))
|
102
|
+
end
|
103
|
+
|
104
|
+
def in_outer_cycle?(candidate)
|
105
|
+
candidate && (outer_range.nil? || (outer_range.first <= candidate && outer_range.last >= candidate))
|
106
|
+
end
|
107
|
+
|
108
|
+
def first_sub_occurrence(previous_occurrence, outer_cycle_range)
|
109
|
+
first_within_outer_cycle(previous_occurrence, outer_cycle_range)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Advance to the next cycle, if the result is within the current cycles of all outer incrementers
|
113
|
+
def next_cycle(previous_occurrence)
|
114
|
+
raise "next_cycle is a subclass responsibility"
|
115
|
+
end
|
116
|
+
|
117
|
+
def contains_daily_incrementer?
|
118
|
+
@contains_daily_incrementer
|
119
|
+
end
|
120
|
+
|
121
|
+
def daily_incrementer?
|
122
|
+
false
|
123
|
+
end
|
124
|
+
|
125
|
+
def contains_weeknum_incrementer?
|
126
|
+
@contains_weeknum_incrementer
|
127
|
+
end
|
128
|
+
|
129
|
+
def weeknum_incrementer?
|
130
|
+
false
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
class ByDayIncrementer < ListIncrementer #:nodoc:
|
8
|
+
|
9
|
+
def initialize(rrule, list, by_monthday_list, by_yearday_list, parent)
|
10
|
+
super(rrule, list, parent)
|
11
|
+
@monthday_filters = by_monthday_list
|
12
|
+
@yearday_filters = by_yearday_list
|
13
|
+
@by_day_scope = rrule.by_day_scope
|
14
|
+
|
15
|
+
case rrule.by_day_scope
|
16
|
+
when :yearly
|
17
|
+
@cycle_advance_proc = lambda {|date_time| first_day_of_year(advance_year(date_time))}
|
18
|
+
@current_proc = lambda {|date_time| same_year?(current, date_time)}
|
19
|
+
@first_day_proc = lambda {|date_time| first_day_of_year(date_time)}
|
20
|
+
when :monthly
|
21
|
+
@cycle_advance_proc = lambda {|date_time| first_day_of_month(advance_month(date_time))}
|
22
|
+
@current_proc = lambda {|date_time| same_month?(current, date_time)}
|
23
|
+
@first_day_proc = lambda {|date_time| first_day_of_month(date_time)}
|
24
|
+
when :weekly
|
25
|
+
@cycle_advance_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, advance_week(date_time))}
|
26
|
+
@current_proc = lambda {|date_time| same_week?(rrule.wkst_day, current, date_time)}
|
27
|
+
@first_day_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, date_time)}
|
28
|
+
else
|
29
|
+
raise "Invalid recurrence rule, byday needs to be scoped by month, week or year"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.for_rrule(rrule)
|
34
|
+
list = rrule.by_rule_list(:byday)
|
35
|
+
if list
|
36
|
+
sub_cycle_incrementer = OccurrenceIncrementer::DailyIncrementer.for_rrule(rrule)
|
37
|
+
new(rrule, list, rrule.by_rule_list(:bymonthday), rrule.by_rule_list(:byyearday), sub_cycle_incrementer)
|
38
|
+
else
|
39
|
+
OccurrenceIncrementer::ByYeardayIncrementer.for_rrule(rrule)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def unneeded?(candidate)
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
47
|
+
def daily_incrementer?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
def start_of_cycle(date_time)
|
52
|
+
@first_day_proc.call(date_time)
|
53
|
+
end
|
54
|
+
|
55
|
+
def occurrences_for(date_time)
|
56
|
+
first_day = start_of_cycle(date_time)
|
57
|
+
result = list.map {|recurring_day| recurring_day.matches_for(first_day)}.flatten.uniq.sort
|
58
|
+
if @monthday_filters
|
59
|
+
result = result.select {|occurrence| @monthday_filters.any? {|recurring_day| recurring_day.include?(occurrence)}}
|
60
|
+
end
|
61
|
+
if @yearday_filters
|
62
|
+
result = result.select {|occurrence| @yearday_filters.any? {|recurring_day| recurring_day.include?(occurrence)}}
|
63
|
+
end
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def candidate_acceptable?(candidate)
|
68
|
+
list.any? {|recurring_day| recurring_day.include?(candidate)}
|
69
|
+
end
|
70
|
+
|
71
|
+
def varying_time_attribute
|
72
|
+
:day
|
73
|
+
end
|
74
|
+
|
75
|
+
def advance_cycle(date_time)
|
76
|
+
@cycle_advance_proc.call(date_time)
|
77
|
+
end
|
78
|
+
|
79
|
+
def end_of_occurrence(date_time)
|
80
|
+
date_time.end_of_day
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
class ByHourIncrementer < ListIncrementer #:nodoc:
|
8
|
+
def self.for_rrule(rrule)
|
9
|
+
conditional_incrementer(rrule, :byhour, HourlyIncrementer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_of_cycle(date_time)
|
13
|
+
date_time.change(:hour => 0)
|
14
|
+
end
|
15
|
+
|
16
|
+
def varying_time_attribute
|
17
|
+
:hour
|
18
|
+
end
|
19
|
+
|
20
|
+
def advance_cycle(date_time)
|
21
|
+
first_hour_of_day(advance_day(date_time))
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_of_occurrence(date_time)
|
25
|
+
date_time.end_of_hour
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
class ByMinuteIncrementer < ListIncrementer #:nodoc:
|
8
|
+
def self.for_rrule(rrule)
|
9
|
+
conditional_incrementer(rrule, :byminute, MinutelyIncrementer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def advance_cycle(date_time)
|
13
|
+
date_time.advance(:hours => 1).start_of_hour
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_of_cycle(date_time)
|
17
|
+
date_time.change(:min => 0)
|
18
|
+
end
|
19
|
+
|
20
|
+
def end_of_occurrence(date_time)
|
21
|
+
date_time.end_of_minute
|
22
|
+
end
|
23
|
+
|
24
|
+
def varying_time_attribute
|
25
|
+
:min
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
class ByMonthIncrementer < ListIncrementer #:nodoc:
|
8
|
+
|
9
|
+
def self.for_rrule(rrule)
|
10
|
+
conditional_incrementer(rrule, :bymonth, MonthlyIncrementer)
|
11
|
+
end
|
12
|
+
|
13
|
+
def occurrences_for(date_time)
|
14
|
+
if contains_daily_incrementer?
|
15
|
+
list.map {|value| date_time.change(:month => value, :day => 1)}
|
16
|
+
else
|
17
|
+
list.map {|value| date_time.in_month(value)}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def range_advance(date_time)
|
22
|
+
advance_year(date_time)
|
23
|
+
end
|
24
|
+
|
25
|
+
def start_of_cycle(date_time)
|
26
|
+
if contains_daily_incrementer?
|
27
|
+
date_time.change(:month => 1, :day => 1)
|
28
|
+
else
|
29
|
+
date_time.change(:month => 1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def varying_time_attribute
|
34
|
+
:month
|
35
|
+
end
|
36
|
+
|
37
|
+
def advance_cycle(date_time)
|
38
|
+
if contains_daily_incrementer?
|
39
|
+
first_day_of_year(advance_year(date_time))
|
40
|
+
else
|
41
|
+
advance_year(date_time).change(:month => 1)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def end_of_occurrence(date_time)
|
46
|
+
date_time.end_of_month
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_monthday_incrementer.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module RiCal
|
2
|
+
class PropertyValue
|
3
|
+
class RecurrenceRule < PropertyValue
|
4
|
+
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
|
5
|
+
#
|
6
|
+
class OccurrenceIncrementer # :nodoc:
|
7
|
+
class ByMonthdayIncrementer < ByNumberedDayIncrementer #:nodoc:
|
8
|
+
def self.for_rrule(rrule)
|
9
|
+
conditional_incrementer(rrule, :bymonthday, DailyIncrementer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def scope_of(date_time)
|
13
|
+
date_time.month
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_of_cycle(date_time)
|
17
|
+
date_time.change(:day => 1)
|
18
|
+
end
|
19
|
+
|
20
|
+
def advance_cycle(date_time)
|
21
|
+
first_day_of_month(advance_month(date_time))
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_of_occurrence(date_time)
|
25
|
+
date_time.end_of_day
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|