gcal4ruby 0.3.1 → 0.5.0

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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcal4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Reich
@@ -9,11 +9,20 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-02 00:00:00 +11:00
12
+ date: 2010-04-29 00:00:00 +10:00
13
13
  default_executable:
14
- dependencies: []
15
-
16
- description: A full featured wrapper for interacting with the Google Calendar API
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gdata4ruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.1.0
24
+ version:
25
+ 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:\n\n* Create and edit calendar events\n* Add and invite users to events\n* Set reminders\n* Make recurring events
17
26
  email: mike@seabourneconsulting.com
18
27
  executables: []
19
28
 
@@ -25,13 +34,12 @@ files:
25
34
  - README
26
35
  - CHANGELOG
27
36
  - lib/gcal4ruby.rb
28
- - lib/gcal4ruby/base.rb
29
37
  - lib/gcal4ruby/service.rb
30
38
  - lib/gcal4ruby/calendar.rb
31
39
  - lib/gcal4ruby/event.rb
32
40
  - lib/gcal4ruby/recurrence.rb
33
41
  has_rdoc: true
34
- homepage: http://gcal4ruby.rubyforge.org/
42
+ homepage: http://cookingandcoding.com/gcal4ruby/
35
43
  licenses: []
36
44
 
37
45
  post_install_message:
