├── VERSION ├── .gitignore ├── doc ├── created.rid ├── index.html └── classes │ └── GData │ ├── HTTP │ ├── MimeBody.src │ │ ├── M000034.html │ │ ├── M000038.html │ │ ├── M000032.html │ │ ├── M000035.html │ │ ├── M000036.html │ │ ├── M000033.html │ │ └── M000037.html │ ├── MimeBodyString.src │ │ ├── M000036.html │ │ ├── M000039.html │ │ ├── M000040.html │ │ ├── M000037.html │ │ └── M000041.html │ ├── Request.src │ │ ├── M000016.html │ │ ├── M000034.html │ │ ├── M000039.html │ │ ├── M000043.html │ │ ├── M000017.html │ │ ├── M000035.html │ │ ├── M000040.html │ │ ├── M000044.html │ │ ├── M000015.html │ │ ├── M000018.html │ │ ├── M000033.html │ │ ├── M000038.html │ │ ├── M000041.html │ │ ├── M000042.html │ │ ├── M000036.html │ │ └── M000045.html │ └── Response.src │ │ ├── M000032.html │ │ ├── M000035.html │ │ ├── M000038.html │ │ └── M000039.html │ ├── Client │ ├── Base.src │ │ ├── M000004.html │ │ ├── M000015.html │ │ ├── M000007.html │ │ ├── M000020.html │ │ ├── M000016.html │ │ ├── M000005.html │ │ ├── M000006.html │ │ ├── M000018.html │ │ ├── M000024.html │ │ ├── M000017.html │ │ ├── M000019.html │ │ ├── M000002.html │ │ ├── M000025.html │ │ ├── M000008.html │ │ ├── M000010.html │ │ ├── M000023.html │ │ ├── M000011.html │ │ ├── M000012.html │ │ └── M000021.html │ ├── CaptchaError.src │ │ ├── M000001.html │ │ └── M000005.html │ ├── Calendar.src │ │ ├── M000032.html │ │ ├── M000034.html │ │ ├── M000030.html │ │ ├── M000031.html │ │ └── M000033.html │ ├── RequestError.src │ │ └── M000006.html │ ├── Apps.src │ │ ├── M000027.html │ │ └── M000028.html │ ├── YouTube.src │ │ ├── M000013.html │ │ ├── M000014.html │ │ ├── M000027.html │ │ ├── M000025.html │ │ └── M000026.html │ ├── GBase.src │ │ └── M000004.html │ ├── Blogger.src │ │ └── M000002.html │ ├── Contacts.src │ │ └── M000003.html │ ├── DocList.src │ │ ├── M000006.html │ │ └── M000007.html │ ├── GMail.src │ │ ├── M000028.html │ │ └── M000029.html │ ├── Health.src │ │ ├── M000031.html │ │ ├── M000034.html │ │ └── M000035.html │ ├── BookSearch.src │ │ ├── M000010.html │ │ └── M000011.html │ ├── Finance.src │ │ ├── M000029.html │ │ └── M000030.html │ ├── Notebook.src │ │ ├── M000009.html │ │ └── M000010.html │ ├── Spreadsheets.src │ │ └── M000001.html │ ├── WebmasterTools.src │ │ ├── M000007.html │ │ └── M000008.html │ └── Photos.src │ │ ├── M000008.html │ │ └── M000009.html │ └── Auth │ ├── ClientLogin.src │ ├── M000029.html │ ├── M000047.html │ ├── M000052.html │ ├── M000056.html │ ├── M000027.html │ ├── M000045.html │ ├── M000050.html │ ├── M000053.html │ └── M000054.html │ └── AuthSub.src │ ├── M000038.html │ ├── M000043.html │ ├── M000046.html │ ├── M000047.html │ ├── M000052.html │ ├── M000025.html │ ├── M000020.html │ └── M000050.html ├── test ├── testimage.jpg ├── test_config.yml.example ├── ts_gdata_http.rb ├── ts_gdata_auth.rb ├── ts_gdata_client.rb ├── tc_gdata_http_request.rb ├── tc_gdata_client_base.rb ├── tc_gdata_client_calendar.rb ├── test_helper.rb ├── ts_gdata.rb ├── tc_gdata_http_mime_body.rb ├── tc_gdata_auth_authsub.rb ├── tc_gdata_auth_clientlogin.rb └── tc_gdata_client_photos.rb ├── pkg ├── gdata_19-1.1.2.gem └── gdata_19-1.1.3.gem ├── .hgtags ├── NEWS.md ├── lib ├── gdata │ ├── http.rb │ ├── auth.rb │ ├── client │ │ ├── apps.rb │ │ ├── blogger.rb │ │ ├── contacts.rb │ │ ├── gbase.rb │ │ ├── gmail.rb │ │ ├── health.rb │ │ ├── finance.rb │ │ ├── notebook.rb │ │ ├── doclist.rb │ │ ├── analytics.rb │ │ ├── booksearch.rb │ │ ├── spreadsheets.rb │ │ ├── webmaster_tools.rb │ │ ├── photos.rb │ │ ├── youtube.rb │ │ └── calendar.rb │ ├── http │ │ ├── response.rb │ │ └── request.rb │ └── client.rb └── gdata.rb └── bin └── test_captcha.rb /VERSION: -------------------------------------------------------------------------------- 1 | 1.1.3 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/test_config.yml -------------------------------------------------------------------------------- /doc/created.rid: -------------------------------------------------------------------------------- 1 | Tue, 28 Apr 2009 12:36:57 -0700 2 | -------------------------------------------------------------------------------- /test/testimage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokumine/GData/HEAD/test/testimage.jpg -------------------------------------------------------------------------------- /pkg/gdata_19-1.1.2.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokumine/GData/HEAD/pkg/gdata_19-1.1.2.gem -------------------------------------------------------------------------------- /pkg/gdata_19-1.1.3.gem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokumine/GData/HEAD/pkg/gdata_19-1.1.3.gem -------------------------------------------------------------------------------- /test/test_config.yml.example: -------------------------------------------------------------------------------- 1 | --- 2 | username: myaccount 3 | password: mypassword 4 | # uncomment to test authsub 5 | #authsub_token: someauthsubtoken 6 | # uncomment to test secure authsub 7 | #authsub_private_key: /path/to/private/key 8 | -------------------------------------------------------------------------------- /.hgtags: -------------------------------------------------------------------------------- 1 | 2779e734e0f05be07a6723b614a1a3b134a1afc3 1.1.0 2 | 4359456026eae63f0cfa1a494fdb285098f1b675 1.0.0 3 | dc919b092f8f1a7e30f03812601f9d0394d4c808 0.0.1 4 | e12689fd2570f176d954aa0b5be63f164c58cb50 1.0.1 5 | 93890a03f97a199331ff9bb940ea32db13ebcb8f 1.1.1 6 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | 1.1.4 2 | ----- 3 | 4 | * Add support of remote file to GData - (Florian95 / Florian LAMACHE) 5 | * Support access via proxy set via ENV['https_proxy'] or ENV['http_proxy'] - (tdtds / TADA Tadashi) 6 | * Add Google Analytics client - (tdtds / TADA Tadashi) -------------------------------------------------------------------------------- /lib/gdata/http.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | require 'gdata/http/default_service' 17 | require 'gdata/http/mime_body' 18 | require 'gdata/http/request' 19 | require 'gdata/http/response' 20 | -------------------------------------------------------------------------------- /lib/gdata/auth.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | require 'gdata/auth/clientlogin' 17 | require 'gdata/auth/authsub' 18 | 19 | module GData 20 | module Auth 21 | SOURCE_LIB_STRING = 'GoogleDataRubyUtil-' 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 |
13 |# File lib/gdata/http/mime_body.rb, line 54 14 | def content_type 15 | return "multipart/related; boundary=\"#{@boundary}\"" 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000038.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 54 14 | def content_type 15 | return "multipart/related; boundary=\"#{@boundary}\"" 16 | end17 | 18 | -------------------------------------------------------------------------------- /lib/gdata/client/apps.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Apps Provisioning API. 20 | class Apps < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'apps' 24 | super(options) 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000004.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 101 14 | def get(url) 15 | return self.make_request(:get, url) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000015.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 102 14 | def get(url) 15 | return self.make_request(:get, url) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBodyString.src/M000036.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 75 14 | def initialize(source_string) 15 | @string = source_string 16 | @bytes_read = 0 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBodyString.src/M000039.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 75 14 | def initialize(source_string) 15 | @string = source_string 16 | @bytes_read = 0 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBodyString.src/M000040.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 75 14 | def initialize(source_string) 15 | @string = source_string 16 | @bytes_read = 0 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000007.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 116 14 | def delete(url) 15 | return self.make_request(:delete, url) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000020.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 127 14 | def delete(url) 15 | return self.make_request(:delete, url) 16 | end17 | 18 | -------------------------------------------------------------------------------- /lib/gdata/client/blogger.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Blogger API. 20 | class Blogger < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'blogger' 24 | options[:authsub_scope] ||= 'http://www.blogger.com/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/contacts.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Contacts API. 20 | class Contacts < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'cp' 24 | options[:authsub_scope] ||= 'https://www.google.com/m8/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/CaptchaError.src/M000001.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client.rb, line 33 14 | def initialize(token, url) 15 | @token = token 16 | @url = url 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/CaptchaError.src/M000005.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client.rb, line 68 14 | def initialize(token, url) 15 | @token = token 16 | @url = url 17 | end18 | 19 | -------------------------------------------------------------------------------- /lib/gdata/client/gbase.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Google Base API. 20 | class GBase < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'gbase' 24 | options[:authsub_scope] ||= 'https://www.google.com/base/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/gmail.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the GMail Atom Feed. 20 | class GMail < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'mail' 24 | options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/health.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Health API. 20 | class Health < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'health' 24 | options[:authsub_scope] ||= 'https://www.google.com/health/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/finance.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Finance API. 20 | class Finance < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'finance' 24 | options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/notebook.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Notebook Data API. 20 | class Notebook < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'notebook' 24 | options[:authsub_scope] ||= 'https://www.google.com/notebook/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/doclist.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Documents List Data API. 20 | class DocList < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'writely' 24 | options[:authsub_scope] ||= 'https://docs.google.com/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/analytics.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Analytics API. 20 | class Analytics < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'analytics' 24 | options[:authsub_scope] ||= 'https://www.google.com/analytics/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/booksearch.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Book Search Data API. 20 | class BookSearch < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'print' 24 | options[:authsub_scope] ||= 'https://www.google.com/books/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/spreadsheets.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Spreadsheets API. 20 | class Spreadsheets < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'wise' 24 | options[:authsub_scope] ||= 'https://spreadsheets.google.com/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Calendar.src/M000032.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/calendar.rb, line 32 14 | def auth_handler=(handler) 15 | @session_cookie = nil 16 | return super(handler) 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/RequestError.src/M000006.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client.rb, line 47 14 | def initialize(response) 15 | @response = response 16 | 17 | super "request error #{response.status_code}: #{response.body}" 18 | end19 | 20 | -------------------------------------------------------------------------------- /lib/gdata/client/webmaster_tools.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Webmaster Tools API. 20 | class WebmasterTools < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'sitemaps' 24 | options[:authsub_scope] ||= 'https://www.google.com/webmasters/tools/feeds/' 25 | super(options) 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/gdata/client/photos.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Picasa Web Albums API. 20 | class Photos < Base 21 | 22 | def initialize(options = {}) 23 | options[:clientlogin_service] ||= 'lh2' 24 | options[:authsub_scope] ||= 'https://picasaweb.google.com/data/' 25 | options[:version] ||= '1' 26 | super(options) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /test/ts_gdata_client.rb: -------------------------------------------------------------------------------- 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 | require 'tc_gdata_client_base' 16 | require 'tc_gdata_client_calendar' 17 | require 'tc_gdata_client_photos' 18 | require 'tc_gdata_client_youtube' 19 | 20 | class TS_GData_Client 21 | def self.suite 22 | suite = Test::Unit::TestSuite.new 23 | suite << TC_GData_Client_Base.suite 24 | suite << TC_GData_Client_Calendar.suite 25 | suite << TC_GData_Client_Photos.suite 26 | suite << TC_GData_Client_YouTube.suite 27 | return suite 28 | end 29 | end -------------------------------------------------------------------------------- /doc/classes/GData/Client/Apps.src/M000027.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/apps.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'apps' 16 | super(options) 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Apps.src/M000028.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/apps.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'apps' 16 | super(options) 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000016.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 107 14 | def put(url, body) 15 | return self.make_request(:put, url, body) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000005.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 106 14 | def put(url, body) 15 | return self.make_request(:put, url, body) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000006.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 111 14 | def post(url, body) 15 | return self.make_request(:post, url, body) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000018.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 117 14 | def post(url, body) 15 | return self.make_request(:post, url, body) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/YouTube.src/M000013.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/youtube.rb, line 33 14 | def initialize(options = {}) 15 | options = DEFAULT_OPTIONS.merge(options) 16 | super(options) 17 | end18 | 19 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Calendar.src/M000034.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/calendar.rb, line 50 14 | def prepare_headers 15 | if @session_cookie 16 | @headers['cookie'] = @session_cookie 17 | end 18 | super 19 | end20 | 21 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000024.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 168 14 | def authsub_token=(token) 15 | self.auth_handler = GData::Auth::AuthSub.new(token) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000016.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 46 14 | def chunked? 15 | if @headers['Transfer-Encoding'] == 'chunked' 16 | return true 17 | else 18 | return false 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000034.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 43 14 | def chunked? 15 | if @headers['Transfer-Encoding'] == 'chunked' 16 | return true 17 | else 18 | return false 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000039.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 43 14 | def chunked? 15 | if @headers['Transfer-Encoding'] == 'chunked' 16 | return true 17 | else 18 | return false 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000043.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 44 14 | def chunked? 15 | if @headers['Transfer-Encoding'] == 'chunked' 16 | return true 17 | else 18 | return false 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000017.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 55 14 | def chunked=(enabled) 15 | if enabled 16 | @headers['Transfer-Encoding'] = 'chunked' 17 | else 18 | @headers.delete('Transfer-Encoding') 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000035.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 52 14 | def chunked=(enabled) 15 | if enabled 16 | @headers['Transfer-Encoding'] = 'chunked' 17 | else 18 | @headers.delete('Transfer-Encoding') 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000040.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 52 14 | def chunked=(enabled) 15 | if enabled 16 | @headers['Transfer-Encoding'] = 'chunked' 17 | else 18 | @headers.delete('Transfer-Encoding') 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000044.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 53 14 | def chunked=(enabled) 15 | if enabled 16 | @headers['Transfer-Encoding'] = 'chunked' 17 | else 18 | @headers.delete('Transfer-Encoding') 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/GBase.src/M000004.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gbase.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'gbase' 16 | options[:authsub_scope] ||= 'http://www.google.com/base/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Blogger.src/M000002.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/blogger.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'blogger' 16 | options[:authsub_scope] ||= 'http://www.blogger.com/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Contacts.src/M000003.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/contacts.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'cp' 16 | options[:authsub_scope] ||= 'http://www.google.com/m8/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/DocList.src/M000006.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/doclist.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'writely' 16 | options[:authsub_scope] ||= 'http://docs.google.com/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/DocList.src/M000007.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/doclist.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'writely' 16 | options[:authsub_scope] ||= 'http://docs.google.com/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/GMail.src/M000028.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gmail.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'mail' 16 | options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/GMail.src/M000029.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gmail.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'mail' 16 | options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Health.src/M000031.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/health.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'health' 16 | options[:authsub_scope] ||= 'https://www.google.com/health/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Health.src/M000034.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/health.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'health' 16 | options[:authsub_scope] ||= 'https://www.google.com/health/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Health.src/M000035.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/health.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'health' 16 | options[:authsub_scope] ||= 'https://www.google.com/health/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Calendar.src/M000030.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/calendar.rb, line 24 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'cl' 16 | options[:authsub_scope] ||= 'http://www.google.com/calendar/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Calendar.src/M000031.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/calendar.rb, line 24 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'cl' 16 | options[:authsub_scope] ||= 'http://www.google.com/calendar/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/BookSearch.src/M000010.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/booksearch.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'print' 16 | options[:authsub_scope] ||= 'http://www.google.com/books/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/BookSearch.src/M000011.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/booksearch.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'print' 16 | options[:authsub_scope] ||= 'http://www.google.com/books/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Finance.src/M000029.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/finance.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'finance' 16 | options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Finance.src/M000030.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/finance.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'finance' 16 | options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Notebook.src/M000009.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/notebook.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'notebook' 16 | options[:authsub_scope] ||= 'http://www.google.com/notebook/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Notebook.src/M000010.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/notebook.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'notebook' 16 | options[:authsub_scope] ||= 'http://www.google.com/notebook/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Spreadsheets.src/M000001.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/spreadsheets.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'wise' 16 | options[:authsub_scope] ||= 'http://spreadsheets.google.com/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000017.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 112 14 | def put_file(url, file_path, mime_type, entry = nil) 15 | return self.make_file_request(:put, url, file_path, mime_type, entry) 16 | end17 | 18 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000019.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 122 14 | def post_file(url, file_path, mime_type, entry = nil) 15 | return self.make_file_request(:post, url, file_path, mime_type, entry) 16 | end17 | 18 | -------------------------------------------------------------------------------- /test/tc_gdata_http_request.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_HTTP_Request < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def test_world_is_sane 23 | assert(true, 'World is not sane.') 24 | end 25 | 26 | def test_google_is_live 27 | request = GData::HTTP::Request.new('http://www.google.com') 28 | 29 | service = GData::HTTP::DefaultService.new 30 | 31 | response = service.make_request(request) 32 | 33 | # Google responds with 302 temporary redirect if 34 | # client IP address is not in the US 35 | # http://www.google.com/support/websearch/bin/answer.py?answer=873 36 | assert [200, 302].include?(response.status_code) 37 | end 38 | 39 | end -------------------------------------------------------------------------------- /doc/classes/GData/Client/WebmasterTools.src/M000007.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/webmaster_tools.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'sitemaps' 16 | options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/WebmasterTools.src/M000008.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/webmaster_tools.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'sitemaps' 16 | options[:authsub_scope] ||= 'http://www.google.com/webmasters/tools/feeds/' 17 | super(options) 18 | end19 | 20 | -------------------------------------------------------------------------------- /test/tc_gdata_client_base.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_Client_Base < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def test_simple_gdata_get 23 | service = GData::Client::Base.new 24 | feed = service.get('http://gdata.youtube.com/feeds/base/videos?max-results=1').to_xml 25 | assert_not_nil(feed, 'feed can not be nil') 26 | end 27 | 28 | def test_clientlogin_with_service 29 | service = GData::Client::Base.new 30 | service.clientlogin(self.get_username(), self.get_password(), nil, nil, 31 | 'youtube') 32 | feed = service.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1').to_xml 33 | assert_not_nil(feed, 'feed can not be nil') 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/YouTube.src/M000014.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/youtube.rb, line 38 14 | def prepare_headers 15 | if @client_id 16 | @headers['X-GData-Client'] = @client_id 17 | end 18 | if @developer_key 19 | @headers['X-GData-Key'] = "key=#{@developer_key}" 20 | end 21 | super 22 | end23 | 24 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/YouTube.src/M000027.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/youtube.rb, line 36 14 | def prepare_headers 15 | if @client_id 16 | @headers['X-GData-Client'] = @client_id 17 | end 18 | if @developer_key 19 | @headers['X-GData-Key'] = "key=#{@developer_key}" 20 | end 21 | super 22 | end23 | 24 | -------------------------------------------------------------------------------- /lib/gdata/http/response.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | require 'gdata/client' 17 | 18 | module GData 19 | module HTTP 20 | 21 | # An extremely simple class to hold the values of an HTTP response. 22 | class Response 23 | 24 | # The HTTP response code. 25 | attr_accessor :status_code 26 | # The body of the HTTP response. 27 | attr_accessor :body 28 | # The headers of the HTTP response. 29 | attr_accessor :headers 30 | 31 | # Converts the response body into a REXML::Document 32 | def to_xml 33 | if @body 34 | begin 35 | return REXML::Document.new(@body).root 36 | rescue 37 | raise GData::Client::Error, "Response body not XML." 38 | end 39 | else 40 | return nil 41 | end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000029.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 93 14 | def sign_request!(request) 15 | if @token == nil 16 | raise RuntimeError, "Cannot sign request without credentials" 17 | end 18 | 19 | request.headers['Authorization'] = "GoogleLogin auth=#{@token}" 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000047.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 93 14 | def sign_request!(request) 15 | if @token == nil 16 | raise RuntimeError, "Cannot sign request without credentials" 17 | end 18 | 19 | request.headers['Authorization'] = "GoogleLogin auth=#{@token}" 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000052.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 93 14 | def sign_request!(request) 15 | if @token == nil 16 | raise RuntimeError, "Cannot sign request without credentials" 17 | end 18 | 19 | request.headers['Authorization'] = "GoogleLogin auth=#{@token}" 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Photos.src/M000008.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/photos.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'lh2' 16 | options[:authsub_scope] ||= 'http://picasaweb.google.com/data/' 17 | options[:version] ||= '1' 18 | super(options) 19 | end20 | 21 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Photos.src/M000009.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/photos.rb, line 21 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'lh2' 16 | options[:authsub_scope] ||= 'http://picasaweb.google.com/data/' 17 | options[:version] ||= '1' 18 | super(options) 19 | end20 | 21 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000002.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 51 14 | def initialize(options = {}) 15 | options = DEFAULT_OPTIONS.merge(options) 16 | options.each do |key, value| 17 | self.send("#{key}=", value) 18 | end 19 | end20 | 21 | -------------------------------------------------------------------------------- /test/tc_gdata_client_calendar.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_Client_Calendar < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def setup 23 | @cl = GData::Client::Calendar.new 24 | @cl.clientlogin(self.get_username, self.get_password) 25 | end 26 | 27 | def test_get_all_calendars 28 | response = @cl.get('http://www.google.com/calendar/feeds/default/allcalendars/full') 29 | self.assert_equal(200, response.status_code, 'Must not be a redirect.') 30 | self.assert_not_nil(@cl.session_cookie, 'Must have a session cookie.') 31 | feed = response.to_xml 32 | self.assert_not_nil(feed, 'feed can not be nil') 33 | 34 | #login again to make sure the session cookie gets cleared 35 | @cl.clientlogin(self.get_username, self.get_password) 36 | self.assert_nil(@cl.session_cookie, 'Should clear session cookie.') 37 | end 38 | 39 | 40 | end -------------------------------------------------------------------------------- /bin/test_captcha.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | # 3 | # Copyright (C) 2008 Google Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | $:.unshift(File.dirname(__FILE__)) 18 | 19 | require '../lib/gdata' 20 | 21 | 22 | 23 | def trigger_captcha 24 | client_login = GData::Auth::ClientLogin.new('cl') 25 | username = '' 26 | source = '' 27 | begin 28 | (1..50).each do |i| 29 | begin 30 | client_login.get_token(username, "junk#{i}", source) 31 | rescue GData::Client::AuthorizationError 32 | end 33 | end 34 | rescue GData::Client::CaptchaError => detail 35 | print "Token: #{detail.token}\n" 36 | print "http://www.google.com/accounts/#{detail.url}" 37 | end 38 | end 39 | 40 | def test_captcha_response 41 | client_login = GData::Auth::ClientLogin.new('cl') 42 | username = '' 43 | password = '' 44 | token = '' 45 | captcha_answer = '' 46 | source = '' 47 | token = client_login.get_token(username, password, source, token, captcha_answer) 48 | print token, "\n" 49 | end 50 | 51 | #trigger_captcha 52 | #test_captcha_response -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 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 | require 'yaml' 16 | 17 | # Test::Unit is no longer in standard lib 18 | if RUBY_VERSION >= '1.9.1' 19 | require 'rubygems' 20 | require 'test/unit' # gem install test-unit 21 | else 22 | require 'test/unit' 23 | require 'test/unit/ui/console/testrunner' 24 | end 25 | 26 | $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') 27 | require 'gdata' 28 | 29 | module TestHelper 30 | 31 | def get_config() 32 | if not defined?(@config_file) 33 | @config_file = YAML::load_file(File.join(File.dirname(__FILE__), 'test_config.yml')) 34 | end 35 | return @config_file 36 | end 37 | 38 | def get_username() 39 | return self.get_config()['username'] 40 | end 41 | 42 | def get_password() 43 | return self.get_config()['password'] 44 | end 45 | 46 | def get_authsub_token() 47 | return self.get_config()['authsub_token'] 48 | end 49 | 50 | def get_authsub_private_key() 51 | return self.get_config()['authsub_private_key'] 52 | end 53 | 54 | end 55 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000056.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 93 14 | def sign_request!(request) 15 | if @token == nil 16 | raise GData::Client::Error, "Cannot sign request without credentials" 17 | end 18 | 19 | request.headers['Authorization'] = "GoogleLogin auth=#{@token}" 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Response.src/M000032.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/response.rb, line 28 14 | def to_xml 15 | if @body 16 | begin 17 | return REXML::Document.new(@body).root 18 | rescue 19 | return nil 20 | end 21 | else 22 | return nil 23 | end 24 | end25 | 26 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000025.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 173 14 | def authsub_private_key=(key) 15 | if @auth_handler.class == GData::Auth::AuthSub 16 | @auth_handler.private_key = key 17 | else 18 | raise Error, "An AuthSub token must be set first." 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000015.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 37 14 | def initialize(url, options = {}) 15 | @url = url 16 | options = DEFAULT_OPTIONS.merge(options) 17 | options.each do |key, value| 18 | self.send("#{key}=", value) 19 | end 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000008.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 121 14 | def prepare_headers 15 | headers = @headers 16 | headers['GData-Version'] = @version 17 | headers['User-Agent'] = GData::Auth::SOURCE_LIB_STRING + @source 18 | headers['Content-Type'] = 'application/atom+xml' 19 | return headers 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000018.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 64 14 | def calculate_length! 15 | if not @headers['Content-Length'] and not chunked? 16 | if @body 17 | @headers['Content-Length'] = @body.length 18 | else 19 | @headers['Content-Length'] = 0 20 | end 21 | end 22 | end23 | 24 | -------------------------------------------------------------------------------- /test/ts_gdata.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | $:.unshift(File.dirname(__FILE__)) 17 | require 'test_helper' 18 | require 'ts_gdata_http' 19 | require 'ts_gdata_client' 20 | require 'ts_gdata_auth' 21 | 22 | class TS_GData 23 | def self.suite 24 | suite = Test::Unit::TestSuite.new("GData Test Suite") 25 | suite << UnicodeStringTest.suite 26 | suite << TS_GData_HTTP.suite 27 | suite << TS_GData_Client.suite 28 | suite << TS_GData_Auth.suite 29 | return suite 30 | end 31 | end 32 | 33 | class UnicodeStringTest < Test::Unit::TestCase 34 | def test_jlength 35 | s = "Καλημέρα κόσμε!" 36 | if RUBY_VERSION < '1.9' 37 | assert_equal(15, s.jlength) # Note the 'j' 38 | assert_not_equal(15, s.length) # Normal, non unicode length 39 | assert_equal(28, s.length) # Greek letters happen to take two-bytes 40 | else 41 | assert_equal(15, s.length) # Normal, non unicode length 42 | assert_equal(28, s.bytesize) # Greek letters happen to take two-bytes 43 | end 44 | end 45 | end 46 | 47 | 48 | #Test::Unit::UI::Console::TestRunner.run(TS_GData) 49 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Response.src/M000035.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/response.rb, line 29 14 | def to_xml 15 | if @body 16 | begin 17 | return REXML::Document.new(@body).root 18 | rescue 19 | raise RuntimeError, "Response body not XML." 20 | end 21 | else 22 | return nil 23 | end 24 | end25 | 26 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Response.src/M000038.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/response.rb, line 29 14 | def to_xml 15 | if @body 16 | begin 17 | return REXML::Document.new(@body).root 18 | rescue 19 | raise RuntimeError, "Response body not XML." 20 | end 21 | else 22 | return nil 23 | end 24 | end25 | 26 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000033.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 32 14 | def initialize(url, options = {}) 15 | @url = url 16 | options.each do |key, value| 17 | self.send("#{key}=", value) 18 | end 19 | 20 | @method ||= :get 21 | @headers ||= {} 22 | end23 | 24 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000038.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 32 14 | def initialize(url, options = {}) 15 | @url = url 16 | options.each do |key, value| 17 | self.send("#{key}=", value) 18 | end 19 | 20 | @method ||= :get 21 | @headers ||= {} 22 | end23 | 24 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000041.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 33 14 | def initialize(url, options = {}) 15 | @url = url 16 | options.each do |key, value| 17 | self.send("#{key}=", value) 18 | end 19 | 20 | @method ||= :get 21 | @headers ||= {} 22 | end23 | 24 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000042.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 33 14 | def initialize(url, options = {}) 15 | @url = url 16 | options.each do |key, value| 17 | self.send("#{key}=", value) 18 | end 19 | 20 | @method ||= :get 21 | @headers ||= {} 22 | end23 | 24 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000032.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 27 14 | def initialize(entry, file, file_mime_type) 15 | @boundary = "END_OF_PART_#{rand(64000)}" 16 | entry = wrap_entry(entry, file_mime_type) 17 | closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--") 18 | @parts = [entry, file, closing_boundary] 19 | @current_part = 0 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000035.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 27 14 | def initialize(entry, file, file_mime_type) 15 | @boundary = "END_OF_PART_#{rand(64000)}" 16 | entry = wrap_entry(entry, file_mime_type) 17 | closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--") 18 | @parts = [entry, file, closing_boundary] 19 | @current_part = 0 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000036.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 27 14 | def initialize(entry, file, file_mime_type) 15 | @boundary = "END_OF_PART_#{rand(64000)}" 16 | entry = wrap_entry(entry, file_mime_type) 17 | closing_boundary = MimeBodyString.new("\r\n--#{@boundary}--") 18 | @parts = [entry, file, closing_boundary] 19 | @current_part = 0 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/YouTube.src/M000025.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/youtube.rb, line 27 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'youtube' 16 | options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin' 17 | options[:authsub_scope] ||= 'http://gdata.youtube.com' 18 | options[:version] ||= '2' 19 | super(options) 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/YouTube.src/M000026.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/youtube.rb, line 27 14 | def initialize(options = {}) 15 | options[:clientlogin_service] ||= 'youtube' 16 | options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin' 17 | options[:authsub_scope] ||= 'http://gdata.youtube.com' 18 | options[:version] ||= '2' 19 | super(options) 20 | end21 | 22 | -------------------------------------------------------------------------------- /lib/gdata/client/youtube.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the YouTube API. Sets some 20 | # YouTube-specific options. 21 | class YouTube < Base 22 | 23 | # The YouTube developer key being used. 24 | attr_accessor :developer_key 25 | # The YouTube ClientID being used. 26 | attr_accessor :client_id 27 | 28 | def initialize(options = {}) 29 | options[:clientlogin_service] ||= 'youtube' 30 | options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin' 31 | options[:authsub_scope] ||= 'http://gdata.youtube.com' 32 | options[:version] ||= '2' 33 | super(options) 34 | end 35 | 36 | # Custom prepare_headers to include the developer key and clientID 37 | def prepare_headers 38 | if @client_id 39 | @headers['X-GData-Client'] = @client_id 40 | end 41 | if @developer_key 42 | @headers['X-GData-Key'] = "key=#{@developer_key}" 43 | end 44 | super 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /test/tc_gdata_http_mime_body.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | $:.unshift(File.dirname(__FILE__)) 17 | require 'test_helper' 18 | 19 | class TC_GData_HTTP_MimeBody < Test::Unit::TestCase 20 | 21 | include TestHelper 22 | 23 | def test_mime_body_string 24 | stream = GData::HTTP::MimeBodyString.new('testing 1 2 3') 25 | 26 | self.assert_equal('t', stream.read(1)) 27 | self.assert_equal('esting', stream.read(6)) 28 | self.assert_equal(' 1 2 ', stream.read(5)) 29 | self.assert_equal('3', stream.read(50)) 30 | self.assert_equal(false, stream.read(10)) 31 | end 32 | 33 | def test_mime_body_string_large_read 34 | stream = GData::HTTP::MimeBodyString.new('test string') 35 | 36 | self.assert_equal('test string', stream.read(1024)) 37 | self.assert_equal(false, stream.read(1024)) 38 | end 39 | 40 | def test_mime_body_string_unicode 41 | stream = GData::HTTP::MimeBodyString.new('λ') 42 | self.assert(stream.read(1), 'Greek character should be two bytes') 43 | self.assert(stream.read(1), 'Greek character should be two full bytes') 44 | self.assert_equal(false, stream.read(1)) 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Response.src/M000039.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/response.rb, line 31 14 | def to_xml 15 | if @body 16 | begin 17 | return REXML::Document.new(@body).root 18 | rescue 19 | raise GData::Client::Error, "Response body not XML." 20 | end 21 | else 22 | return nil 23 | end 24 | end25 | 26 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000010.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/gdata.rb, line 142 14 | def authsub_url(next_url, secure = false, session = true, domain = nil, 15 | scope = nil) 16 | if scope.nil? 17 | scope = @authsub_scope 18 | end 19 | GData::Auth::AuthSub.get_url(next_url, scope, secure, session, domain) 20 | end21 | 22 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000023.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 159 14 | def authsub_url(next_url, secure = false, session = true, domain = nil, 15 | scope = nil) 16 | if scope.nil? 17 | scope = @authsub_scope 18 | end 19 | GData::Auth::AuthSub.get_url(next_url, scope, secure, session, domain) 20 | end21 | 22 | -------------------------------------------------------------------------------- /test/tc_gdata_auth_authsub.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_Auth_AuthSub < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def test_make_authenticated_request 23 | token = self.get_authsub_token() 24 | key = self.get_authsub_private_key() 25 | service = GData::Client::YouTube.new 26 | if token 27 | 28 | service.authsub_token = token 29 | if key 30 | service.authsub_private_key = key 31 | end 32 | 33 | feed = service.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1') 34 | self.assert_not_nil(feed, 'Feed should not be nil') 35 | end 36 | end 37 | 38 | def test_generate_url 39 | scope = 'http://gdata.youtube.com' 40 | next_url = 'http://example.com' 41 | secure = true 42 | session = false 43 | url = GData::Auth::AuthSub.get_url(next_url, scope, secure, session) 44 | self.assert_equal('https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fexample.com&scope=http%3A%2F%2Fgdata.youtube.com&session=0&secure=1', url) 45 | 46 | # test generating with a pre-populated scope 47 | yt = GData::Client::YouTube.new 48 | client_url = yt.authsub_url(next_url, secure, session) 49 | self.assert_equal(url, client_url) 50 | 51 | end 52 | 53 | end -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000011.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 39 14 | def initialize(options = {}) 15 | options.each do |key, value| 16 | self.send("#{key}=", value) 17 | end 18 | 19 | @headers ||= {} 20 | @http_service ||= GData::HTTP::DefaultService 21 | @version ||= '2' 22 | @source ||= 'AnonymousApp' 23 | end24 | 25 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000012.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 39 14 | def initialize(options = {}) 15 | options.each do |key, value| 16 | self.send("#{key}=", value) 17 | end 18 | 19 | @headers ||= {} 20 | @http_service ||= GData::HTTP::DefaultService 21 | @version ||= '2' 22 | @source ||= 'AnonymousApp' 23 | end24 | 25 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000036.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 61 14 | def calculate_length! 15 | if not @headers['Content-Length'] and not chunked? \ 16 | and method != :get and method != :delete 17 | if @body 18 | @headers['Content-Length'] = @body.length 19 | else 20 | @headers['Content-Length'] = 0 21 | end 22 | end 23 | end24 | 25 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/Request.src/M000045.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/request.rb, line 62 14 | def calculate_length! 15 | if not @headers['Content-Length'] and not chunked? \ 16 | and method != :get and method != :delete 17 | if @body 18 | @headers['Content-Length'] = @body.length 19 | else 20 | @headers['Content-Length'] = 0 21 | end 22 | end 23 | end24 | 25 | -------------------------------------------------------------------------------- /test/tc_gdata_auth_clientlogin.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_Auth_ClientLogin < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def test_has_config 23 | self.assert_not_nil(self.get_username(), 24 | 'Must have a username in test_config.yml') 25 | self.assert_not_nil(self.get_password(), 26 | 'Must have a password in test_config.yml') 27 | end 28 | 29 | def test_get_token 30 | client_login = GData::Auth::ClientLogin.new('cl') 31 | source = 'GDataUnitTest' 32 | assert_nothing_raised do 33 | token = client_login.get_token(self.get_username(), self.get_password(), source) 34 | end 35 | end 36 | 37 | def test_all_clients 38 | source = 'GDataUnitTest' 39 | GData::Client.constants.each do |const_name| 40 | const = GData::Client.const_get(const_name) 41 | if const.superclass == GData::Client::Base 42 | instance = const.new 43 | assert_nothing_raised do 44 | instance.clientlogin(self.get_username(), self.get_password(), source) 45 | end 46 | end 47 | end 48 | end 49 | 50 | def test_specify_account_type 51 | gp = GData::Client::Photos.new 52 | gp.source = 'GDataUnitTest' 53 | assert_nothing_raised do 54 | token = gp.clientlogin(self.get_username(), self.get_password(), nil, nil, nil, 'GOOGLE') 55 | end 56 | end 57 | 58 | 59 | end -------------------------------------------------------------------------------- /doc/classes/GData/Client/Base.src/M000021.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/base.rb, line 132 14 | def prepare_headers 15 | headers = @headers 16 | headers['GData-Version'] = @version 17 | headers['User-Agent'] = GData::Auth::SOURCE_LIB_STRING + @source 18 | # by default we assume we are sending Atom entries 19 | if not headers.has_key?('Content-Type') 20 | headers['Content-Type'] = 'application/atom+xml' 21 | end 22 | return headers 23 | end24 | 25 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000027.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 41 14 | def initialize(service, options = {}) 15 | if service.nil? 16 | raise ArgumentError, "Service name cannot be nil" 17 | end 18 | 19 | @service = service 20 | 21 | options = DEFAULT_OPTIONS.merge(options) 22 | options.each do |key, value| 23 | self.send("#{key}=", value) 24 | end 25 | end26 | 27 | -------------------------------------------------------------------------------- /lib/gdata/client/calendar.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | module GData 17 | module Client 18 | 19 | # Client class to wrap working with the Calendar Data API. 20 | class Calendar < Base 21 | 22 | # Holds on to a session cookie 23 | attr_accessor :session_cookie 24 | 25 | def initialize(options = {}) 26 | options[:clientlogin_service] ||= 'cl' 27 | options[:authsub_scope] ||= 'https://www.google.com/calendar/feeds/' 28 | super(options) 29 | end 30 | 31 | # Overrides auth_handler= so if the authentication changes, 32 | # the session cookie is cleared. 33 | def auth_handler=(handler) 34 | @session_cookie = nil 35 | return super(handler) 36 | end 37 | 38 | # Overrides make_request to handle 302 redirects with a session cookie. 39 | def make_request(method, url, body = '', retries = 4) 40 | response = super(method, url, body) 41 | if response.status_code == 302 and retries > 0 42 | @session_cookie = response.headers['set-cookie'] 43 | return self.make_request(method, url, body, 44 | retries - 1) 45 | else 46 | return response 47 | end 48 | end 49 | 50 | # Custom prepare_headers to include the session cookie if it exists 51 | def prepare_headers 52 | if @session_cookie 53 | @headers['cookie'] = @session_cookie 54 | end 55 | super 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBodyString.src/M000037.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 81 14 | def read(bytes_requested) 15 | if @bytes_read == @string.length 16 | return false 17 | elsif bytes_requested > @string.length - @bytes_read 18 | bytes_requested = @string.length - @bytes_read 19 | end 20 | 21 | buffer = @string[@bytes_read, bytes_requested] 22 | @bytes_read += bytes_requested 23 | 24 | return buffer 25 | end26 | 27 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBodyString.src/M000041.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 81 14 | def read(bytes_requested) 15 | if @bytes_read == @string.length 16 | return false 17 | elsif bytes_requested > @string.length - @bytes_read 18 | bytes_requested = @string.length - @bytes_read 19 | end 20 | 21 | buffer = @string[@bytes_read, bytes_requested] 22 | @bytes_read += bytes_requested 23 | 24 | return buffer 25 | end26 | 27 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000045.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 37 14 | def initialize(service, options = {}) 15 | if service.nil? 16 | raise ArgumentError, "Service name cannot be nil" 17 | end 18 | 19 | @service = service 20 | 21 | options.each do |key, value| 22 | self.send("#{key}=", value) 23 | end 24 | 25 | @auth_url ||= 'https://www.google.com/accounts/ClientLogin' 26 | @account_type ||= 'HOSTED_OR_GOOGLE' 27 | end28 | 29 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000050.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 37 14 | def initialize(service, options = {}) 15 | if service.nil? 16 | raise ArgumentError, "Service name cannot be nil" 17 | end 18 | 19 | @service = service 20 | 21 | options.each do |key, value| 22 | self.send("#{key}=", value) 23 | end 24 | 25 | @auth_url ||= 'https://www.google.com/accounts/ClientLogin' 26 | @account_type ||= 'HOSTED_OR_GOOGLE' 27 | end28 | 29 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000053.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 37 14 | def initialize(service, options = {}) 15 | if service.nil? 16 | raise ArgumentError, "Service name cannot be nil" 17 | end 18 | 19 | @service = service 20 | 21 | options.each do |key, value| 22 | self.send("#{key}=", value) 23 | end 24 | 25 | @auth_url ||= 'https://www.google.com/accounts/ClientLogin' 26 | @account_type ||= 'HOSTED_OR_GOOGLE' 27 | end28 | 29 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/ClientLogin.src/M000054.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/clientlogin.rb, line 37 14 | def initialize(service, options = {}) 15 | if service.nil? 16 | raise ArgumentError, "Service name cannot be nil" 17 | end 18 | 19 | @service = service 20 | 21 | options.each do |key, value| 22 | self.send("#{key}=", value) 23 | end 24 | 25 | @auth_url ||= 'https://www.google.com/accounts/ClientLogin' 26 | @account_type ||= 'HOSTED_OR_GOOGLE' 27 | end28 | 29 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000038.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 44 14 | def initialize(token, options = {}) 15 | if token.nil? 16 | raise ArgumentError, "Token cannot be nil." 17 | elsif token.class != String 18 | raise ArgumentError, "Token must be a String." 19 | end 20 | 21 | @token = token 22 | 23 | options.each do |key, value| 24 | self.send("#{key}=", value) 25 | end 26 | end27 | 28 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000043.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 44 14 | def initialize(token, options = {}) 15 | if token.nil? 16 | raise ArgumentError, "Token cannot be nil." 17 | elsif token.class != String 18 | raise ArgumentError, "Token must be a String." 19 | end 20 | 21 | @token = token 22 | 23 | options.each do |key, value| 24 | self.send("#{key}=", value) 25 | end 26 | end27 | 28 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000046.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 44 14 | def initialize(token, options = {}) 15 | if token.nil? 16 | raise ArgumentError, "Token cannot be nil." 17 | elsif token.class != String 18 | raise ArgumentError, "Token must be a String." 19 | end 20 | 21 | @token = token 22 | 23 | options.each do |key, value| 24 | self.send("#{key}=", value) 25 | end 26 | end27 | 28 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000047.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 44 14 | def initialize(token, options = {}) 15 | if token.nil? 16 | raise ArgumentError, "Token cannot be nil." 17 | elsif token.class != String 18 | raise ArgumentError, "Token must be a String." 19 | end 20 | 21 | @token = token 22 | 23 | options.each do |key, value| 24 | self.send("#{key}=", value) 25 | end 26 | end27 | 28 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000052.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 131 14 | def revoke 15 | request = GData::HTTP::Request.new(REVOKE_HANDLER) 16 | sign_request!(request) 17 | service = GData::HTTP::DefaultService.new 18 | response = service.make_request(request) 19 | if response.status_code != 200 20 | raise GData::Client::AuthorizationError.new(response) 21 | end 22 | 23 | end24 | 25 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000025.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 137 14 | def revoke 15 | request = GData::HTTP::Request.new(REVOKE_HANDLER) 16 | sign_request!(request) 17 | service = GData::HTTP::DefaultService.new 18 | response = service.make_request(request) 19 | if response.status_code != 200 20 | raise GData::Client::AuthorizationError, 21 | "#{response.status_code} : #{response.body}" 22 | end 23 | 24 | end25 | 26 | -------------------------------------------------------------------------------- /doc/classes/GData/Client/Calendar.src/M000033.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/client/calendar.rb, line 38 14 | def make_request(method, url, body = '', retries = 4) 15 | response = super(method, url, body) 16 | if response.status_code == 302 and retries > 0 17 | @session_cookie = response.headers['set-cookie'] 18 | return self.make_request(method, url, body, 19 | retries - 1) 20 | else 21 | return response 22 | end 23 | end24 | 25 | -------------------------------------------------------------------------------- /lib/gdata/http/request.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | require "rexml/document" 17 | 18 | module GData 19 | module HTTP 20 | 21 | # Very simple class to hold everything about an HTTP request. 22 | class Request 23 | 24 | # The URL of the request. 25 | attr_accessor :url 26 | # The body of the request. 27 | attr_accessor :body 28 | # The HTTP method being used in the request. 29 | attr_accessor :method 30 | # The HTTP headers of the request. 31 | attr_accessor :headers 32 | 33 | # Only the URL itself is required, everything else is optional. 34 | def initialize(url, options = {}) 35 | @url = url 36 | options.each do |key, value| 37 | self.send("#{key}=", value) 38 | end 39 | 40 | @method ||= :get 41 | @headers ||= {} 42 | end 43 | 44 | # Returns whether or not a request is chunked. 45 | def chunked? 46 | if @headers['Transfer-Encoding'] == 'chunked' 47 | return true 48 | else 49 | return false 50 | end 51 | end 52 | 53 | # Sets if the request is using chunked transfer-encoding. 54 | def chunked=(enabled) 55 | if enabled 56 | @headers['Transfer-Encoding'] = 'chunked' 57 | else 58 | @headers.delete('Transfer-Encoding') 59 | end 60 | end 61 | 62 | # Calculates and sets the length of the body. 63 | def calculate_length! 64 | if not @headers['Content-Length'] and not chunked? \ 65 | and method != :get and method != :delete 66 | if @body 67 | @headers['Content-Length'] = @body.length 68 | else 69 | @headers['Content-Length'] = 0 70 | end 71 | end 72 | end 73 | end 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /test/tc_gdata_client_photos.rb: -------------------------------------------------------------------------------- 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 | $:.unshift(File.dirname(__FILE__)) 16 | require 'test_helper' 17 | 18 | class TC_GData_Client_Photos < Test::Unit::TestCase 19 | 20 | include TestHelper 21 | 22 | def setup 23 | @gp = GData::Client::Photos.new 24 | @gp.source = 'Ruby Client Unit Tests' 25 | @gp.clientlogin(self.get_username(), self.get_password()) 26 | end 27 | 28 | def test_authenticated_dropbox_feed 29 | feed = @gp.get('http://picasaweb.google.com/data/feed/api/user/default/albumid/default?max-results=1').to_xml 30 | self.assert_not_nil(feed, 'feed can not be nil') 31 | end 32 | 33 | def test_photo_upload 34 | test_image = File.join(File.dirname(__FILE__), 'testimage.jpg') 35 | mime_type = 'image/jpeg' 36 | 37 | response = @gp.post_file('http://picasaweb.google.com/data/feed/api/user/default/albumid/default', 38 | test_image, mime_type).to_xml 39 | 40 | edit_uri = response.elements["link[@rel='edit']"].attributes['href'] 41 | 42 | @gp.delete(edit_uri) 43 | end 44 | 45 | def test_photo_upload_with_metadata 46 | test_image = File.join(File.dirname(__FILE__), 'testimage.jpg') 47 | mime_type = 'image/jpeg' 48 | 49 | entry = <<-EOF 50 |
# File lib/gdata/auth/authsub.rb, line 47 14 | def initialize(token, options = {}) 15 | if token.nil? 16 | raise ArgumentError, "Token cannot be nil." 17 | elsif token.class != String 18 | raise ArgumentError, "Token must be a String." 19 | end 20 | 21 | @token = token 22 | 23 | options = DEFAULT_OPTIONS.merge(options) 24 | options.each do |key, value| 25 | self.send("#{key}=", value) 26 | end 27 | end28 | 29 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000033.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 36 14 | def read(bytes_requested) 15 | if @current_part >= @parts.length 16 | return false 17 | end 18 | 19 | buffer = @parts[@current_part].read(bytes_requested) 20 | 21 | until buffer.length == bytes_requested 22 | @current_part += 1 23 | next_buffer = self.read(bytes_requested - buffer.length) 24 | break if not next_buffer 25 | buffer += next_buffer 26 | end 27 | 28 | return buffer 29 | end30 | 31 | -------------------------------------------------------------------------------- /doc/classes/GData/HTTP/MimeBody.src/M000037.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/http/mime_body.rb, line 36 14 | def read(bytes_requested) 15 | if @current_part >= @parts.length 16 | return false 17 | end 18 | 19 | buffer = @parts[@current_part].read(bytes_requested) 20 | 21 | until buffer.length == bytes_requested 22 | @current_part += 1 23 | next_buffer = self.read(bytes_requested - buffer.length) 24 | break if not next_buffer 25 | buffer += next_buffer 26 | end 27 | 28 | return buffer 29 | end30 | 31 | -------------------------------------------------------------------------------- /doc/classes/GData/Auth/AuthSub.src/M000050.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
# File lib/gdata/auth/authsub.rb, line 97 14 | def upgrade 15 | request = GData::HTTP::Request.new(SESSION_HANDLER) 16 | sign_request!(request) 17 | service = GData::HTTP::DefaultService.new 18 | response = service.make_request(request) 19 | if response.status_code != 200 20 | raise GData::Client::AuthorizationError.new(response) 21 | end 22 | 23 | @token = response.body[/Token=(.*)/,1] 24 | return @token 25 | 26 | end27 | 28 | -------------------------------------------------------------------------------- /lib/gdata/client.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # Copyright (C) 2008 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | require 'gdata/client/base' 17 | require 'gdata/client/apps' 18 | require 'gdata/client/analytics' 19 | require 'gdata/client/blogger' 20 | require 'gdata/client/booksearch' 21 | require 'gdata/client/calendar' 22 | require 'gdata/client/contacts' 23 | require 'gdata/client/doclist' 24 | require 'gdata/client/finance' 25 | require 'gdata/client/gbase' 26 | require 'gdata/client/gmail' 27 | require 'gdata/client/health' 28 | require 'gdata/client/notebook' 29 | require 'gdata/client/photos' 30 | require 'gdata/client/spreadsheets' 31 | require 'gdata/client/webmaster_tools' 32 | require 'gdata/client/youtube' 33 | 34 | module GData 35 | module Client 36 | 37 | # Base class for GData::Client errors 38 | class Error < RuntimeError 39 | end 40 | 41 | # Base class for errors raised due to requests 42 | class RequestError < Error 43 | 44 | # The Net::HTTPResponse that caused this error. 45 | attr_accessor :response 46 | 47 | # Creates a new RequestError from Net::HTTPResponse +response+ with a 48 | # message containing the error code and response body. 49 | def initialize(response) 50 | @response = response 51 | 52 | super "request error #{response.status_code}: #{response.body}" 53 | end 54 | 55 | end 56 | 57 | class AuthorizationError < RequestError 58 | end 59 | 60 | class BadRequestError < RequestError 61 | end 62 | 63 | # An error caused by ClientLogin issuing a CAPTCHA error. 64 | class CaptchaError < RuntimeError 65 | # The token identifying the CAPTCHA 66 | attr_reader :token 67 | # The URL to the CAPTCHA image 68 | attr_reader :url 69 | 70 | def initialize(token, url) 71 | @token = token 72 | @url = url 73 | end 74 | end 75 | 76 | class ServerError < RequestError 77 | end 78 | 79 | class UnknownError < RequestError 80 | end 81 | 82 | class VersionConflictError < RequestError 83 | end 84 | 85 | end 86 | end 87 | --------------------------------------------------------------------------------