Ruby Google Calendar Reader
I saw a few crude creations out there and I couldn't find any that were well-written, so I wrote my own. Completely from scratch. ICal format reading and all. Hey if you're looking for an ICal parser, I have a pretty good one embedded in here. The parser is reliable and only 40 lines long!
What can you do with this module? Here are some examples:include CalendarReader
g = Calendar.new('...your public or private ical feed url for google calendar...')
g.events.length
g.future_events.length
g.events_in_range(5.days.ago, 5.days.from_now).collect {|e| e.summary}
Like that? I did too. It's rather .. handy. I might add that it doesn't gather or calculate recurring events yet. So the events_in_range method will usually just get all events excluding the recurring events, because they would need to be calculated to actually exist in that specific time range.
Get the module at http://gist.github.com/43977 .
- - - - - - -
Added Wednesday, June 20, 2007:
I now plan to make this into a plugin called gcal_attribute. You'll be able to create a pseudo-attribute of your model that gives you your google calendar as a Calendar object. Usage instructions will follow along with the publishing of the plugin.
4 comments:
Looks great! The link to the module is broke though :(
I get a NoMethodError: undefined method `gcalschema' for Time:Class
What is gcalschema and where can I get it?
As of today, 01/06/2009, I also have a dead link to the module. They must be 40 good lines. Any alternatives?
I have it up on Github now: http://gist.github.com/43977
Note, the 40 lines is just for the ICal parsing, the entire library is about 200 lines.
Post a Comment