@@ -1,283 +0,0 @@
1
- require "rexml/document"
2
- require "cgi"
3
- require "uri"
4
- require "net/http"
5
- require "net/https"
6
- require "open-uri"
7
- require "nkf"
8
- require "time"
9
-
10
- Net::HTTP.version_1_2
11
-
12
- # GCal4Ruby is a full featured wrapper for the google calendar API
13
-
14
- # =Usage:
15
-
16
- module GCal4Ruby
17
-
18
- CALENDAR_XML = "<entry xmlns='http://www.w3.org/2005/Atom'
19
- xmlns:gd='http://schemas.google.com/g/2005'
20
- xmlns:gCal='http://schemas.google.com/gCal/2005'>
21
- <title type='text'></title>
22
- <summary type='text'></summary>
23
- <gCal:timezone value=''></gCal:timezone>
24
- <gCal:hidden value=''></gCal:hidden>
25
- <gCal:color value=''></gCal:color>
26
- <gd:where rel='' label='' valueString=''></gd:where>
27
- </entry>"
28
-
29
- ACL_XML = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>
30
- <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/>
31
- <gAcl:scope type='default'></gAcl:scope>
32
- <gAcl:role value=''></gAcl:role>
33
- </entry>"
34
-
35
- EVENT_XML = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>
36
- <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'></category>
37
- <title type='text'></title>
38
- <content type='text'></content>
39
- <gd:transparency value=''></gd:transparency>
40
- <gd:eventStatus value=''></gd:eventStatus>
41
- <gd:where valueString=''></gd:where>
42
- <gd:when startTime='' endTime=''></gd:when>
43
- </entry>
44
- "
45
-
46
- class AuthenticationFailed < StandardError; end #:nodoc: all
47
-
48
- class NotAuthenticated < StandardError; end
49
-
50
- class InvalidService < StandardError; end
51
-
52
- class HTTPPostFailed < StandardError; end
53
-
54
- class HTTPPutFailed < StandardError; end
55
-
56
- class HTTPGetFailed < StandardError; end
57
-
58
- class HTTPDeleteFailed < StandardError; end
59
-
60
- class CalendarSaveFailed < StandardError; end
61
-
62
- class EventSaveFailed < StandardError; end
63
-
64
- class RecurrenceValueError < StandardError; end
65
-
66
- class CalendarNotEditable < StandardError; end
67
-
68
- class QueryParameterError < StandardError; end
69
-
70
- #The ProxyInfo class contains information for configuring a proxy connection
71
-
72
- class ProxyInfo
73
- attr_accessor :address, :port, :username, :password
74
- @address = nil
75
- @port = nil
76
- @username = nil
77
- @password = nil
78
-
79
- #The initialize function accepts four variables for configuring the ProxyInfo object.
80
- #The proxy connection is initiated using the builtin Net::HTTP proxy support.
81
-
82
- def initialize(address, port, username=nil, password=nil)
83
- @address = address
84
- @port = port
85
- @username = username
86
- @password = password
87
- end
88
- end
89
-
90
- #The Base class includes the basic HTTP methods for sending and receiving
91
- #messages from the Google Calendar API. You shouldn't have to use this class
92
- #directly, rather access the functionality through the Service subclass.
93
-
94
- class Base
95
- AUTH_URL = "https://www.google.com/accounts/ClientLogin"
96
- CALENDAR_LIST_FEED = "http://www.google.com/calendar/feeds/default/allcalendars/full"
97
- @proxy_info = nil
98
- @auth_token = nil
99
- @debug = false
100
-
101
- #Contains the ProxyInfo object for using a proxy server
102
- attr_accessor :proxy_info
103
-
104
- #If set to true, debug will dump all raw HTTP requests and responses
105
- attr_accessor :debug
106
-
107
- # Sends an HTTP POST request. The header should be a hash of name/value pairs.
108
- # Returns the Net::HTTPResponse object on succces, or raises the appropriate
109
- # error if a non 20x response code is received.
110
- def send_post(url, content, header=nil)
111
- header = auth_header(header)
112
- ret = nil
113
- location = URI.parse(url)
114
- puts "url = "+url if @debug
115
- ret = do_post(location, header, content)
116
- while ret.is_a?(Net::HTTPRedirection)
117
- puts "Redirect received, resending post" if @debug
118
- ret = do_post(ret['location'], header, content)
119
- end
120
- if ret.is_a?(Net::HTTPSuccess)
121
- puts "20x response received\nResponse: \n"+ret.read_body if @debug
122
- return ret
123
- else
124
- puts "invalid response received: "+ret.code if @debug
125
- raise HTTPPostFailed, ret.body
126
- end
127
- end
128
-
129
- def do_post(url, header, content)
130
- ret = nil
131
- if url.is_a?(String)
132
- location = URI.parse(url)
133
- else
134
- location = url
135
- end
136
- http = get_http_object(location)
137
- puts "Starting post\nHeader: #{header}\n" if @debug
138
- http.start do |ht|
139
- ret = ht.post(location.to_s, content, header)
140
- end
141
- return ret
142
- end
143
-
144
- # Sends an HTTP PUT request. The header should be a hash of name/value pairs.
145
- # Returns the Net::HTTPResponse object on succces, or raises the appropriate
146
- # error if a non 20x response code is received.
147
- def send_put(url, content, header=nil)
148
- header = auth_header(header)
149
- ret = nil
150
- location = URI.parse(url)
151
- puts "url = "+url if @debug
152
- ret = do_put(location, header, content)
153
- while ret.is_a?(Net::HTTPRedirection)
154
- puts "Redirect received, resending post" if @debug
155
- ret = do_put(ret['location'], header, content)
156
- end
157
- if ret.is_a?(Net::HTTPSuccess)
158
- puts "20x response received\nResponse: \n"+ret.read_body if @debug
159
- return ret
160
- else
161
- puts "invalid response received: "+ret.code if @debug
162
- raise HTTPPutFailed, ret.body
163
- end
164
- end
165
-
166
- def do_put(url, header, content)
167
- ret = nil
168
- if url.is_a?(String)
169
- location = URI.parse(url)
170
- else
171
- location = url
172
- end
173
- http = get_http_object(location)
174
- puts "Starting put\nHeader: #{header}\n" if @debug
175
- http.start do |ht|
176
- ret = ht.put(location.to_s, content, header)
177
- end
178
- return ret
179
- end
180
-
181
- # Sends an HTTP GET request. The header should be a hash of name/value pairs.
182
- # Returns the Net::HTTPResponse object on succces, or raises the appropriate
183
- # error if a non 20x response code is received.
184
- def send_get(url, header = nil)
185
- header = auth_header(header)
186
- ret = nil
187
- location = URI.parse(url)
188
- puts "url = "+url if @debug
189
- ret = do_get(location, header)
190
- while ret.is_a?(Net::HTTPRedirection)
191
- puts "Redirect received from #{location.to_s}, resending get to #{ret['location']}" if @debug
192
- ret = do_get(ret['location'], header)
193
- end
194
- if ret.is_a?(Net::HTTPSuccess)
195
- puts "20x response received\nResponse: \n"+ret.read_body if @debug
196
- return ret
197
- else
198
- puts "Error received, resending get" if @debug
199
- raise HTTPGetFailed, ret.body
200
- end
201
- end
202
-
203
- def do_get(url, header)
204
- ret = nil
205
- if url.is_a?(String)
206
- location = URI.parse(url)
207
- else
208
- location = url
209
- end
210
- http = get_http_object(location)
211
- puts "Starting get\nHeader: #{header}\n" if @debug
212
- http.start do |ht|
213
- ret = ht.get(location.to_s, header)
214
- end
215
- return ret
216
- end
217
-
218
- # Sends an HTTP DELETE request. The header should be a hash of name/value pairs.
219
- # Returns the Net::HTTPResponse object on succces, or raises the appropriate
220
- # error if a non 20x response code is received.
221
- def send_delete(url, header = nil)
222
- header = auth_header(header)
223
- ret = nil
224
- location = URI.parse(url)
225
- puts "url = "+url if @debug
226
- ret = do_delete(location, header)
227
- while ret.is_a?(Net::HTTPRedirection)
228
- puts "Redirect received, resending post" if @debug
229
- ret = do_delete(ret['location'], header)
230
- end
231
- if ret.is_a?(Net::HTTPSuccess)
232
- puts "20x response received\nResponse: \n"+ret.read_body if @debug
233
- return true
234
- else
235
- puts "invalid response received: "+ret.code if @debug
236
- raise HTTPDeleteFailed, ret.body
237
- end
238
- end
239
-
240
- def do_delete(url, header)
241
- ret = nil
242
- if url.is_a?(String)
243
- location = URI.parse(url)
244
- else
245
- location = url
246
- end
247
- http = get_http_object(location)
248
- puts "Starting get\nHeader: #{header}\n" if @debug
249
- http.start do |ht|
250
- ret = ht.delete(location.to_s, header)
251
- end
252
- return ret
253
- end
254
-
255
- private
256
-
257
- def get_http_object(location)
258
- if @proxy_info and @proxy_info.address
259
- http = Net::HTTP.new(location.host, location.port, @proxy_info.address, @proxy_info.port, @proxy_info.username, @proxy_info.password)
260
- else
261
- http = Net::HTTP.new(location.host, location.port)
262
- end
263
- if location.scheme == 'https'
264
- #fixed http/http misnaming via JohnMetta
265
- puts "SSL True" if @debug
266
- http.use_ssl = true
267
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
268
- end
269
- return http
270
- end
271
-
272
- def auth_header(header)
273
- if @auth_token
274
- if header
275
- header.merge!({'Authorization' => "GoogleLogin auth=#{@auth_token}", "GData-Version" => "2.1"})
276
- else
277
- header = {'Authorization' => "GoogleLogin auth=#{@auth_token}", "GData-Version" => "2.1"}
278
- end
279
- end
280
- return header
281
- end
282
- end
283
- end