Skip to content

Commit

Permalink
Added calendar beginnings, bugfixes.
Browse files Browse the repository at this point in the history
git-svn-id: http://gdata-ruby.rubyforge.org/svn@17 3d76ca7b-2e8e-4910-8bb0-bc18f4d68cdf
  • Loading branch information
crkruse committed Oct 11, 2007
1 parent e998eaf commit 2550d2a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
34 changes: 34 additions & 0 deletions lib/gdata/calendar.rb
@@ -0,0 +1,34 @@
#!/usr/bin/ruby
#
# = calendar.rb - extension class for the use of Google Calendar
# by way of the ruby GData library.
#
# Author: Christopher Kruse <christopher.kruse@clarke.edu>
#
# Liscensing for the GData API under the Apache Liscense, version 2.0.
#
#
require 'gdata/client'
require 'rubygems'
require 'builder'
require 'rexml/document'

module GData
class Calendar < GData::Client
def initialize
super 'cl', 'gdata-ruby', 'www.google.com'
@gsessionid = ""
end
CAL_PATH = "/calendar/feeds/default/allcalendars/full?gsessionid=#{@gsessionid}"
def retrieve_calendar_list
if authenticated?
cal_feed = get('calendar/feeds/default/allcalendars/full')
@gsessionid = cal_feed[0].get_fields("location")[0].split("gsessionid").last
cal_feed = get(cal_feed[0].get_fields("location"))
return cal_feed
else puts "Not authenticated."
end
end
end
end

12 changes: 7 additions & 5 deletions lib/gdata/client.rb
Expand Up @@ -89,7 +89,7 @@ def authenticate(email, passwd)
'Authorization' => "GoogleLogin auth=#{response_data["Auth"]}",
'Content-Type' => 'application/atom+xml'
}
@authenticaed = true
@authenticated = true
when Net::HTTPForbidden
# Check to see whether or not we've received a Captcha challenge, and
# raise the CAPTCHAException if we have.
Expand Down Expand Up @@ -125,14 +125,16 @@ def post(path, entry)
# It contains the 'X-HTTP-Method-Override' line because there are times
# that firewalls don't play nice with the HTTP PUT request.
def put(path,entry)
@headers['X-HTTP-Method-Override'] = 'PUT'
@url.put(path,entry,@headers)
h = @headers.clone
h['X-HTTP-Method-Override'] = 'PUT'
@url.put(path,entry,h)
end
# Sends an HTTP DELETE request
# 'X-HTTP-Method-Override' exists for the same reason as above.
def delete(path)
@headers['X-HTTP-Method-Override'] = 'DELETE'
@url.delete(path,@headers)
h=@headers.clone
h['X-HTTP-Method-Override'] = 'DELETE'
@url.delete(path,h)
end
end
end

0 comments on commit 2550d2a

Please sign in to comment.