gcal4ruby 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,7 @@
1
1
  #=CHANGELOG
2
+ #==version 0.5.2
3
+ #* Fixed calendar.public functionality for making calendars publicly viewable.
4
+ #* Fixed to_iframe output methods
2
5
  #==version 0.5.1
3
6
  #* Minor fixes to to_iframe methods
4
7
  #==version 0.5.0 - MAJOR CHANGES
@@ -93,7 +93,6 @@ module GCal4Ruby
93
93
  @timezone ||= "America/Los_Angeles"
94
94
  @color ||= "#2952A3"
95
95
  @where ||= ""
96
- @permissions = ''
97
96
  attributes.each do |key, value|
98
97
  self.send("#{key}=", value)
99
98
  end
@@ -125,15 +124,29 @@ module GCal4Ruby
125
124
  return events
126
125
  end
127
126
 
127
+
128
+ #Saves the calendar.
129
+ def save
130
+ public = @public
131
+ ret = super
132
+ return ret if public == @public
133
+ if public
134
+ puts 'setting calendar to public' if service.debug
135
+ rule = GData4Ruby::ACL::AccessRule.new(service, self)
136
+ rule.role = 'http://schemas.google.com/gCal/2005#read'
137
+ rule.save
138
+ else
139
+ rule = GData4Ruby::ACL::AccessRule.find(service, self, {:user => 'default'})
140
+ rule.delete if rule
141
+ end
142
+ reload
143
+ end
144
+
128
145
  #Set the calendar to public (p = true) or private (p = false). Publically viewable
129
146
  #calendars can be accessed by anyone without having to log in to google calendar. See
130
147
  #Calendar#to_iframe on how to display a public calendar in a webpage.
131
148
  def public=(p)
132
- if p
133
- @permissions = 'http://schemas.google.com/gCal/2005#read'
134
- else
135
- @permissions = 'none'
136
- end
149
+ @public = p
137
150
  end
138
151
 
139
152
  #Creates a new instance of the object
@@ -184,7 +197,7 @@ module GCal4Ruby
184
197
  #if successful, otherwise returns false. Any information not saved will be overwritten.
185
198
  def reload
186
199
  return false if not @exists
187
- t = self.find(service, @id)
200
+ t = Calendar.find(service, {:id => @id})
188
201
  if t
189
202
  load(t.to_xml)
190
203
  else
@@ -207,8 +220,6 @@ module GCal4Ruby
207
220
  ele.attributes["value"] = @color
208
221
  when "selected"
209
222
  ele.attributes["value"] = @selected.to_s
210
- when 'role'
211
- ele.attributes['value'] = @permissions
212
223
  end
213
224
  end
214
225
  xml.to_s
@@ -259,7 +270,9 @@ module GCal4Ruby
259
270
  e = GData4Ruby::ACL::AccessRule.new(service, self)
260
271
  ele = GData4Ruby::Utils.add_namespaces(ele)
261
272
  e.load(ele.to_s)
262
- @public == (e.role.include? 'read' and e.user == 'default')
273
+ puts 'acl rule = '+e.inspect if service.debug
274
+ @public = (e.role.include? 'read' and e.user == 'default')
275
+ puts 'public = '+@public.to_s if service.debug
263
276
  break if @public
264
277
  end
265
278
  else
@@ -293,13 +306,12 @@ module GCal4Ruby
293
306
  params[:bgcolor] ||= "#FFFFFF"
294
307
  params[:color] ||= "#2952A3"
295
308
  params[:border] ||= "0"
296
- puts "params = #{params.inspect}" if service.debug
297
- output = "?#{params.to_a.collect{|a| a.join("=")}.join("&")}&"
298
- puts "param_string = #{output}" if service.debug
309
+ params.each{|key, value| params[key] = CGI::escape(value)}
310
+ output = "#{params.to_a.collect{|a| a.join("=")}.join("&")}"
299
311
 
