vincentchu-gdata 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/LICENSE +202 -0
  2. data/README +97 -0
  3. data/Rakefile +72 -0
  4. data/lib/gdata.rb +22 -0
  5. data/lib/gdata/auth.rb +22 -0
  6. data/lib/gdata/auth/authsub.rb +161 -0
  7. data/lib/gdata/auth/clientlogin.rb +102 -0
  8. data/lib/gdata/client.rb +84 -0
  9. data/lib/gdata/client/apps.rb +27 -0
  10. data/lib/gdata/client/base.rb +182 -0
  11. data/lib/gdata/client/blogger.rb +28 -0
  12. data/lib/gdata/client/booksearch.rb +28 -0
  13. data/lib/gdata/client/calendar.rb +58 -0
  14. data/lib/gdata/client/contacts.rb +28 -0
  15. data/lib/gdata/client/doclist.rb +28 -0
  16. data/lib/gdata/client/finance.rb +28 -0
  17. data/lib/gdata/client/gbase.rb +28 -0
  18. data/lib/gdata/client/gmail.rb +28 -0
  19. data/lib/gdata/client/health.rb +28 -0
  20. data/lib/gdata/client/notebook.rb +28 -0
  21. data/lib/gdata/client/photos.rb +29 -0
  22. data/lib/gdata/client/spreadsheets.rb +28 -0
  23. data/lib/gdata/client/webmaster_tools.rb +28 -0
  24. data/lib/gdata/client/youtube.rb +47 -0
  25. data/lib/gdata/http.rb +18 -0
  26. data/lib/gdata/http/default_service.rb +82 -0
  27. data/lib/gdata/http/mime_body.rb +95 -0
  28. data/lib/gdata/http/request.rb +74 -0
  29. data/lib/gdata/http/response.rb +44 -0
  30. data/test/tc_gdata_auth_authsub.rb +53 -0
  31. data/test/tc_gdata_auth_clientlogin.rb +59 -0
  32. data/test/tc_gdata_client_base.rb +37 -0
  33. data/test/tc_gdata_client_calendar.rb +40 -0
  34. data/test/tc_gdata_client_photos.rb +65 -0
  35. data/test/tc_gdata_client_youtube.rb +77 -0
  36. data/test/tc_gdata_http_mime_body.rb +46 -0
  37. data/test/tc_gdata_http_request.rb +36 -0
  38. data/test/test_config.yml.example +7 -0
  39. data/test/test_helper.rb +47 -0
  40. data/test/testimage.jpg +0 -0
  41. data/test/ts_gdata.rb +42 -0
  42. data/test/ts_gdata_auth.rb +25 -0
  43. data/test/ts_gdata_client.rb +29 -0
  44. data/test/ts_gdata_http.rb +25 -0
  45. metadata +98 -0
