File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,18 @@ module IceCube
22 class IcalParser
33 def self . schedule_from_ical ( ical_string , options = { } )
44 data = { }
5+
6+ # First join lines that are wrapped
7+ lines = [ ]
58 ical_string . each_line do |line |
9+ if lines [ -1 ] && line =~ /\A [ \t ].+\z /
10+ lines [ -1 ] = lines [ -1 ] . strip + line . sub ( /\A [ \t ]+/ , "" )
11+ else
12+ lines << line
13+ end
14+ end
15+
16+ lines . each do |line |
617 ( property , value ) = line . split ( ":" )
718 ( property , _tzid ) = property . split ( ";" )
819 case property
Original file line number Diff line number Diff line change @@ -448,5 +448,13 @@ def sorted_ical(ical)
448448 it_behaves_like "an invalid ical string"
449449 end
450450 end
451+
452+ describe "ical data with wrapping" do
453+ it "matches simple daily" do
454+ ical_string = "DTSTART:20130314T201500Z\n DTEND:20130314T201545Z\n RRULE:FREQ=WEEKLY;BYDAY=TH;UNT\n IL=20130531T100000Z"
455+ schedule = IceCube ::Schedule . from_ical ( ical_string )
456+ expect ( schedule . to_ical . split ( /\n / ) . select { |x | x =~ /RRULE/ } . first ) . to eq ( "RRULE:FREQ=WEEKLY;UNTIL=20130531T100000Z;BYDAY=TH" )
457+ end
458+ end
451459 end
452460end
You can’t perform that action at this time.
0 commit comments