A couple of months ago, that pesky Paul Mison (if I get to be the "wily" Richard Clamp for Pod::Coverage I reserve the right to hand out one pesky to someone) planted an idea in my head, which lead me through something of a world of hurt...
First I'll tell you what the idea is, and you can tell me what the pain was.
It would be cool to turn a page on our intranet into ics so we can
add it to iCal.
Okay, so now take a moment to yourselves to figure out where the pain came from.
10 points if you guessed Net::ICal.
Now I know it's disclaimed as being alpha code, and that I shouldn't be surprised if it's not too good, but the CPAN dist doesn't even pass its own tests, and the CVS version didn't even get that far.
I even sat down for a few afternoons and worked on a fork of Net::ICal CVS which got the tests passing, and it still wasn't fit for duty.
There's a whole other paragraph which goes here and questions the parentage and sanity of Class::MethodMapper, but there's only so many times you can say rude words. Let's just say it's not suitable for something you want to parse, validate, and follow the flow of control without big sheets of paper and crayons. I like crayons, but I like clear flow of control even more.
Thus cheesed off, I put the idea aside for a few weeks, expecting that when I came back to it I'd just cave and write an alternative to the whole ball of wax.
That few weeks ended this week, when Nik pointed out to me that Text::vFile should be a suitable module to base a vCalendar parser on.
an aside - iCalendars, vCalendars, ics, vFile, rfc2445, make your mind up!
So why do I keep calling things
ics one moment, vCalendars the
other, and iCal the next? Well it's partly due to my brain being a
swiss cheesed mess, but also because someone is out to get me.
rfc2445 / iCalendar
Internet Calendaring and Scheduling Core Object Specification
This baby is the specification for iCalendar-formatted files.
Weighing in at 148 pages it covers pretty much anything you need to do for online interactive calendars (maybe).
The common extension for iCalendar files when stored on disk.
It turns out that the object/property/parameter encoding used by
rfc 2445 is the same as the one
used by rfc 2426
Directory Profile, apart from 2445 encoded documents tend to have
deeply nested objects.
We follow Text::vFiles example in calling these documents vFile formatted.
Okay, this one's probably made up.
It comes about because iCalendar is a kind of vFile.
Look just stop looking at me like that.
An application from Apple Computer, Ltd. Parses, generates, and generally speaks rfc 2445.
Sometimes I call it iCal.app, in order to distinguish it from the standard in the same way that use Mail.app to refer to Apple Mail.
And thus overloading occured, in my branes at least.
At about the time we discovered this my impatience kicked in. "Surely it can't be that hard to parse vFile to a simple data structure" I said to myself, and half an hour of coding later it turned out it wasn't. Text::vFile::asData sprang into the world.
A couple more hours tagteaming with Nik to find the corner cases and fix them and we both managed to scratch our itches. Nik's handy what's going on script to summarise upcoming events, and my wiki to ical script for the intranet, both done fairly easily with the assistance of DateTime. Version 0.01 hit the CPAN last night, with 0.02 to follow this weekend.