300
- output += "src=#{@id}&color=#{params[:color]}"
312
+ output += "&src=#{id}"
301
313
 
302
- "<iframe src='http://www.google.com/calendar/embed?#{CGI.escape(output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
314
+ "<iframe src='http://www.google.com/calendar/embed?#{output}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
303
315
  end
304
316
 
305
317
  #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
@@ -327,11 +339,12 @@ module GCal4Ruby
327
339
  params[:bgcolor] ||= "#FFFFFF"
328
340
  params[:color] ||= "#2952A3"
329
341
  params[:border] ||= "0"
330
- output = "?#{params.to_a.collect{|a| a.join("=")}.join("&")}&"
342
+ params.each{|key, value| params[key] = CGI::escape(value)}
343
+ output = "#{params.to_a.collect{|a| a.join("=")}.join("&")}"
331
344
 
332
- output += "src=#{id}&color=#{params[:color]}"
345
+ output += "&src=#{id}"
333
346
 
334
- "<iframe src='http://www.google.com/calendar/embed?#{CGI.escape(output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
347
+ "<iframe src='http://www.google.com/calendar/embed?#{output}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
335
348
  end
336
349
 
337
350
  private
@@ -125,8 +125,8 @@ module GCal4Ruby
125
125
  self.send("#{key}=", value)
126
126
  end
127
127
  @xml = EVENT_XML
128
- @transparency ||= "http://schemas.google.com/g/2005#event.opaque"
129
- @status ||= "http://schemas.google.com/g/2005#event.confirmed"
128
+ @transparency ||= :busy
129
+ @status ||= :confirmed
130
130
  @attendees ||= []
131
131
  @all_day ||= false
132
132
  @reminder = []
@@ -116,7 +116,6 @@ module GCal4Ruby
116
116
  # width:: the width of the embedded calendar in pixels
117
117
  # title:: the title to display
118
118
  # bgcolor:: the background color. Limited choices, see google docs for allowable values.
119
- # color:: the color of the calendar elements. Limited choices, see google docs for allowable values.
120
119
  # showTitle:: set to '0' to hide the title
121
120
  # showDate:: set to '0' to hide the current date
122
121
  # showNav:: set to '0 to hide the navigation tools
@@ -134,11 +133,9 @@ module GCal4Ruby
134
133
  params[:width] ||= "600"
135
134
  params[:title] ||= (self.account ? self.account : '')
136
135
  params[:bgcolor] ||= "#FFFFFF"
137
- params[:color] ||= "#2952A3"
138
136
  params[:border] ||= "0"
139
- puts "params = #{params.inspect}" if self.debug
140
- output = "?#{params.to_a.collect{|a| a.join("=")}.join("&")}&"
141
- puts "param_string = #{output}" if self.debug
137
+ params.each{|key, value| params[key] = CGI::escape(value)}
138
+ output = "#{params.to_a.collect{|a| a.join("=")}.join("&")}"
142
139
 
143
140
  if cals.is_a?(Array)
144
141
  for c in cals
@@ -157,7 +154,7 @@ module GCal4Ruby
157
154
  output += "src=#{cal_list[0].id}&"
158
155
  end
159
156
 
160
- "<iframe src='http://www.google.com/calendar/embed?#{CGI::escape(output)}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
157
+ "<iframe src='http://www.google.com/calendar/embed?#{output}' style='#{params[:border]} px solid;' width='#{params[:width]}' height='#{params[:height]}' frameborder='#{params[:border]}' scrolling='no'></iframe>"
161
158
  end
162
159
  end
163
160
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mike Reich
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-29 00:00:00 +10:00
17
+ date: 2010-05-13 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,11 +27,11 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 1
30
- - 0
31
- version: 0.1.0
30
+ - 2
31
+ version: 0.1.2
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
- 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:<br>* Create and edit calendar events<br>* Add and invite users to events<br>* Set reminders<br>* Make recurring events
34
+ 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."
35
35
  email: mike@seabourneconsulting.com
36
36
  executables: []
37
37