diff --git a/.gitignore b/.gitignore index 19718514..21482310 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ pkg/ profiles/ doc/ \.DS_Store -.ackrc \ No newline at end of file +.ackrc +.idea/ \ No newline at end of file diff --git a/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb b/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb index e11bee24..e16be4a6 100644 --- a/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb +++ b/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb @@ -21,12 +21,12 @@ def initialize(rrule, list, by_monthday_list, by_yearday_list, parent) @cycle_advance_proc = lambda {|date_time| first_day_of_month(advance_month(date_time))} @current_proc = lambda {|date_time| same_month?(current, date_time)} @first_day_proc = lambda {|date_time| first_day_of_month(date_time)} - when :weekly + when :weekly, :daily @cycle_advance_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, advance_week(date_time))} @current_proc = lambda {|date_time| same_week?(rrule.wkst_day, current, date_time)} @first_day_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, date_time)} else - raise "Invalid recurrence rule, byday needs to be scoped by month, week or year" + raise "Invalid recurrence rule, byday needs to be scoped by month, week, day or year" end end diff --git a/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb b/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb index 8583a41c..3e5bceea 100644 --- a/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb +++ b/lib/ri_cal/property_value/recurrence_rule/recurring_day.rb @@ -48,7 +48,7 @@ def list_id(time) time.year when :monthly (time.year * 100) + time.month - when :weekly + when :weekly, :daily time.at_start_of_week_with_wkst(rrule.wkst_day).jd end end @@ -60,7 +60,7 @@ def matches_for(time) yearly_matches_for(time) when :monthly monthly_matches_for(time) - when :weekly + when :weekly, :daily weekly_matches_for(time) else walkback = caller.grep(/recurrence/i) diff --git a/spec/ri_cal/bugreports_spec.rb b/spec/ri_cal/bugreports_spec.rb index 91ba7df1..020343ac 100644 --- a/spec/ri_cal/bugreports_spec.rb +++ b/spec/ri_cal/bugreports_spec.rb @@ -229,7 +229,7 @@ end end -context "ticket #23" do +describe "ticket #23" do describe "RecurrenceRule" do it "should convert the rrule string to a hash" do rrule = RiCal::PropertyValue::RecurrenceRule.convert(nil, 'INTERVAL=2;FREQ=WEEKLY;BYDAY=TH,TU') @@ -238,8 +238,8 @@ end end -context "ticket #26" do - context "Date property" do +describe "ticket #26" do + describe "Date property" do it "should handle for_parent" do lambda { RiCal::PropertyValue::Date.convert(:foo, Date.parse("20090927")).for_parent(:bar)}.should_not raise_error @@ -247,7 +247,7 @@ end end -context "ticket 29:supress-x-rical-tzsource-when-not-relevant" do +describe "ticket 29:supress-x-rical-tzsource-when-not-relevant" do it "should parse its own output" do cal_string = %Q(BEGIN:VCALENDAR PRODID:-//Google Inc//Google Calendar 70.9054//EN @@ -260,7 +260,7 @@ end end -context "X-properties" do +describe "X-properties" do it "should round-trip the X-WR-CALNAME property" do cal_string = %Q(BEGIN:VCALENDAR PRODID:-//Markthisdate.com\,0.7 @@ -269,8 +269,37 @@ METHOD:PUBLISH X-WR-CALNAME: AFC Ajax Eredivisie wedstrijden 2010 - 2011 END:VCALENDAR) - cal = RiCal.parse_string(cal_string).first - cal.x_wr_calname.first.should == " AFC Ajax Eredivisie wedstrijden 2010 - 2011" - end + cal = RiCal.parse_string(cal_string).first + cal.x_wr_calname.first.should == " AFC Ajax Eredivisie wedstrijden 2010 - 2011" + end +end + +describe "RRULE_DAILY_BYDAY" do + it "should parse and generate" do + cal_string = %Q(BEGIN:VCALENDAR +PRODID:-//Google Inc//Google Calendar 70.9054//EN +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:PUBLISH +BEGIN:VEVENT +CREATED;VALUE=DATE-TIME:20110320T181053Z +DTEND;VALUE=DATE:20110412 +STATUS:CONFIRMED +DTSTART;VALUE=DATE:20110411 +TRANSP:TRANSPARENT +DTSTAMP;VALUE=DATE-TIME:20120810T174438Z +SUMMARY:Pragmatic Marketing +RRULE:FREQ=DAILY;UNTIL=20110413;BYDAY=MO,TU,WE,TH,FR +LOCATION: +SEQUENCE:0 +END:VEVENT +END:VCALENDAR) + cal = RiCal.parse_string(cal_string).first + e = cal.events.first + e.recurs?.should be_true + e.bounded?.should be_true + twelfth = Date.parse('2011-04-12') + e.occurrences(:overlapping => [twelfth, twelfth]).size.should eql 2 + end end