jkarlsson-gdata 1.1.1

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 (46) hide show
  1. data/LICENSE +202 -0
  2. data/README +97 -0
  3. data/Rakefile +64 -0
  4. data/lib/gdata.rb +22 -0
  5. data/lib/gdata/auth.rb +23 -0
  6. data/lib/gdata/auth/authsub.rb +161 -0
  7. data/lib/gdata/auth/clientlogin.rb +102 -0
  8. data/lib/gdata/auth/oauth.rb +129 -0
  9. data/lib/gdata/client.rb +84 -0
  10. data/lib/gdata/client/apps.rb +27 -0
  11. data/lib/gdata/client/base.rb +187 -0
  12. data/lib/gdata/client/blogger.rb +28 -0
  13. data/lib/gdata/client/booksearch.rb +28 -0
  14. data/lib/gdata/client/calendar.rb +58 -0
  15. data/lib/gdata/client/contacts.rb +28 -0
  16. data/lib/gdata/client/doclist.rb +28 -0
  17. data/lib/gdata/client/finance.rb +28 -0
  18. data/lib/gdata/client/gbase.rb +28 -0
  19. data/lib/gdata/client/gmail.rb +28 -0
  20. data/lib/gdata/client/health.rb +28 -0
  21. data/lib/gdata/client/notebook.rb +28 -0
  22. data/lib/gdata/client/photos.rb +29 -0
  23. data/lib/gdata/client/spreadsheets.rb +28 -0
  24. data/lib/gdata/client/webmaster_tools.rb +28 -0
  25. data/lib/gdata/client/youtube.rb +47 -0
  26. data/lib/gdata/http.rb +18 -0
  27. data/lib/gdata/http/default_service.rb +82 -0
  28. data/lib/gdata/http/mime_body.rb +106 -0
  29. data/lib/gdata/http/request.rb +74 -0
  30. data/lib/gdata/http/response.rb +44 -0
  31. data/test/tc_gdata_auth_authsub.rb +53 -0
  32. data/test/tc_gdata_auth_clientlogin.rb +59 -0
  33. data/test/tc_gdata_client_base.rb +37 -0
  34. data/test/tc_gdata_client_calendar.rb +40 -0
  35. data/test/tc_gdata_client_photos.rb +65 -0
  36. data/test/tc_gdata_client_youtube.rb +77 -0
  37. data/test/tc_gdata_http_mime_body.rb +46 -0
  38. data/test/tc_gdata_http_request.rb +36 -0
  39. data/test/test_config.yml.example +7 -0
  40. data/test/test_helper.rb +47 -0
  41. data/test/testimage.jpg +0 -0
  42. data/test/ts_gdata.rb +42 -0
  43. data/test/ts_gdata_auth.rb +25 -0
  44. data/test/ts_gdata_client.rb +29 -0
  45. data/test/ts_gdata_http.rb +25 -0
  46. metadata +111 -0
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Blogger API.
19
+ class Blogger < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'blogger'
23
+ options[:authsub_scope] ||= 'http://www.blogger.com/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Book Search Data API.
19
+ class BookSearch < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'print'
23
+ options[:authsub_scope] ||= 'http://www.google.com/books/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Calendar Data API.
19
+ class Calendar < Base
20
+
21
+ # Holds on to a session cookie
22
+ attr_accessor :session_cookie
23
+
24
+ def initialize(options = {})
25
+ options[:clientlogin_service] ||= 'cl'
26
+ options[:authsub_scope] ||= 'http://www.google.com/calendar/feeds/'
27
+ super(options)
28
+ end
29
+
30
+ # Overrides auth_handler= so if the authentication changes,
31
+ # the session cookie is cleared.
32
+ def auth_handler=(handler)
33
+ @session_cookie = nil
34
+ return super(handler)
35
+ end
36
+
37
+ # Overrides make_request to handle 302 redirects with a session cookie.
38
+ def make_request(method, url, body = '', retries = 4)
39
+ response = super(method, url, body)
40
+ if response.status_code == 302 and retries > 0
41
+ @session_cookie = response.headers['set-cookie']
42
+ return self.make_request(method, url, body,
43
+ retries - 1)
44
+ else
45
+ return response
46
+ end
47
+ end
48
+
49
+ # Custom prepare_headers to include the session cookie if it exists
50
+ def prepare_headers
51
+ if @session_cookie
52
+ @headers['cookie'] = @session_cookie
53
+ end
54
+ super
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Contacts API.
19
+ class Contacts < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'cp'
23
+ options[:authsub_scope] ||= 'http://www.google.com/m8/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Documents List Data API.
19
+ class DocList < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'writely'
23
+ options[:authsub_scope] ||= 'http://docs.google.com/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Finance API.
19
+ class Finance < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'finance'
23
+ options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Google Base API.
19
+ class GBase < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'gbase'
23
+ options[:authsub_scope] ||= 'http://www.google.com/base/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the GMail Atom Feed.
19
+ class GMail < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'mail'
23
+ options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Health API.
19
+ class Health < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'health'
23
+ options[:authsub_scope] ||= 'https://www.google.com/health/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Notebook Data API.
19
+ class Notebook < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'notebook'
23
+ options[:authsub_scope] ||= 'http://www.google.com/notebook/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Picasa Web Albums API.
19
+ class Photos < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'lh2'
23
+ options[:authsub_scope] ||= 'http://picasaweb.google.com/data/'
24
+ options[:version] ||= '1'
25
+ super(options)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Spreadsheets API.
19
+ class Spreadsheets < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'wise'
23
+ options[:authsub_scope] ||= 'http://spreadsheets.google.com/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the Webmaster Tools API.
19
+ class WebmasterTools < Base
20
+
21
+ def initialize(options = {})
22
+ options[:clientlogin_service] ||= 'sitemaps'
23
+ options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/'
24
+ super(options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module GData
16
+ module Client
17
+
18
+ # Client class to wrap working with the YouTube API. Sets some
19
+ # YouTube-specific options.
20
+ class YouTube < Base
21
+
22
+ # The YouTube developer key being used.
23
+ attr_accessor :developer_key
24
+ # The YouTube ClientID being used.
25
+ attr_accessor :client_id
26
+
27
+ def initialize(options = {})
28
+ options[:clientlogin_service] ||= 'youtube'
29
+ options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin'
30
+ options[:authsub_scope] ||= 'http://gdata.youtube.com'
31
+ options[:version] ||= '2'
32
+ super(options)
33
+ end
34
+
35
+ # Custom prepare_headers to include the developer key and clientID
36
+ def prepare_headers
37
+ if @client_id
38
+ @headers['X-GData-Client'] = @client_id
39
+ end
40
+ if @developer_key
41
+ @headers['X-GData-Key'] = "key=#{@developer_key}"
42
+ end
43
+ super
44
+ end
45
+ end
46
+ end
47
+ end