Skip to content

Instantly share code, notes, and snippets.

@jakehow
Created October 22, 2008 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakehow/18537 to your computer and use it in GitHub Desktop.
Save jakehow/18537 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'atom'
require 'gcalendar'
require 'net/https'
require 'uri'
LAST_CHECKED = Time.now - 36000
HIGHRISE_URL = 'x.highrisehq.com' #set this to your url
class Meeting
attr_accessor :location
attr_accessor :created_by
attr_accessor :assigned_to
attr_accessor :created_at
attr_accessor :scheduled_for
attr_accessor :notes
def self.find_all
http = Net::HTTP.new(HIGHRISE_URL, 443)
http.use_ssl = true #
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Get.new('/recordings.atom')
req.basic_auth '4610c0a35b15d7b608aa5ae44e657717ee30159f', 'X'
response = http.request(req)
feed = Atom::Feed.new(response.body)
meetings = feed.entries.select {|e| e.published >= LAST_CHECKED && e.title =~/^Note/ && e.content.value =~ /^Meeting/}
meetings.map {|m| Meeting.parse(m)}
end
def self.parse(meeting)
m = Meeting.new
lines = meeting.content.value.gsub(' ', '').split('')
m.location = lines[0].gsub('Meeting @ ', '').strip
m.created_by = meeting.authors.first.name
m.assigned_to = lines[1].scan(/<a>]*>(.*?)/).flatten.first
m.created_at = meeting.published
m.scheduled_for = Time.parse(meeting.content.value.gsub('</a>', '').split('')[2])
m.notes = meeting.content.value.gsub(' ', '').split('')[3].gsub('Notes: ', '')
return m
end
end
cal = GCalendar.new('user@gmail.com', 'pass')Meeting.find_all.each do |m|
event = { :title=>"Meeting for #{m.assigned_to}",
:content=>m.notes,
:authorName=>m.created_by,
:where=>m.location,
:startT=>m.scheduled_for,
:endT=>m.scheduled_for + 3600}
cal.add(event)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment