google-api-client 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -0
- data/README +1 -1
- data/bin/google-api +174 -120
- data/lib/google/api_client.rb +333 -135
- data/lib/google/api_client/discovery.rb +106 -108
- data/lib/google/api_client/environment.rb +13 -0
- data/lib/google/api_client/errors.rb +30 -0
- data/lib/google/api_client/parsers/json_parser.rb +1 -0
- data/lib/google/api_client/version.rb +3 -2
- data/lib/google/inflection.rb +23 -0
- data/spec/google/api_client/discovery_spec.rb +381 -381
- data/spec/google/api_client_spec.rb +78 -28
- data/tasks/gem.rake +4 -6
- metadata +32 -60
@@ -16,32 +16,50 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
require 'signet/oauth_1/client'
|
18
18
|
require 'httpadapter/adapters/net_http'
|
19
|
+
require 'httpadapter/adapters/mock'
|
19
20
|
|
20
21
|
require 'google/api_client'
|
21
22
|
require 'google/api_client/version'
|
22
23
|
require 'google/api_client/parsers/json_parser'
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
@client =
|
25
|
+
shared_examples_for 'configurable user agent' do
|
26
|
+
it 'should allow the user agent to be modified' do
|
27
|
+
@client.user_agent = 'Custom User Agent/1.2.3'
|
28
|
+
@client.user_agent.should == 'Custom User Agent/1.2.3'
|
27
29
|
end
|
28
30
|
|
29
|
-
it 'should
|
30
|
-
|
31
|
+
it 'should allow the user agent to be set to nil' do
|
32
|
+
@client.user_agent = nil
|
33
|
+
@client.user_agent.should == nil
|
31
34
|
end
|
32
35
|
|
33
|
-
it 'should
|
34
|
-
|
36
|
+
it 'should not allow the user agent to be used with bogus values' do
|
37
|
+
(lambda do
|
38
|
+
@client.user_agent = 42
|
39
|
+
@client.transmit_request(
|
40
|
+
['GET', 'http://www.google.com/', [], []]
|
41
|
+
)
|
42
|
+
end).should raise_error(TypeError)
|
35
43
|
end
|
36
44
|
|
37
|
-
it 'should
|
38
|
-
@client.
|
45
|
+
it 'should transmit a User-Agent header when sending requests' do
|
46
|
+
@client.user_agent = 'Custom User Agent/1.2.3'
|
47
|
+
request = ['GET', 'http://www.google.com/', [], []]
|
48
|
+
adapter = HTTPAdapter::MockAdapter.create do |request_ary, connection|
|
49
|
+
method, uri, headers, body = request_ary
|
50
|
+
headers.should be_any { |k, v| k.downcase == 'user-agent' }
|
51
|
+
headers.each do |k, v|
|
52
|
+
v.should == @client.user_agent if k.downcase == 'user-agent'
|
53
|
+
end
|
54
|
+
[200, [], ['']]
|
55
|
+
end
|
56
|
+
@client.transmit_request(request, adapter)
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
42
|
-
describe Google::APIClient
|
60
|
+
describe Google::APIClient do
|
43
61
|
before do
|
44
|
-
@client = Google::APIClient.new
|
62
|
+
@client = Google::APIClient.new
|
45
63
|
end
|
46
64
|
|
47
65
|
it 'should make its version number available' do
|
@@ -52,28 +70,60 @@ describe Google::APIClient, 'with default oauth configuration' do
|
|
52
70
|
@client.parser.should be(Google::APIClient::JSONParser)
|
53
71
|
end
|
54
72
|
|
55
|
-
it 'should
|
56
|
-
@client.authorization
|
57
|
-
'https://www.google.com/accounts/OAuthGetRequestToken'
|
58
|
-
@client.authorization.authorization_uri.to_s.should include(
|
59
|
-
'https://www.google.com/accounts/OAuthAuthorizeToken'
|
60
|
-
)
|
61
|
-
@client.authorization.token_credential_uri.to_s.should ==
|
62
|
-
'https://www.google.com/accounts/OAuthGetAccessToken'
|
63
|
-
@client.authorization.client_credential_key.should == 'anonymous'
|
64
|
-
@client.authorization.client_credential_secret.should == 'anonymous'
|
73
|
+
it 'should default to OAuth 2' do
|
74
|
+
Signet::OAuth2::Client.should === @client.authorization
|
65
75
|
end
|
66
|
-
end
|
67
76
|
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
it_should_behave_like 'configurable user agent'
|
78
|
+
|
79
|
+
describe 'configured for OAuth 1' do
|
80
|
+
before do
|
81
|
+
@client.authorization = :oauth_1
|
71
82
|
end
|
72
83
|
|
73
|
-
|
84
|
+
it 'should use the default OAuth1 client configuration' do
|
85
|
+
@client.authorization.temporary_credential_uri.to_s.should ==
|
86
|
+
'https://www.google.com/accounts/OAuthGetRequestToken'
|
87
|
+
@client.authorization.authorization_uri.to_s.should include(
|
88
|
+
'https://www.google.com/accounts/OAuthAuthorizeToken'
|
89
|
+
)
|
90
|
+
@client.authorization.token_credential_uri.to_s.should ==
|
91
|
+
'https://www.google.com/accounts/OAuthGetAccessToken'
|
92
|
+
@client.authorization.client_credential_key.should == 'anonymous'
|
93
|
+
@client.authorization.client_credential_secret.should == 'anonymous'
|
94
|
+
end
|
95
|
+
|
96
|
+
it_should_behave_like 'configurable user agent'
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'configured for OAuth 2' do
|
100
|
+
before do
|
101
|
+
@client.authorization = :oauth_2
|
102
|
+
end
|
103
|
+
|
104
|
+
# TODO
|
105
|
+
it_should_behave_like 'configurable user agent'
|
74
106
|
end
|
75
107
|
|
76
|
-
|
77
|
-
|
108
|
+
describe 'with custom pluggable parser' do
|
109
|
+
before do
|
110
|
+
class FakeJsonParser
|
111
|
+
def serialize(value)
|
112
|
+
return "42"
|
113
|
+
end
|
114
|
+
|
115
|
+
def parse(value)
|
116
|
+
return 42
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
@client.parser = FakeJsonParser.new
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should use the custom parser' do
|
124
|
+
@client.parser.should be_instance_of(FakeJsonParser)
|
125
|
+
end
|
126
|
+
|
127
|
+
it_should_behave_like 'configurable user agent'
|
78
128
|
end
|
79
129
|
end
|
data/tasks/gem.rake
CHANGED
@@ -20,16 +20,14 @@ namespace :gem do
|
|
20
20
|
s.rdoc_options.concat ['--main', 'README']
|
21
21
|
|
22
22
|
# Dependencies used in the main library
|
23
|
-
s.add_runtime_dependency('signet', '
|
24
|
-
s.add_runtime_dependency('addressable', '
|
25
|
-
s.add_runtime_dependency('httpadapter', '
|
26
|
-
s.add_runtime_dependency('json', '>= 1.
|
23
|
+
s.add_runtime_dependency('signet', '~> 0.2.2')
|
24
|
+
s.add_runtime_dependency('addressable', '~> 2.2.2')
|
25
|
+
s.add_runtime_dependency('httpadapter', '~> 1.0.0')
|
26
|
+
s.add_runtime_dependency('json', '>= 1.4.6')
|
27
27
|
s.add_runtime_dependency('extlib', '>= 0.9.15')
|
28
28
|
|
29
29
|
# Dependencies used in the CLI
|
30
30
|
s.add_runtime_dependency('launchy', '>= 0.3.2')
|
31
|
-
s.add_runtime_dependency('rack', '= 1.2.0')
|
32
|
-
s.add_runtime_dependency('sinatra', '>= 1.0')
|
33
31
|
|
34
32
|
# Dependencies used in the examples
|
35
33
|
s.add_runtime_dependency('liquid', '>= 2.2.2')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors: []
|
13
13
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-05-12 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,14 +24,14 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
hash: 19
|
30
30
|
segments:
|
31
31
|
- 0
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version: 0.
|
32
|
+
- 2
|
33
|
+
- 2
|
34
|
+
version: 0.2.2
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
hash: 3
|
46
46
|
segments:
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
hash: 23
|
62
62
|
segments:
|
63
|
+
- 1
|
63
64
|
- 0
|
64
|
-
- 2
|
65
65
|
- 0
|
66
|
-
version: 0.
|
66
|
+
version: 1.0.0
|
67
67
|
type: :runtime
|
68
68
|
version_requirements: *id003
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -74,12 +74,12 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 11
|
78
78
|
segments:
|
79
79
|
- 1
|
80
|
-
-
|
81
|
-
-
|
82
|
-
version: 1.
|
80
|
+
- 4
|
81
|
+
- 6
|
82
|
+
version: 1.4.6
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
@@ -114,41 +114,10 @@ dependencies:
|
|
114
114
|
version: 0.3.2
|
115
115
|
type: :runtime
|
116
116
|
version_requirements: *id006
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rack
|
119
|
-
prerelease: false
|
120
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - "="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 31
|
126
|
-
segments:
|
127
|
-
- 1
|
128
|
-
- 2
|
129
|
-
- 0
|
130
|
-
version: 1.2.0
|
131
|
-
type: :runtime
|
132
|
-
version_requirements: *id007
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
name: sinatra
|
135
|
-
prerelease: false
|
136
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
hash: 15
|
142
|
-
segments:
|
143
|
-
- 1
|
144
|
-
- 0
|
145
|
-
version: "1.0"
|
146
|
-
type: :runtime
|
147
|
-
version_requirements: *id008
|
148
117
|
- !ruby/object:Gem::Dependency
|
149
118
|
name: liquid
|
150
119
|
prerelease: false
|
151
|
-
requirement: &
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
152
121
|
none: false
|
153
122
|
requirements:
|
154
123
|
- - ">="
|
@@ -160,11 +129,11 @@ dependencies:
|
|
160
129
|
- 2
|
161
130
|
version: 2.2.2
|
162
131
|
type: :runtime
|
163
|
-
version_requirements: *
|
132
|
+
version_requirements: *id007
|
164
133
|
- !ruby/object:Gem::Dependency
|
165
134
|
name: rake
|
166
135
|
prerelease: false
|
167
|
-
requirement: &
|
136
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
168
137
|
none: false
|
169
138
|
requirements:
|
170
139
|
- - ">="
|
@@ -176,11 +145,11 @@ dependencies:
|
|
176
145
|
- 3
|
177
146
|
version: 0.7.3
|
178
147
|
type: :development
|
179
|
-
version_requirements: *
|
148
|
+
version_requirements: *id008
|
180
149
|
- !ruby/object:Gem::Dependency
|
181
150
|
name: rspec
|
182
151
|
prerelease: false
|
183
|
-
requirement: &
|
152
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
184
153
|
none: false
|
185
154
|
requirements:
|
186
155
|
- - ~>
|
@@ -192,11 +161,11 @@ dependencies:
|
|
192
161
|
- 9
|
193
162
|
version: 1.2.9
|
194
163
|
type: :development
|
195
|
-
version_requirements: *
|
164
|
+
version_requirements: *id009
|
196
165
|
- !ruby/object:Gem::Dependency
|
197
166
|
name: rcov
|
198
167
|
prerelease: false
|
199
|
-
requirement: &
|
168
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
200
169
|
none: false
|
201
170
|
requirements:
|
202
171
|
- - ">="
|
@@ -208,11 +177,11 @@ dependencies:
|
|
208
177
|
- 9
|
209
178
|
version: 0.9.9
|
210
179
|
type: :development
|
211
|
-
version_requirements: *
|
180
|
+
version_requirements: *id010
|
212
181
|
- !ruby/object:Gem::Dependency
|
213
182
|
name: diff-lcs
|
214
183
|
prerelease: false
|
215
|
-
requirement: &
|
184
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
216
185
|
none: false
|
217
186
|
requirements:
|
218
187
|
- - ">="
|
@@ -224,7 +193,7 @@ dependencies:
|
|
224
193
|
- 2
|
225
194
|
version: 1.1.2
|
226
195
|
type: :development
|
227
|
-
version_requirements: *
|
196
|
+
version_requirements: *id011
|
228
197
|
description: |
|
229
198
|
The Google API Ruby Client makes it trivial to discover and access supported
|
230
199
|
APIs.
|
@@ -238,9 +207,12 @@ extra_rdoc_files:
|
|
238
207
|
- README
|
239
208
|
files:
|
240
209
|
- lib/google/api_client/discovery.rb
|
210
|
+
- lib/google/api_client/environment.rb
|
211
|
+
- lib/google/api_client/errors.rb
|
241
212
|
- lib/google/api_client/parsers/json_parser.rb
|
242
213
|
- lib/google/api_client/version.rb
|
243
214
|
- lib/google/api_client.rb
|
215
|
+
- lib/google/inflection.rb
|
244
216
|
- spec/google/api_client/discovery_spec.rb
|
245
217
|
- spec/google/api_client/parsers/json_parser_spec.rb
|
246
218
|
- spec/google/api_client_spec.rb
|
@@ -289,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
261
|
requirements: []
|
290
262
|
|
291
263
|
rubyforge_project:
|
292
|
-
rubygems_version: 1.
|
264
|
+
rubygems_version: 1.4.1
|
293
265
|
signing_key:
|
294
266
|
specification_version: 3
|
295
267
|
summary: Package Summary
|