-
Notifications
You must be signed in to change notification settings - Fork 361
Added support for parsing VEVENT from iCal format #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The build is failing because travis is trying to use bundler 2.0 with ruby < 2.3. #459 should fix that |
a5a11d7 to
318153e
Compare
lib/ice_cube/parsers/ical_parser.rb
Outdated
|
|
||
| parser, attr, occurrences = *send(parser, property, value) | ||
|
|
||
| case attr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me but what do you think of passing data into the parse_line and parse_vevent_line methods so that we can remove this generic case statement. I think personally it reads a bit confusing to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me. Should remove an unnecessary additional case statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iainbeeston - are you happy to push an update to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long wait, I've refactored this now to get rid of the extra case statement. Please let me know what you think.
d4423a5 to
c991f99
Compare
BACKGROUND
I have an ical file I'd like to parse with ice cube. It has no recurring events, just a series of one off events. Those events are stored in the file as
VEVENTs, where each event is a block of lines all describing a single event, starting withBEGIN:VEVENTand ending withEND:VEVENT(more detail here).CURRENT BEHAVIOUR
Icecube can't parse these events. It sees the
DTSTARTandDTENDinside theVEVENT, but applies them to the schedule.EXPECTED BEHAVIOUR
I would have expected it to add each
VEVENTas it's own recurrence time in the new schedule.SOLUTION
I've refactored the ical parser such that it acts as a state machine. By default it works as it did before. However, if it sees a
BEGIN:VEVENTline it goes into an event parsing mode, where it parses subsequent lines as events. Once it sees anEND:VEVENTline, it goes back to the regular mode. When parsing events it adds a new recurrence time every time it sees aDTSTART.NOTES
DTSTARTlines within an event, it will add a new recurrence time for each of them. AVEVENTwith more than oneDTSTARTis invalid, so this shouldn't happen in practice.VEVENTs can have an end date (ie.DTEND) as well as a start date (DTSTART). I couldn't see a way of adding a duration to a recurrence time, so I've ignored the end dates for now.