Skip to content

Instantly share code, notes, and snippets.

@krames
Created April 18, 2012 13:20
Show Gist options
  • Save krames/2413513 to your computer and use it in GitHub Desktop.
Save krames/2413513 to your computer and use it in GitHub Desktop.
Parse RailsConf calendar into iCal format
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'icalendar'
require 'date'
include Icalendar
cal = Calendar.new
cal.custom_property("X-WR-CALNAME;VALUE=TEXT", "RailsConf 2012")
cal.custom_property("X-WR-TIMEZONE;VALUE=TEXT", "America/Chicago")
doc = Nokogiri::HTML(open('http://railsconf2012.com/sessions'))
doc.css('.session,.keynote').each do |session|
event = Event.new
event.summary = session.css('h4').text
stuff = session.css('h5')
stuff1 = stuff.first.text
time, event.location = stuff1.split(' in ')
event.start = DateTime.parse(time)
event.end = event.start + 1/24.0
event.organizer = stuff[1] ? stuff[1].text.gsub(/by /, '') : ''
event.description = session.css('p').collect {|p| p.text}.join("\n\n")
cal.add_event(event)
end
puts cal.to_ical
@shaileshkalamkar
Copy link

Excellent!

@gvaughn
Copy link

gvaughn commented Apr 18, 2012

I'm lousy with iCal, but wanted to share the steps I used (after some trial and error):
Create a new calendar in iCal for this (I used an iCloud calendar named RailsConf2012 for easy sync to iPhone)
In prefs turn off any default alert.
Save the results of this as railsconf.ics.
Double-click and then choose RailsConf2012 as the calendar to receive them
Re-enable default alert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment