gdata-ruby19 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +202 -0
- data/README +97 -0
- data/README.md +4 -0
- data/Rakefile +64 -0
- data/lib/gdata.rb +22 -0
- data/lib/gdata/auth.rb +22 -0
- data/lib/gdata/auth/authsub.rb +161 -0
- data/lib/gdata/auth/clientlogin.rb +102 -0
- data/lib/gdata/client.rb +84 -0
- data/lib/gdata/client/apps.rb +27 -0
- data/lib/gdata/client/base.rb +182 -0
- data/lib/gdata/client/blogger.rb +28 -0
- data/lib/gdata/client/booksearch.rb +28 -0
- data/lib/gdata/client/calendar.rb +58 -0
- data/lib/gdata/client/contacts.rb +28 -0
- data/lib/gdata/client/doclist.rb +28 -0
- data/lib/gdata/client/finance.rb +28 -0
- data/lib/gdata/client/gbase.rb +28 -0
- data/lib/gdata/client/gmail.rb +28 -0
- data/lib/gdata/client/health.rb +28 -0
- data/lib/gdata/client/notebook.rb +28 -0
- data/lib/gdata/client/photos.rb +29 -0
- data/lib/gdata/client/spreadsheets.rb +28 -0
- data/lib/gdata/client/webmaster_tools.rb +28 -0
- data/lib/gdata/client/youtube.rb +47 -0
- data/lib/gdata/http.rb +18 -0
- data/lib/gdata/http/default_service.rb +82 -0
- data/lib/gdata/http/mime_body.rb +95 -0
- data/lib/gdata/http/request.rb +74 -0
- data/lib/gdata/http/response.rb +44 -0
- data/test/tc_gdata_auth_authsub.rb +53 -0
- data/test/tc_gdata_auth_clientlogin.rb +59 -0
- data/test/tc_gdata_client_base.rb +37 -0
- data/test/tc_gdata_client_calendar.rb +40 -0
- data/test/tc_gdata_client_photos.rb +65 -0
- data/test/tc_gdata_client_youtube.rb +77 -0
- data/test/tc_gdata_http_mime_body.rb +46 -0
- data/test/tc_gdata_http_request.rb +36 -0
- data/test/test_config.yml.example +7 -0
- data/test/test_helper.rb +47 -0
- data/test/testimage.jpg +0 -0
- data/test/ts_gdata.rb +42 -0
- data/test/ts_gdata_auth.rb +25 -0
- data/test/ts_gdata_client.rb +29 -0
- data/test/ts_gdata_http.rb +25 -0
- metadata +96 -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
|
data/test/test_helper.rb
ADDED
@@ -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
|
data/test/testimage.jpg
ADDED
Binary file
|
data/test/ts_gdata.rb
ADDED
@@ -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,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gdata-ruby19
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeff Fisher, Trevor Johns
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! "This gem provides a set of wrappers designed to make it easy to work
|
15
|
+
with \nthe Google Data APIs.\n"
|
16
|
+
email: trevorjohns@google.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README
|
21
|
+
- LICENSE
|
22
|
+
files:
|
23
|
+
- LICENSE
|
24
|
+
- Rakefile
|
25
|
+
- README
|
26
|
+
- README.md
|
27
|
+
- lib/gdata/auth/authsub.rb
|
28
|
+
- lib/gdata/auth/clientlogin.rb
|
29
|
+
- lib/gdata/auth.rb
|
30
|
+
- lib/gdata/client/apps.rb
|
31
|
+
- lib/gdata/client/base.rb
|
32
|
+
- lib/gdata/client/blogger.rb
|
33
|
+
- lib/gdata/client/booksearch.rb
|
34
|
+
- lib/gdata/client/calendar.rb
|
35
|
+
- lib/gdata/client/contacts.rb
|
36
|
+
- lib/gdata/client/doclist.rb
|
37
|
+
- lib/gdata/client/finance.rb
|
38
|
+
- lib/gdata/client/gbase.rb
|
39
|
+
- lib/gdata/client/gmail.rb
|
40
|
+
- lib/gdata/client/health.rb
|
41
|
+
- lib/gdata/client/notebook.rb
|
42
|
+
- lib/gdata/client/photos.rb
|
43
|
+
- lib/gdata/client/spreadsheets.rb
|
44
|
+
- lib/gdata/client/webmaster_tools.rb
|
45
|
+
- lib/gdata/client/youtube.rb
|
46
|
+
- lib/gdata/client.rb
|
47
|
+
- lib/gdata/http/default_service.rb
|
48
|
+
- lib/gdata/http/mime_body.rb
|
49
|
+
- lib/gdata/http/request.rb
|
50
|
+
- lib/gdata/http/response.rb
|
51
|
+
- lib/gdata/http.rb
|
52
|
+
- lib/gdata.rb
|
53
|
+
- test/tc_gdata_auth_authsub.rb
|
54
|
+
- test/tc_gdata_auth_clientlogin.rb
|
55
|
+
- test/tc_gdata_client_base.rb
|
56
|
+
- test/tc_gdata_client_calendar.rb
|
57
|
+
- test/tc_gdata_client_photos.rb
|
58
|
+
- test/tc_gdata_client_youtube.rb
|
59
|
+
- test/tc_gdata_http_mime_body.rb
|
60
|
+
- test/tc_gdata_http_request.rb
|
61
|
+
- test/test_config.yml.example
|
62
|
+
- test/test_helper.rb
|
63
|
+
- test/testimage.jpg
|
64
|
+
- test/ts_gdata.rb
|
65
|
+
- test/ts_gdata_auth.rb
|
66
|
+
- test/ts_gdata_client.rb
|
67
|
+
- test/ts_gdata_http.rb
|
68
|
+
homepage: http://code.google.com/p/gdata-ruby-util
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --main
|
73
|
+
- README
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements:
|
89
|
+
- none
|
90
|
+
rubyforge_project: gdata
|
91
|
+
rubygems_version: 1.8.24
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Google Data APIs Ruby Utility Library
|
95
|
+
test_files:
|
96
|
+
- test/ts_gdata.rb
|