googlecalendar 0.0.5 → 0.0.6

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.
Files changed (4) hide show
  1. data/CHANGELOG +8 -3
  2. data/lib/builders.rb +1 -1
  3. data/lib/googlecalendar.rb +58 -11
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,6 +1,11 @@
1
1
  = Versions
2
+ === 0.0.6 (Dec 03rd, 2007)
3
+ * Added add_reminder and reset_reminders to GData (see examples/ruby_standalone/gdata_new_event_reminder.rb)
4
+ Contribution: Nicolas Fouché
5
+ * Added "Quick Add" (see examples/ruby_standalone/gdata_quick_add.rb)
6
+ Contribution: Levi Kennedy
2
7
 
3
- === 0.0.5 (Spet 24th, 2007)
8
+ === 0.0.5 (Sept 24th, 2007)
4
9
  * You can now set a different google url in GData class (default value is www.google.com)
5
10
  * Adding code to post an event to other calendar than the default one
6
11
  * Get the list of calendar associated with the user.
@@ -12,11 +17,11 @@ Thanks to Kalle Saas for his contribution :)
12
17
 
13
18
  === 0.0.4 (June 8th, 2007)
14
19
  * Can add simple events now
15
- ** Added a GData class and an example of how to use it
20
+ * Added a GData class and an example of how to use it
16
21
 
17
22
  === 0.0.3 (May 5th, 2007)
18
23
  * Handle recurring events
19
- ** Added a rrule property and a rrule_as_hash method
24
+ * Added a rrule property and a rrule_as_hash method
20
25
 
21
26
  === 0.0.2 (June 16th, 2006)
22
27
  * Refactor googlecalendar to a single rb file
@@ -93,4 +93,4 @@ def html(calendar, filename)
93
93
  html_builder.filename = filename
94
94
  html_builder.date_format = "%d-%m-%y" #"%F"#"%A %B %d %Y" #"%d-%m-%Y"
95
95
  html_builder.export
96
- end
96
+ end
@@ -49,7 +49,7 @@ class Event
49
49
  data << 'rrule: ' + @rrule.to_s + "\n"
50
50
  data << 'summary: ' + @summary.to_s + "\n"
51
51
  data << 'desription: ' + @desription.to_s + "\n"
52
- data << 'location: ' + @ location.to_s + "\n"
52
+ data << 'location: ' + @location.to_s + "\n"
53
53
  return data
54
54
  end
55
55
 
@@ -77,9 +77,11 @@ module Net
77
77
  end
78
78
  end
79
79
 
80
- #A ruby class to wrap calls to the Google Data API
81
- #More informations
82
- #_Google calendar API: http://code.google.com/apis/calendar/developers_guide_protocol.html_
80
+ # A ruby class to wrap calls to the Google Data API
81
+ #
82
+ # More informations
83
+ #
84
+ # Google calendar API: http://code.google.com/apis/calendar/developers_guide_protocol.html
83
85
  class GData
84
86
  attr_accessor :google_url
85
87
 
@@ -112,6 +114,34 @@ class GData
112
114
  return @token
113
115
  end
114
116
 
117
+ # Reset reminders
118
+ def reset_reminders(event)
119
+ event[:reminders] = ""
120
+ end
121
+
122
+ # Add a reminder to the event hash
123
+ #* reminderMinutes
124
+ #* reminderMethod [email, alert, sms, none]
125
+ def add_reminder(event, reminderMinutes, reminderMethod)
126
+ event[:reminders] = event[:reminders].to_s +
127
+ "<gd:reminder minutes='#{reminderMinutes}' method='#{reminderMethod}' />\n"
128
+ end
129
+
130
+ # Create a quick add event
131
+ #
132
+ # <tt>text = 'Tennis with John April 11 3pm-3:30pm'</tt>
133
+ #
134
+ # http://code.google.com/apis/calendar/developers_guide_protocol.html#CreatingQuickAdd
135
+ def quick_add(text)
136
+ content = <<EOF
137
+ <entry xmlns='http://www.w3.org/2005/Atom' xmlns:gCal='http://schemas.google.com/gCal/2005'>
138
+ <content type="html">#{text}</content>
139
+ <gCal:quickadd value="true"/>
140
+ </entry>
141
+ EOF
142
+ post_event(content)
143
+ end
144
+
115
145
  #'event' param is a hash containing
116
146
  #* :title
117
147
  #* :content
@@ -119,10 +149,15 @@ class GData
119
149
  #* :email
120
150
  #* :where
121
151
  #* :startTime '2007-06-06T15:00:00.000Z'
122
- #* :endTime '2007-06-06T17:00:00.000Z'
123
- def new_event(event={},calendar = nil)
152
+ #* :endTime '2007-06-06T17:00:00.000Z'
153
+ #
154
+ # Use add_reminder(event, reminderMinutes, reminderMethod) method to add reminders
155
+ def new_event(event={},calendar = nil)
124
156
  new_event = template(event)
157
+ post_event(new_event, calendar)
158
+ end
125
159
 
160
+ def post_event(xml, calendar = nil)
126
161
  #Get calendar url
127
162
  calendar_url = if calendar
128
163
  get_calendars
@@ -133,10 +168,10 @@ class GData
133
168
  end
134
169
 
135
170
  http = Net::HTTP.new(@google_url, 80)
136
- response, data = http.post(calendar_url, new_event, @headers)
171
+ response, data = http.post(calendar_url, xml, @headers)
137
172
  case response
138
173
  when Net::HTTPSuccess, Net::HTTPRedirection
139
- redirect_response, redirect_data = http.post(response['location'], new_event, @headers)
174
+ redirect_response, redirect_data = http.post(response['location'], xml, @headers)
140
175
  case response
141
176
  when Net::HTTPSuccess, Net::HTTPRedirection
142
177
  return redirect_response
@@ -197,12 +232,13 @@ class GData
197
232
  value='http://schemas.google.com/g/2005#event.confirmed'>
198
233
  </gd:eventStatus>
199
234
  <gd:where valueString='#{event[:where]}'></gd:where>
200
- <gd:when startTime='#{event[:startTime]}'
201
- endTime='#{event[:endTime]}'></gd:when>
235
+ <gd:when startTime='#{event[:startTime]}' endTime='#{event[:endTime]}'>
236
+ #{event[:reminders]}
237
+ </gd:when>
202
238
  </entry>
203
239
  EOF
204
240
  end
205
- end
241
+ end # GData class
206
242
 
207
243
  class ICALParser
208
244
  attr_reader :calendar
@@ -335,3 +371,14 @@ def scan(ical_url, base_url='www.google.com')
335
371
  end
336
372
  end
337
373
 
374
+ def scan_proxy(proxy_addr, proxy_port, ical_url, base_url='www.google.com')
375
+ Net::HTTP::Proxy(proxy_addr, proxy_port).start(base_url, 80) do |http|
376
+ response, data = http.get(ical_url)
377
+ case response
378
+ when Net::HTTPSuccess, Net::HTTPRedirection
379
+ return data
380
+ else
381
+ response.error!
382
+ end
383
+ end
384
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: googlecalendar
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.5
7
- date: 2007-09-24 00:00:00 +02:00
6
+ version: 0.0.6
7
+ date: 2007-12-03 00:00:00 +01:00
8
8
  summary: Google Calendar api for Ruby
9
9
  require_paths:
10
10
  - lib