gdata 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/gdata/auth/authsub.rb +3 -6
- data/lib/gdata/auth/clientlogin.rb +2 -2
- data/lib/gdata/client.rb +26 -5
- data/lib/gdata/client/base.rb +5 -5
- data/lib/gdata/http/response.rb +3 -1
- metadata +2 -2
data/Rakefile
CHANGED
@@ -50,7 +50,7 @@ spec = Gem::Specification.new do |s|
|
|
50
50
|
s.summary = "Google Data APIs Ruby Utility Library"
|
51
51
|
s.rubyforge_project = 'gdata'
|
52
52
|
s.name = 'gdata'
|
53
|
-
s.version = '1.0
|
53
|
+
s.version = '1.1.0'
|
54
54
|
s.requirements << 'none'
|
55
55
|
s.require_path = 'lib'
|
56
56
|
s.test_files = FileList['test/ts_gdata.rb']
|
data/lib/gdata/auth/authsub.rb
CHANGED
@@ -100,8 +100,7 @@ module GData
|
|
100
100
|
service = GData::HTTP::DefaultService.new
|
101
101
|
response = service.make_request(request)
|
102
102
|
if response.status_code != 200
|
103
|
-
raise GData::Client::AuthorizationError
|
104
|
-
"#{response.status_code} : #{response.body}"
|
103
|
+
raise GData::Client::AuthorizationError.new(response)
|
105
104
|
end
|
106
105
|
|
107
106
|
@token = response.body[/Token=(.*)/,1]
|
@@ -117,8 +116,7 @@ module GData
|
|
117
116
|
service = GData::HTTP::DefaultService.new
|
118
117
|
response = service.make_request(request)
|
119
118
|
if response.status_code != 200
|
120
|
-
raise GData::Client::AuthorizationError
|
121
|
-
"#{response.status_code} : #{response.body}"
|
119
|
+
raise GData::Client::AuthorizationError.new(response)
|
122
120
|
end
|
123
121
|
|
124
122
|
result = {}
|
@@ -136,8 +134,7 @@ module GData
|
|
136
134
|
service = GData::HTTP::DefaultService.new
|
137
135
|
response = service.make_request(request)
|
138
136
|
if response.status_code != 200
|
139
|
-
raise GData::Client::AuthorizationError
|
140
|
-
"#{response.status_code} : #{response.body}"
|
137
|
+
raise GData::Client::AuthorizationError.new(response)
|
141
138
|
end
|
142
139
|
|
143
140
|
end
|
@@ -81,7 +81,7 @@ module GData
|
|
81
81
|
"#{error} : #{url}"
|
82
82
|
end
|
83
83
|
|
84
|
-
raise GData::Client::AuthorizationError
|
84
|
+
raise GData::Client::AuthorizationError.new(response)
|
85
85
|
end
|
86
86
|
|
87
87
|
@token = response.body[/Auth=(.*)/,1]
|
@@ -92,7 +92,7 @@ module GData
|
|
92
92
|
# object.
|
93
93
|
def sign_request!(request)
|
94
94
|
if @token == nil
|
95
|
-
raise
|
95
|
+
raise GData::Client::Error, "Cannot sign request without credentials"
|
96
96
|
end
|
97
97
|
|
98
98
|
request.headers['Authorization'] = "GoogleLogin auth=#{@token}"
|
data/lib/gdata/client.rb
CHANGED
@@ -31,10 +31,31 @@ require 'gdata/client/youtube'
|
|
31
31
|
|
32
32
|
module GData
|
33
33
|
module Client
|
34
|
-
|
34
|
+
|
35
|
+
# Base class for GData::Client errors
|
36
|
+
class Error < RuntimeError
|
37
|
+
end
|
38
|
+
|
39
|
+
# Base class for errors raised due to requests
|
40
|
+
class RequestError < Error
|
41
|
+
|
42
|
+
# The Net::HTTPResponse that caused this error.
|
43
|
+
attr_accessor :response
|
44
|
+
|
45
|
+
# Creates a new RequestError from Net::HTTPResponse +response+ with a
|
46
|
+
# message containing the error code and response body.
|
47
|
+
def initialize(response)
|
48
|
+
@response = response
|
49
|
+
|
50
|
+
super "request error #{response.status_code}: #{response.body}"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
class AuthorizationError < RequestError
|
35
56
|
end
|
36
57
|
|
37
|
-
class BadRequestError <
|
58
|
+
class BadRequestError < RequestError
|
38
59
|
end
|
39
60
|
|
40
61
|
# An error caused by ClientLogin issuing a CAPTCHA error.
|
@@ -50,13 +71,13 @@ module GData
|
|
50
71
|
end
|
51
72
|
end
|
52
73
|
|
53
|
-
class ServerError <
|
74
|
+
class ServerError < RequestError
|
54
75
|
end
|
55
76
|
|
56
|
-
class UnknownError <
|
77
|
+
class UnknownError < RequestError
|
57
78
|
end
|
58
79
|
|
59
|
-
class VersionConflictError <
|
80
|
+
class VersionConflictError < RequestError
|
60
81
|
end
|
61
82
|
|
62
83
|
end
|
data/lib/gdata/client/base.rb
CHANGED
@@ -84,15 +84,15 @@ module GData
|
|
84
84
|
when 200, 201, 302
|
85
85
|
#Do nothing, it's a success.
|
86
86
|
when 401, 403
|
87
|
-
raise AuthorizationError
|
87
|
+
raise AuthorizationError.new(response)
|
88
88
|
when 400
|
89
89
|
raise BadRequestError, response.body
|
90
90
|
when 409
|
91
|
-
raise VersionConflictError
|
91
|
+
raise VersionConflictError.new(response)
|
92
92
|
when 500
|
93
|
-
raise ServerError
|
93
|
+
raise ServerError.new(response)
|
94
94
|
else
|
95
|
-
raise UnknownError
|
95
|
+
raise UnknownError.new(response)
|
96
96
|
end
|
97
97
|
|
98
98
|
return response
|
@@ -174,7 +174,7 @@ module GData
|
|
174
174
|
if @auth_handler.class == GData::Auth::AuthSub
|
175
175
|
@auth_handler.private_key = key
|
176
176
|
else
|
177
|
-
raise
|
177
|
+
raise Error, "An AuthSub token must be set first."
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
data/lib/gdata/http/response.rb
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
require 'gdata/client'
|
16
|
+
|
15
17
|
module GData
|
16
18
|
module HTTP
|
17
19
|
|
@@ -31,7 +33,7 @@ module GData
|
|
31
33
|
begin
|
32
34
|
return REXML::Document.new(@body).root
|
33
35
|
rescue
|
34
|
-
raise
|
36
|
+
raise GData::Client::Error, "Response body not XML."
|
35
37
|
end
|
36
38
|
else
|
37
39
|
return nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fisher
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|