@@ -0,0 +1,77 @@
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_YouTube < Test::Unit::TestCase
19
+
20
+ include TestHelper
21
+
22
+ def setup
23
+ @yt = GData::Client::YouTube.new
24
+ self.assert(@yt.headers.empty?, 'headers should be empty.')
25
+ @yt.clientlogin(self.get_username(), self.get_password())
26
+ @yt.client_id = 'ytapi-Google-GDataUnitTests-lcqr3u89-1'
27
+ @yt.developer_key = 'AI39si4vwXwDLR5MrtsdR1ULUD8__EnEccla-0bnqV40KpeFDIyCwEv0VJqZKHUsO3MvVM_bXHp3cAr55HmMYMhqfxzLMUgDXA'
28
+ end
29
+
30
+ def test_authenticated_uploads_feed
31
+
32
+
33
+ feed = @yt.get('http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1').to_xml
34
+ self.assert_not_nil(feed, 'feed can not be nil')
35
+ end
36
+
37
+ def test_favorites
38
+
39
+ video_id = 'zlfKdbWwruY'
40
+
41
+ entry = <<-EOF
42
+ <entry xmlns="http://www.w3.org/2005/Atom">
43
+ <id>#{video_id}</id>
44
+ </entry>
45
+ EOF
46
+
47
+ response = @yt.post('http://gdata.youtube.com/feeds/api/users/default/favorites', entry).to_xml
48
+
49
+ edit_uri = response.elements["link[@rel='edit']"].attributes['href']
50
+
51
+ @yt.delete(edit_uri)
52
+
53
+ end
54
+
55
+ def test_playlist
56
+ entry = <<-EOF
57
+ <entry xmlns="http://www.w3.org/2005/Atom"
58
+ xmlns:yt="http://gdata.youtube.com/schemas/2007">
59
+ <title type="text">Ruby Utility Unit Test</title>
60
+ <summary>This is a test playlist.</summary>
61
+ </entry>
62
+ EOF
63
+
64
+ response = @yt.post('http://gdata.youtube.com/feeds/api/users/default/playlists', entry).to_xml
65
+
66
+ edit_uri = response.elements["link[@rel='edit']"].attributes['href']
67
+
68
+ response.elements["summary"].text = "Updated description"
69
+
70
+ response = @yt.put(edit_uri, response.to_s).to_xml
71
+
72
+ self.assert_equal("Updated description", response.elements["summary"].text)
73
+
74
+ @yt.delete(edit_uri)
75
+ end
76
+
77
+ end
@@ -0,0 +1,46 @@
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_MimeBody < Test::Unit::TestCase
19
+
20
+ include TestHelper
21
+
22
+ def test_mime_body_string
23
+ stream = GData::HTTP::MimeBodyString.new('testing 1 2 3')
24
+
25
+ self.assert_equal('t', stream.read(1))
26
+ self.assert_equal('esting', stream.read(6))
27
+ self.assert_equal(' 1 2 ', stream.read(5))
28
+ self.assert_equal('3', stream.read(50))
29
+ self.assert_equal(false, stream.read(10))
30
+ end
31
+
32
+ def test_mime_body_string_large_read
33
+ stream = GData::HTTP::MimeBodyString.new('test string')
34
+
35
+ self.assert_equal('test string', stream.read(1024))
36
+ self.assert_equal(false, stream.read(1024))
37
+ end
38
+
39
+ def test_mime_body_string_unicode
40
+ stream = GData::HTTP::MimeBodyString.new('λ')
41
+ self.assert(stream.read(1), 'Greek character should be two bytes')
42
+ self.assert(stream.read(1), 'Greek character should be two full bytes')
43
+ self.assert_equal(false, stream.read(1))
44
+ end
45
+
46
+ end
@@ -0,0 +1,36 @@
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
+ assert_equal(200, response.status_code)
34
+ end
35
+
36
+ end
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,47 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'yaml'
16
+ require 'test/unit'
17
+ require 'test/unit/ui/console/testrunner'
18
+
19
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
20
+ require 'gdata'
21
+
22
+ module TestHelper
23
+
24
+ def get_config()
25
+ if not defined?(@config_file)
26
+ @config_file = YAML::load_file(File.join(File.dirname(__FILE__), 'test_config.yml'))
27
+ end
28
+ return @config_file
29
+ end
30
+
31
+ def get_username()
32
+ return self.get_config()['username']
33
+ end
34
+
35
+ def get_password()
36
+ return self.get_config()['password']
37
+ end
38
+
39
+ def get_authsub_token()
40
+ return self.get_config()['authsub_token']
41
+ end
42
+
43
+ def get_authsub_private_key()
44
+ return self.get_config()['authsub_private_key']
45
+ end
46
+
47
+ end
Binary file
@@ -0,0 +1,42 @@
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
+ require 'ts_gdata_http'
18
+ require 'ts_gdata_client'
19
+ require 'ts_gdata_auth'
20
+
21
+ class TS_GData
22
+ def self.suite
23
+ suite = Test::Unit::TestSuite.new("GData Test Suite")
24
+ suite << UnicodeStringTest.suite
25
+ suite << TS_GData_HTTP.suite
26
+ suite << TS_GData_Client.suite
27
+ suite << TS_GData_Auth.suite
28
+ return suite
29
+ end
30
+ end
31
+
32
+ class UnicodeStringTest < Test::Unit::TestCase
33
+ def test_jlength
34
+ s = "Καλημέρα κόσμε!"
35
+ assert_equal(15, s.jlength) # Note the 'j'
36
+ assert_not_equal(15, s.length) # Normal, non unicode length
37
+ assert_equal(28, s.length) # Greek letters happen to take two-bytes
38
+ end
39
+ end
40
+
41
+
42
+ Test::Unit::UI::Console::TestRunner.run(TS_GData)
@@ -0,0 +1,25 @@
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_auth_clientlogin'
16
+ require 'tc_gdata_auth_authsub'
17
+
18
+ class TS_GData_Auth
19
+ def self.suite
20
+ suite = Test::Unit::TestSuite.new
21
+ suite << TC_GData_Auth_ClientLogin.suite
22
+ suite << TC_GData_Auth_AuthSub.suite
23
+ return suite
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2008 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ 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
@@ -0,0 +1,25 @@
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_http_request'
16
+ require 'tc_gdata_http_mime_body'
17
+
18
+ class TS_GData_HTTP
19
+ def self.suite
20
+ suite = Test::Unit::TestSuite.new
21
+ suite << TC_GData_HTTP_Request.suite
22
+ suite << TC_GData_HTTP_MimeBody.suite
23
+ return suite
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vincentchu-gdata
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.11
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Fisher
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-28 00:00:00 -07:00
13
+ default_executable: gdata
14
+ dependencies: []
15
+
16
+ description: This gem provides a set of wrappers designed to make it easy to work with the Google Data APIs.
17
+ email: jfisher@youtube.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README
25
+ files:
26
+ - LICENSE
27
+ - Rakefile
28
+ - README
29
+ - lib/gdata/auth/authsub.rb
30
+ - lib/gdata/auth/clientlogin.rb
31
+ - lib/gdata/auth.rb
32
+ - lib/gdata/client/apps.rb
33
+ - lib/gdata/client/base.rb
34
+ - lib/gdata/client/blogger.rb
35
+ - lib/gdata/client/booksearch.rb
36
+ - lib/gdata/client/calendar.rb
37
+ - lib/gdata/client/contacts.rb
38
+ - lib/gdata/client/doclist.rb
39
+ - lib/gdata/client/finance.rb
40
+ - lib/gdata/client/gbase.rb
41
+ - lib/gdata/client/gmail.rb
42
+ - lib/gdata/client/health.rb
43
+ - lib/gdata/client/notebook.rb
44
+ - lib/gdata/client/photos.rb
45
+ - lib/gdata/client/spreadsheets.rb
46
+ - lib/gdata/client/webmaster_tools.rb
47
+ - lib/gdata/client/youtube.rb
48
+ - lib/gdata/client.rb
49
+ - lib/gdata/http/default_service.rb
50
+ - lib/gdata/http/mime_body.rb
51
+ - lib/gdata/http/request.rb
52
+ - lib/gdata/http/response.rb
53
+ - lib/gdata/http.rb
54
+ - lib/gdata.rb
55
+ - test/tc_gdata_auth_authsub.rb
56
+ - test/tc_gdata_auth_clientlogin.rb
57
+ - test/tc_gdata_client_base.rb
58
+ - test/tc_gdata_client_calendar.rb
59
+ - test/tc_gdata_client_photos.rb
60
+ - test/tc_gdata_client_youtube.rb
61
+ - test/tc_gdata_http_mime_body.rb
62
+ - test/tc_gdata_http_request.rb
63
+ - test/test_config.yml.example
64
+ - test/test_helper.rb
65
+ - test/testimage.jpg
66
+ - test/ts_gdata.rb
67
+ - test/ts_gdata_auth.rb
68
+ - test/ts_gdata_client.rb
69
+ - test/ts_gdata_http.rb
70
+ has_rdoc: true
71
+ homepage: http://code.google.com/p/gdata-ruby-util/
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --main
75
+ - README
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: gdata
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: Google Data APIs Ruby Utility Library
97
+ test_files:
98
+ - test/ts_gdata.rb