cs210-gcal4ruby 0.5.8.5 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +89 -1
- data/README.md +62 -79
- data/lib/gcal4ruby/calendar.rb +27 -16
- data/lib/gcal4ruby/event.rb +3 -0
- data/lib/gcal4ruby/service.rb +69 -15
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
<<<<<<< HEAD
|
1
2
|
#=CHANGELOG
|
2
3
|
#==version 0.5.8
|
3
4
|
#* Calculate event feed URI instead of querying Google for content URI
|
@@ -90,4 +91,91 @@
|
|
90
91
|
#==version 0.1.1
|
91
92
|
#* Added all_day indicator to event to indicate an all day event
|
92
93
|
#==version 0.1.0
|
93
|
-
#* Initial Version
|
94
|
+
#* Initial Version
|
95
|
+
=======
|
96
|
+
=CHANGELOG
|
97
|
+
==version 0.6.0
|
98
|
+
* Updated Service to work with multiple types of GData4Ruby services
|
99
|
+
==version 0.5.5
|
100
|
+
* Fixed calendar::find method. Thanks to AB <a.berezovskiy@gmail.com>.
|
101
|
+
* Improved recurrence handling. Thanks to John Paul Narowski <jnarowski@gmail.com>.
|
102
|
+
* Fixed documentation bug for event reminders.
|
103
|
+
* Changed license to LGPLv3.
|
104
|
+
==version 0.5.4
|
105
|
+
* Fixed Serviceto_iframe bgcolor bug
|
106
|
+
==version 0.5.3
|
107
|
+
* Fixed bug when loading event attributes when initializing
|
108
|
+
==version 0.5.2
|
109
|
+
* Fixed calendar.public functionality for making calendars publicly viewable.
|
110
|
+
* Fixed to_iframe output methods
|
111
|
+
* Fixed issue with creating new events
|
112
|
+
==version 0.5.1
|
113
|
+
* Minor fixes to to_iframe methods
|
114
|
+
==version 0.5.0 - MAJOR CHANGES
|
115
|
+
* Now using GData4Ruby library as base class for service, calendar, and event objects. This removed the base.rb class, which is now inherited from
|
116
|
+
GData4ruby
|
117
|
+
* Added 'events' method to service to get all events for an account.
|
118
|
+
* Major interface changes to find methods - these are not backwards compatible changes.
|
119
|
+
* Changed Eventfind default behavior to search all calendars.
|
120
|
+
* Major interface changes to to_iframe methods - these are not backwards compatible changes.
|
121
|
+
* Added support for multiple reminders.
|
122
|
+
* Improved object relationship for events. Events are now service-centric, i.e. events are instantiated with a service object.
|
123
|
+
* Event calendar is now set through a 'calendar' attribute.
|
124
|
+
* Fixes to event recurrence handling and display.
|
125
|
+
* Added support for reminders with recurring events.
|
126
|
+
* Numerous improvements to performance.
|
127
|
+
* Calendar objects no longer have to query ACL feed to determine editability.
|
128
|
+
* Added support for event statuses: cancelled, tentative or confirmed.
|
129
|
+
==version 0.3.2
|
130
|
+
* Updated the Event.find method to support finding all events by passing :all as the query term.
|
131
|
+
==version 0.3.1
|
132
|
+
* Fixed Event.find method to work with secondary calendars and google apps accounts. Fix provided by groesser3.
|
133
|
+
* Added max results to Calendar.find.
|
134
|
+
==version 0.3.0
|
135
|
+
* Rewrote Event.find to improve performance significantly.
|
136
|
+
* Added improvements to event recurrence handling, including loading existing recurrences, changing recurring events to non recurring and vice versa.
|
137
|
+
* Added support for initialization attributes to Event, Calendar, Service and Recurrence.
|
138
|
+
* Fixed query string typo in Event.find. Fix provided by nat.lownes.
|
139
|
+
==version 0.2.11
|
140
|
+
* Added support for GML elements in calendar events. Fix provided by nat.lownes.
|
141
|
+
* Fixed event status bug where cancelled events were marked confirmed. Fix provided by rifraf.
|
142
|
+
==version 0.2.10
|
143
|
+
* Fixed library support for Google Hosted Apps accounts running in forced SSL mode.
|
144
|
+
==version 0.2.9
|
145
|
+
* Fixed small SSL redirect bug due to variable misnaming in base.rb. Fix provided by JohnMetta
|
146
|
+
==version 0.2.8
|
147
|
+
* Merged changes from edruder and h13ronim from the unofficial github repo - http://github.com/h13ronim/gcal4ruby/commits/master
|
148
|
+
==version 0.2.7
|
149
|
+
* Added fix for finding events in calendars that have more than 25 entries
|
150
|
+
==version 0.2.6
|
151
|
+
* Added fix for updated google calendar XML per http://cookingandcoding.wordpress.com/2009/06/08/new-ruby-google-calendar-api-gem-gcal4ruby/comment-183
|
152
|
+
==version 0.2.5
|
153
|
+
* Added calendar color support to to_iframe methods in Calendar and Service.
|
154
|
+
==version 0.2.4
|
155
|
+
* Fixed bug with ACL check in Calendarload
|
156
|
+
==version 0.2.3
|
157
|
+
* Implemented to_iframe method for calendars and services to output embeddable iframe text.
|
158
|
+
* Added switch to turn off ACL check for public calendars. Can increase effeciency if turned off.
|
159
|
+
==version 0.2.2
|
160
|
+
* Fixed URL encoding problem in Event.find method.
|
161
|
+
* cleaned up Event.find method to allow for finding events by id
|
162
|
+
* updated Calendar.find method to add params hash
|
163
|
+
* added 'published', 'updated', and 'edited' attributes
|
164
|
+
==version 0.2.1
|
165
|
+
* fixed Event.find calendar specification
|
166
|
+
==version 0.2.0
|
167
|
+
* Fixed redirect URI query params problem
|
168
|
+
* Updated syntax for finding events to include most google api parameters, Non-backwards compatible.
|
169
|
+
==version 0.1.4
|
170
|
+
* Added additional search criteria for Event.find
|
171
|
+
==version 0.1.3
|
172
|
+
* Added support for authenticating with Google Hosted Apps accounts
|
173
|
+
* Added flag to indicate whether a calendar is editable
|
174
|
+
* Added handling to gracefully throw error when trying to create event on a non-editable (shared) calendar
|
175
|
+
==version 0.1.2
|
176
|
+
* Fixed to_xml dump problem with hidden and selected attributes
|
177
|
+
==version 0.1.1
|
178
|
+
* Added all_day indicator to event to indicate an all day event
|
179
|
+
==version 0.1.0
|
180
|
+
* Initial Version
|
181
|
+
>>>>>>> edave/master
|
data/README.md
CHANGED
@@ -1,131 +1,114 @@
|
|
1
1
|
#GCal4Ruby
|
2
2
|
|
3
|
-
##Introduction
|
4
|
-
|
3
|
+
## Introduction
|
5
4
|
GCal4Ruby is a full featured wrapper for the google calendar API. GCal4Ruby implements
|
6
|
-
all of the functionality available through the Google
|
5
|
+
all of the functionality available through the Google Calendar API, including permissions,
|
7
6
|
attendees, reminders and event recurrence.
|
8
7
|
|
9
|
-
##Author and Contact Information
|
10
|
-
|
11
|
-
GCal4Ruby was created and is maintained by [Mike Reich](mailto:mike@seabourneconsulting.com)
|
8
|
+
## Author and Contact Information
|
9
|
+
GCal4Ruby was created and is maintained by {Mike Reich}[mailto:mike@seabourneconsulting.com]
|
12
10
|
and is licenses under the LGPL v3. Feel free to use and update, but be sure to contribute your
|
13
11
|
code back to the project and attribute as required by the license. You can find the text of the LGPL
|
14
|
-
here:
|
15
|
-
|
16
|
-
##Website
|
12
|
+
here: http://www.gnu.org/licenses/lgpl.html.
|
17
13
|
|
18
|
-
|
14
|
+
### Website
|
15
|
+
http://cookingandcoding.com/gcal4ruby/ (original GCal4Ruby plugin)
|
19
16
|
|
20
|
-
|
17
|
+
### Description
|
21
18
|
|
22
19
|
GCal4Ruby has three major components: the service, calendar and event objects. Each service
|
23
20
|
has many calendars, which in turn have many events. Each service is the representation of a
|
24
21
|
google account, and thus must be successfully authenticated using valid Google Calendar
|
25
22
|
account credentials.
|
26
23
|
|
27
|
-
##Examples
|
24
|
+
## Examples
|
28
25
|
|
29
26
|
Below are some common usage examples. For more examples, check the documentation.
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
1. Authenticate
|
34
|
-
|
35
|
-
service = Service.new
|
36
|
-
service.authenticate("user@gmail.com", "password")
|
37
|
-
|
38
|
-
2. Get Calendar List for all calendars
|
39
|
-
|
40
|
-
calendars = service.calendars
|
28
|
+
####Service
|
41
29
|
|
42
|
-
|
30
|
+
##### Authenticate with the AuthSub service (quickest, dirtiest)
|
31
|
+
service = Service.new
|
32
|
+
service.authenticate({:username => "user@gmail.com", :password => "password"})
|
43
33
|
|
44
|
-
|
34
|
+
##### Authenticate using OAuth (more setup, easier for an app)
|
35
|
+
service = Service.new({:GData4RubyService => :OAuthService})
|
36
|
+
service.authenticate({:access_token=>my_oauth_accesstoken})
|
37
|
+
|
38
|
+
See [edave-GData4Ruby](https://github.com/edave/GData4Ruby) for more details
|
39
|
+
|
40
|
+
##### Get Calendar List for all calendars that the authenticated user has owner access level
|
41
|
+
calendars = service.calendars(:only_owner_access_level => true)
|
45
42
|
|
46
|
-
|
43
|
+
# Get Calendar List
|
44
|
+
calendars = service.calendars
|
47
45
|
|
46
|
+
### Calendar
|
48
47
|
All usages assume a successfully authenticated Service.
|
49
|
-
|
50
48
|
1. Create a new Calendar
|
51
|
-
|
52
|
-
cal = Calendar.new(service)
|
49
|
+
cal = Calendar.new(service)
|
53
50
|
|
54
51
|
2. Find a calendar by ID
|
55
|
-
|
56
|
-
cal = Calendar.find(service, {:id => cal_id})
|
52
|
+
cal = Calendar.find(service, {:id => cal_id})
|
57
53
|
|
58
54
|
3. Get all calendar events
|
59
|
-
|
60
|
-
|
61
|
-
events = cal.events
|
55
|
+
cal = Calendar.find(service, {:id => cal_id})
|
56
|
+
events = cal.events
|
62
57
|
|
63
58
|
4. Find an existing calendar by title
|
64
|
-
|
65
|
-
cal = Calendar.find(service, {:title => "New Calendar"})
|
59
|
+
cal = Calendar.find(service, {:title => "New Calendar"})
|
66
60
|
|
67
61
|
5. Find all calendars containing a search term
|
62
|
+
cal = Calendar.find(service, "Soccer Team")
|
68
63
|
|
69
|
-
|
70
|
-
|
71
|
-
###Event
|
64
|
+
### Event
|
72
65
|
|
73
66
|
All usages assume a successfully authenticated Service and valid Calendar.
|
74
|
-
|
75
67
|
1. Create a new Event
|
76
|
-
|
77
|
-
|
78
|
-
event.save
|
68
|
+
event = Event.new(service, {:calendar => cal, :title => "Soccer Game", :start => Time.parse("12-06-2009 at 12:30 PM"), :end => Time.parse("12-06-2009 at 1:30 PM"), :where => "Merry Playfields"})
|
69
|
+
event.save
|
79
70
|
|
80
71
|
2. Find an existing Event by title
|
81
|
-
|
82
|
-
event = Event.find(service, {:title => "Soccer Game"})
|
72
|
+
event = Event.find(service, {:title => "Soccer Game"})
|
83
73
|
|
84
74
|
3. Find an existing Event by ID
|
85
|
-
|
86
|
-
event = Event.find(service, {:id => event.id})
|
75
|
+
event = Event.find(service, {:id => event.id})
|
87
76
|
|
88
77
|
4. Find all events containing the search term
|
89
|
-
|
90
|
-
event = Event.find(service, "Soccer Game")
|
78
|
+
event = Event.find(service, "Soccer Game")
|
91
79
|
|
92
80
|
5. Find all events on a calendar containing the search term
|
93
|
-
|
94
|
-
event = Event.find(service, "Soccer Game", {:calendar => cal.id})
|
81
|
+
event = Event.find(service, "Soccer Game", {:calendar => cal.id})
|
95
82
|
|
96
83
|
6. Find events within a date range
|
97
|
-
|
98
|
-
event = Event.find(service, "Soccer Game", {'start-min' => Time.parse("01/01/2010").utc.xmlschema, 'start-max' => Time.parse("06/01/2010").utc.xmlschema})
|
84
|
+
event = Event.find(service, "Soccer Game", {'start-min' => Time.parse("01/01/2010").utc.xmlschema, 'start-max' => Time.parse("06/01/2010").utc.xmlschema})
|
99
85
|
|
100
86
|
7. Create a recurring event for every saturday
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
event.save
|
87
|
+
event = Event.new(service)
|
88
|
+
event.title = "Baseball Game"
|
89
|
+
event.calendar = cal
|
90
|
+
event.where = "Municipal Stadium"
|
91
|
+
event.recurrence = Recurrence.new
|
92
|
+
event.recurrence.start_time = Time.parse("06/20/2009 at 4:30 PM")
|
93
|
+
event.recurrence.end_time = Time.parse("06/20/2009 at 6:30 PM")
|
94
|
+
event.recurrence.frequency = {"weekly" => ["SA"]}
|
95
|
+
event.save
|
111
96
|
|
112
97
|
8. Create an event with a 15 minute email reminder
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
event.save
|
98
|
+
event = Event.new(service)
|
99
|
+
event.calendar = cal
|
100
|
+
event.title = "Dinner with Kate"
|
101
|
+
event.start_time = Time.parse("06/20/2009 at 5 pm")
|
102
|
+
event.end_time = Time.parse("06/20/2009 at 8 pm")
|
103
|
+
event.where = "Luigi's"
|
104
|
+
event.reminder = {:minutes => 15, :method => 'email'}
|
105
|
+
event.save
|
122
106
|
|
123
107
|
9. Create an event with attendees
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
event.save
|
108
|
+
event = Event.new(service)
|
109
|
+
event.calendar = cal
|
110
|
+
event.title = "Dinner with Kate"
|
111
|
+
event.start_time = Time.parse("06/20/2009 at 5 pm")
|
112
|
+
event.end_time = Time.parse("06/20/2009 at 8 pm")
|
113
|
+
event.attendees => {:name => "Kate", :email => "kate@gmail.com"}
|
114
|
+
event.save
|
data/lib/gcal4ruby/calendar.rb
CHANGED
@@ -44,7 +44,7 @@ module GCal4Ruby
|
|
44
44
|
class Calendar < GData4Ruby::GDataObject
|
45
45
|
ALL_CALENDARS_FEED = 'https://www.google.com/calendar/feeds/default/allcalendars/full'
|
46
46
|
OWN_CALENDARS_FEED = 'https://www.google.com/calendar/feeds/default/owncalendars/full'
|
47
|
-
CALENDAR_XML = "<entry xmlns='http://www.w3.org/2005/Atom'
|
47
|
+
CALENDAR_XML = "<entry xmlns='http://www.w3.org/2005/Atom'
|
48
48
|
xmlns:gd='http://schemas.google.com/g/2005'
|
49
49
|
xmlns:gCal='http://schemas.google.com/gCal/2005'>
|
50
50
|
<title type='text'></title>
|
@@ -89,7 +89,7 @@ module GCal4Ruby
|
|
89
89
|
if !service.is_a?(Service)
|
90
90
|
raise InvalidService
|
91
91
|
end
|
92
|
-
@xml =
|
92
|
+
@xml = @@calendar_xml
|
93
93
|
@service ||= service
|
94
94
|
@updated_at = nil
|
95
95
|
@exists = false
|
@@ -101,8 +101,11 @@ module GCal4Ruby
|
|
101
101
|
@color ||= "#2952A3"
|
102
102
|
@where ||= ""
|
103
103
|
attributes.each do |key, value|
|
104
|
-
self.
|
104
|
+
if self.respond_to?("#{key}=")
|
105
|
+
self.send("#{key}=", value)
|
106
|
+
end
|
105
107
|
end
|
108
|
+
@debug ||= false
|
106
109
|
return true
|
107
110
|
end
|
108
111
|
|
@@ -120,7 +123,7 @@ module GCal4Ruby
|
|
120
123
|
#Returns an array of Event objects corresponding to each event in the calendar.
|
121
124
|
def events
|
122
125
|
events = []
|
123
|
-
ret =
|
126
|
+
ret = service.send_request(GData4Ruby::Request.new(:get, @content_uri))
|
124
127
|
REXML::Document.new(ret.body).root.elements.each("entry"){}.map do |entry|
|
125
128
|
entry = GData4Ruby::Utils.add_namespaces(entry)
|
126
129
|
e = Event.new(service)
|
@@ -138,12 +141,12 @@ module GCal4Ruby
|
|
138
141
|
ret = super
|
139
142
|
return ret if public == @public
|
140
143
|
if public
|
141
|
-
|
142
|
-
rule = GData4Ruby::ACL::AccessRule.new(service, self)
|
144
|
+
log('setting calendar to public')
|
145
|
+
rule = GData4Ruby::ACL::AccessRule.new(service.gdata_service, self)
|
143
146
|
rule.role = 'http://schemas.google.com/gCal/2005#read'
|
144
147
|
rule.save
|
145
148
|
else
|
146
|
-
rule = GData4Ruby::ACL::AccessRule.find(service, self, {:user => 'default'})
|
149
|
+
rule = GData4Ruby::ACL::AccessRule.find(service.gdata_service, self, {:user => 'default'})
|
147
150
|
rule.delete if rule
|
148
151
|
end
|
149
152
|
reload
|
@@ -263,25 +266,33 @@ module GCal4Ruby
|
|
263
266
|
end
|
264
267
|
end
|
265
268
|
|
266
|
-
if
|
267
|
-
|
269
|
+
if service.check_public
|
270
|
+
log("Getting ACL Feed")
|
271
|
+
|
272
|
+
# If the ACL URI doesn't exist, then its definitely not public
|
273
|
+
if (@acl_uri == nil)
|
274
|
+
log("Not Public")
|
275
|
+
@public = false
|
276
|
+
return true
|
277
|
+
end
|
268
278
|
|
269
279
|
#rescue error on shared calenar ACL list access
|
270
280
|
begin
|
271
|
-
|
281
|
+
log("ACL URI: #{@acl_uri}")
|
282
|
+
ret = service.send_request(GData4Ruby::Request.new(:get, @acl_uri))
|
272
283
|
rescue Exception => e
|
273
|
-
|
284
|
+
log("ACL Feed Get Failed: #{e.inspect}")
|
274
285
|
@public = false
|
275
286
|
return true
|
276
287
|
end
|
277
288
|
r = REXML::Document.new(ret.read_body)
|
278
289
|
r.root.elements.each("entry") do |ele|
|
279
|
-
e = GData4Ruby::ACL::AccessRule.new(service, self)
|
290
|
+
e = GData4Ruby::ACL::AccessRule.new(service.gdata_service, self)
|
280
291
|
ele = GData4Ruby::Utils.add_namespaces(ele)
|
281
292
|
e.load(ele.to_s)
|
282
|
-
|
293
|
+
log('ACL Rule: '+e.inspect)
|
283
294
|
@public = (e.role.include? 'read' and e.user == 'default')
|
284
|
-
|
295
|
+
log('Public: '+@public.to_s)
|
285
296
|
break if @public
|
286
297
|
end
|
287
298
|
else
|
@@ -320,7 +331,7 @@ module GCal4Ruby
|
|
320
331
|
|
321
332
|
output += "&src=#{id}"
|
322
333
|
|
323
|
-
"<iframe src='
|
334
|
+
"<iframe src='#{service.create_url("www.google.com/calendar/embed?"+output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
|
324
335
|
end
|
325
336
|
|
326
337
|
#Helper function to return a specified calendar id as a formatted iframe embedded google calendar. This function does not require loading the calendar information from the Google calendar
|
@@ -353,7 +364,7 @@ module GCal4Ruby
|
|
353
364
|
|
354
365
|
output += "&src=#{id}"
|
355
366
|
|
356
|
-
"<iframe src='
|
367
|
+
"<iframe src='#{service.create_url("www.google.com/calendar/embed?"+output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
|
357
368
|
end
|
358
369
|
|
359
370
|
private
|
data/lib/gcal4ruby/event.rb
CHANGED
@@ -402,6 +402,9 @@ module GCal4Ruby
|
|
402
402
|
end
|
403
403
|
else
|
404
404
|
service.calendars.each do |cal|
|
405
|
+
puts "Event.find() searching calendar: " if service.debug
|
406
|
+
puts cal.content_uri if service.debug
|
407
|
+
puts args.inspect if service.debug
|
405
408
|
ret = service.send_request(GData4Ruby::Request.new(:get, cal.content_uri, nil, nil, args))
|
406
409
|
xml = REXML::Document.new(ret.body).root
|
407
410
|
xml.elements.each("entry") do |e|
|
data/lib/gcal4ruby/service.rb
CHANGED
@@ -43,12 +43,12 @@ module GCal4Ruby
|
|
43
43
|
#
|
44
44
|
class Service < GData4Ruby::Service
|
45
45
|
|
46
|
-
#
|
47
|
-
|
48
|
-
|
49
|
-
# The token returned by the Google servers, used to authorize all subsequent messages
|
50
|
-
attr_reader :auth_token
|
46
|
+
# The type of GData4Ruby service we want to use
|
47
|
+
attr_accessor :gdata_service
|
51
48
|
|
49
|
+
# Convenience attribute contains the currently authenticated account name
|
50
|
+
attr_accessor :account
|
51
|
+
|
52
52
|
# Determines whether GCal4Ruby ensures a calendar is public. Setting this to false can increase speeds by
|
53
53
|
# 50% but can cause errors if you try to do something to a calendar that is not public and you don't have
|
54
54
|
# adequate permissions
|
@@ -56,24 +56,71 @@ module GCal4Ruby
|
|
56
56
|
|
57
57
|
#Accepts an optional attributes hash for initialization values
|
58
58
|
def initialize(attributes = {})
|
59
|
-
|
59
|
+
# If the user has specified the type of GData4Ruby class they want, instantiate it
|
60
|
+
if(attributes.has_key?(:GData4RubyService))
|
61
|
+
@gdata_service = GData4Ruby.const_get(attributes[:GData4RubyService]).new(attributes)
|
62
|
+
end
|
63
|
+
# Otherwise use the default service
|
64
|
+
@gdata_service ||= GData4Ruby::Service.new(attributes)
|
60
65
|
attributes.each do |key, value|
|
61
|
-
self.
|
66
|
+
if self.respond_to?("#{key}=")
|
67
|
+
self.send("#{key}=", value)
|
68
|
+
end
|
62
69
|
end
|
63
70
|
@check_public ||= true
|
71
|
+
@account ||= "default"
|
72
|
+
@debug ||= false
|
73
|
+
log("Check Public: #{check_public}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def debug
|
77
|
+
return @debug
|
78
|
+
end
|
79
|
+
|
80
|
+
def debug=(value)
|
81
|
+
@debug=value
|
82
|
+
@gdata_service.debug = value
|
64
83
|
end
|
84
|
+
|
85
|
+
def log(string)
|
86
|
+
puts string if debug
|
87
|
+
end
|
88
|
+
<<<<<<< HEAD
|
65
89
|
|
66
90
|
# The authenticate method passes the username and password to google servers.
|
91
|
+
=======
|
92
|
+
|
93
|
+
def default_event_feed
|
94
|
+
return create_url("www.google.com/calendar/feeds/#{@account}/private/full")
|
95
|
+
end
|
96
|
+
|
97
|
+
# The authenticate method passes an for the service to use to access Google's servers
|
98
|
+
>>>>>>> edave/master
|
67
99
|
# If authentication succeeds, returns true, otherwise raises the AuthenticationFailed error.
|
68
|
-
def authenticate(
|
69
|
-
|
100
|
+
def authenticate(options = {})
|
101
|
+
if not options.has_key?(:service)
|
102
|
+
options[:service] = 'cl'
|
103
|
+
end
|
104
|
+
@gdata_service.authenticate(options)
|
70
105
|
end
|
71
106
|
|
72
107
|
#Helper function to reauthenticate to a new Google service without having to re-set credentials.
|
73
|
-
def reauthenticate(
|
74
|
-
|
108
|
+
def reauthenticate(options = {})
|
109
|
+
if not options.has_key?(:service)
|
110
|
+
options[:service] = 'cl'
|
111
|
+
end
|
112
|
+
@gdata_service.reauthenticate(options)
|
75
113
|
end
|
76
|
-
|
114
|
+
|
115
|
+
# Passes a request along from a GData4Ruby GDataObject to a GData4Ruby Base (Service) to be invoked
|
116
|
+
def send_request(request)
|
117
|
+
if not @gdata_service.authenticated?
|
118
|
+
raise GData4Ruby::NotAuthenticated
|
119
|
+
end
|
120
|
+
@gdata_service.send_request(request)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
77
124
|
#Returns an array of Calendar objects for each calendar associated with
|
78
125
|
#the authenticated account. An optional hash of options is the only parameter. The
|
79
126
|
#available options are:
|
@@ -87,12 +134,14 @@ module GCal4Ruby
|
|
87
134
|
cals = []
|
88
135
|
REXML::Document.new(ret.body).root.elements.each("entry"){}.map do |entry|
|
89
136
|
entry = GData4Ruby::Utils.add_namespaces(entry)
|
90
|
-
cal = Calendar.new(self)
|
137
|
+
cal = Calendar.new(self, {:debug => debug})
|
138
|
+
log(entry.inspect)
|
91
139
|
cal.load(entry.to_s)
|
92
140
|
cals << cal
|
93
141
|
end
|
94
142
|
return cals
|
95
143
|
end
|
144
|
+
|
96
145
|
|
97
146
|
#Returns an array of Event objects for each event in this account
|
98
147
|
def events
|
@@ -103,13 +152,18 @@ module GCal4Ruby
|
|
103
152
|
events = []
|
104
153
|
REXML::Document.new(ret.body).root.elements.each("entry"){}.map do |entry|
|
105
154
|
entry = GData4Ruby::Utils.add_namespaces(entry)
|
106
|
-
event = Event.new(self)
|
155
|
+
event = Event.new(self, {:debug => debug})
|
107
156
|
event.load(entry.to_s)
|
108
157
|
events << event
|
109
158
|
end
|
110
159
|
return events
|
111
160
|
end
|
112
161
|
|
162
|
+
# Builds a URL
|
163
|
+
def create_url(path)
|
164
|
+
return @gdata_service.create_url(path)
|
165
|
+
end
|
166
|
+
|
113
167
|
#Helper function to return a formatted iframe embedded google calendar. Parameters are:
|
114
168
|
#1. *cals*: either an array of calendar ids, or <em>:all</em> for all calendars, or <em>:first</em> for the first (usally default) calendar
|
115
169
|
#2. *params*: a hash of parameters that affect the display of the embedded calendar. Accepts any parameter that the google iframe recognizes. Here are the most common:
|
@@ -155,7 +209,7 @@ module GCal4Ruby
|
|
155
209
|
output += "src=#{cal_list[0].id}&"
|
156
210
|
end
|
157
211
|
|
158
|
-
"<iframe src='
|
212
|
+
"<iframe src='#{create_url("www.google.com/calendar/embed?"+output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
|
159
213
|
end
|
160
214
|
end
|
161
215
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cs210-gcal4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.6.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Reich
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-29 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cs210-gdata4ruby
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.2.0
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
description: "GCal4Ruby is a Ruby Gem that can be used to interact with the current version of the Google Calendar API. GCal4Ruby provides the following features: Create and edit calendar events, Add and invite users to events, Set reminders, Make recurring events."
|