google-api-client 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/google-api-client.gemspec +4 -3
  4. data/lib/google/api_client/client_secrets.rb +1 -1
  5. data/lib/google/apis/core/download.rb +10 -1
  6. data/lib/google/apis/core/json_representation.rb +2 -2
  7. data/lib/google/apis/version.rb +1 -1
  8. data/samples/cli/.env +4 -0
  9. data/samples/web/.env +2 -0
  10. data/samples/web/views/home.erb +0 -1
  11. metadata +5 -71
  12. data/api_names_out.yaml +0 -28434
  13. data/generated/google/apis/sheets_v1.rb +0 -43
  14. data/generated/google/apis/sheets_v1/classes.rb +0 -4542
  15. data/generated/google/apis/sheets_v1/representations.rb +0 -1703
  16. data/generated/google/apis/sheets_v1/service.rb +0 -363
  17. data/script/generate +0 -105
  18. data/script/package +0 -8
  19. data/script/release +0 -15
  20. data/spec/fixtures/files/api_names.yaml +0 -3
  21. data/spec/fixtures/files/auth_stored_credentials.json +0 -8
  22. data/spec/fixtures/files/child/.gitignore +0 -0
  23. data/spec/fixtures/files/client_secrets.json +0 -1
  24. data/spec/fixtures/files/invalid.json +0 -1
  25. data/spec/fixtures/files/test.blah +0 -1
  26. data/spec/fixtures/files/test.txt +0 -1
  27. data/spec/fixtures/files/test_api.json +0 -440
  28. data/spec/google/api_client/auth/storage_spec.rb +0 -120
  29. data/spec/google/api_client/auth/storages/file_store_spec.rb +0 -39
  30. data/spec/google/api_client/auth/storages/redis_store_spec.rb +0 -68
  31. data/spec/google/api_client/client_secrets_spec.rb +0 -389
  32. data/spec/google/apis/core/api_command_spec.rb +0 -209
  33. data/spec/google/apis/core/batch_spec.rb +0 -142
  34. data/spec/google/apis/core/download_spec.rb +0 -103
  35. data/spec/google/apis/core/hashable_spec.rb +0 -60
  36. data/spec/google/apis/core/http_command_spec.rb +0 -303
  37. data/spec/google/apis/core/json_representation_spec.rb +0 -199
  38. data/spec/google/apis/core/service_spec.rb +0 -313
  39. data/spec/google/apis/core/upload_spec.rb +0 -300
  40. data/spec/google/apis/generated_spec.rb +0 -27
  41. data/spec/google/apis/generator/generator_spec.rb +0 -324
  42. data/spec/google/apis/logging_spec.rb +0 -100
  43. data/spec/google/apis/options_spec.rb +0 -40
  44. data/spec/integration_tests/adsense_spec.rb +0 -29
  45. data/spec/integration_tests/drive_spec.rb +0 -35
  46. data/spec/integration_tests/pubsub_spec.rb +0 -48
  47. data/spec/integration_tests/url_shortener_spec.rb +0 -45
  48. data/spec/spec_helper.rb +0 -153
  49. data/spec/spec_helper/load_path_spec.rb +0 -33
@@ -1,27 +0,0 @@
1
- # Copyright 2015 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 'spec_helper'
16
-
17
- RSpec.describe Google::Apis do
18
- # Minimal test just to ensure no syntax errors in generated code
19
- it 'should load all APIs' do
20
- expect do
21
- Dir.glob(File.join(ROOT_DIR, 'generated', 'google', 'apis', '*.rb')) do |file|
22
- base = File.basename(file, '.rb')
23
- require sprintf('google/apis/%s', base)
24
- end
25
- end.not_to raise_error
26
- end
27
- end
@@ -1,324 +0,0 @@
1
- # Copyright 2015 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 'spec_helper'
16
- require 'google/apis/generator'
17
- require 'tmpdir'
18
- require 'fileutils'
19
-
20
- # TODO - Naked arrays in method requests/responses
21
-
22
- RSpec.describe Google::Apis::Generator do
23
- include TestHelpers
24
-
25
- context 'with test API' do
26
- before(:context) do
27
- generator = Google::Apis::Generator.new(api_names: File.join(FIXTURES_DIR, 'files', 'api_names.yaml'))
28
- discovery = File.read(File.join(FIXTURES_DIR, 'files', 'test_api.json'))
29
- generated_files = generator.render(discovery)
30
- puts generator.dump_api_names
31
- tempdir = Dir.mktmpdir
32
- generated_files.each do |key, content|
33
- path = File.join(tempdir, key)
34
- FileUtils.mkdir_p(File.dirname(path))
35
- File.open(path, 'w') do |f|
36
- f.write(content)
37
- end
38
- end
39
- $LOAD_PATH.unshift(tempdir)
40
- require 'google/apis/test_v1'
41
- end
42
-
43
- let(:service) { Google::Apis::TestV1::TestService.new }
44
-
45
- context 'with the generated service' do
46
- it 'should set the base URL' do
47
- expect(service.root_url.to_s).to eql('https://www.googleapis.com/')
48
- end
49
-
50
- it 'should define global methods from discovery' do
51
- expect(service.method(:query)).to_not be_nil
52
- end
53
-
54
- it 'should define parameters on methods' do
55
- parameters = service.method(:query).parameters.map { |(_k, v)| v }
56
- expect(parameters).to include(:s, :i, :n, :b, :a, :e, :er, :sr)
57
- end
58
-
59
- it 'should modify parameter names that are ruby keywords' do
60
- parameters = service.method(:query).parameters.map { |(_k, v)| v }
61
- expect(parameters).to include(:do_)
62
- end
63
-
64
- it 'should define global parameters on methods' do
65
- parameters = service.method(:query).parameters.map { |(_k, v)| v }
66
- expect(parameters).to include(:fields, :quota_user, :user_ip)
67
- end
68
-
69
- it 'should include standard options & block' do
70
- parameters = service.method(:query).parameters.map { |(_k, v)| v }
71
- expect(parameters).to include(:options, :block)
72
- end
73
-
74
- it 'should define AUTH_TEST scope' do
75
- expect(Google::Apis::TestV1::AUTH_TEST).to eql ('https://www.googleapis.com/auth/test')
76
- end
77
-
78
- it 'should define AUTH_TEST_READONLY scope' do
79
- expect(Google::Apis::TestV1::AUTH_TEST_READONLY).to eql ('https://www.googleapis.com/auth/test.readonly')
80
- end
81
-
82
- context 'when simplifying class names' do
83
- it 'should simplify the TestAnotherThing name' do
84
- expect { Google::Apis::TestV1::AnotherThing.new }.not_to raise_error
85
- end
86
-
87
- it 'should not simplify the TestThing name' do
88
- expect { Google::Apis::TestV1::TestThing.new }.not_to raise_error
89
- end
90
- end
91
-
92
-
93
- context 'with the Thing resource' do
94
- it 'should define the create method`' do
95
- expect(service.method(:create_thing)).to_not be_nil
96
- end
97
-
98
- it 'should define the list method`' do
99
- expect(service.method(:list_things)).to_not be_nil
100
- end
101
-
102
- it 'should define the get method`' do
103
- expect(service.method(:get_thing)).to_not be_nil
104
- end
105
-
106
- it 'should include the download_dest parameter for get_thing' do
107
- parameters = service.method(:get_thing).parameters.map { |(_k, v)| v }
108
- expect(parameters).to include(:download_dest)
109
- end
110
-
111
- it 'should define the update method`' do
112
- expect(service.method(:update_thing)).to_not be_nil
113
- end
114
-
115
- it 'should include the upload_source parameter for update_thing' do
116
- parameters = service.method(:update_thing).parameters.map { |(_k, v)| v }
117
- expect(parameters).to include(:upload_source)
118
- end
119
-
120
- it 'should define subresource methods' do
121
- expect(service.method(:list_thing_subthings)).to_not be_nil
122
- end
123
-
124
- context 'With the from_json method' do
125
- let(:json) do
126
- <<EOF
127
- {
128
- "name" : "A thing",
129
- "properties": {
130
- "prop_a" : "value_a"
131
- },
132
- "photo": {
133
- "filename": "image.jpg"
134
- },
135
- "hat": {
136
- "type": "topHat",
137
- "height": 100
138
- }
139
- }
140
- EOF
141
- end
142
-
143
- let(:thing) { Google::Apis::TestV1::Thing.from_json(json) }
144
-
145
- it 'should return a thing' do
146
- expect(thing).to be_instance_of(Google::Apis::TestV1::Thing)
147
- end
148
-
149
- it 'should parse properties' do
150
- expect(thing.name).to eq 'A thing'
151
- end
152
-
153
- it 'should parse subtypes' do
154
- expect(thing.photo.filename).to eq "image.jpg"
155
- end
156
- end
157
-
158
- context 'With the to_json method' do
159
- let(:thing) do
160
- Google::Apis::TestV1::Thing.new(
161
- name: "A thing",
162
- properties: {
163
- prop_a: "value_a"
164
- },
165
- photo: {
166
- filename: "image.jpg"
167
- },
168
- hat: {
169
- type: "topHat",
170
- height: 100
171
- }
172
- )
173
- end
174
- end
175
- end
176
-
177
- context 'with the get_thing method' do
178
- before(:example) do
179
- json = <<EOF
180
- {
181
- "id" : "123",
182
- "name" : "A thing",
183
- "enabled": true,
184
- "properties": {
185
- "prop_a" : "value_a",
186
- "prop_b" : "value_b"
187
- },
188
- "photo": {
189
- "filename": "image.jpg"
190
- },
191
- "hat": {
192
- "type": "baseballHat",
193
- "color": "red"
194
- }
195
- }
196
- EOF
197
- stub_request(:get, 'https://www.googleapis.com/test/v1/things/123')
198
- .to_return(headers: { 'Content-Type' => 'application/json' }, body: json)
199
- end
200
-
201
- let(:thing) { service.get_thing('123') }
202
-
203
- it 'should return a Thing' do
204
- expect(thing).to be_instance_of(Google::Apis::TestV1::Thing)
205
- end
206
-
207
- it 'should set attributes' do
208
- expect(thing.id).to eql '123'
209
- end
210
-
211
- it 'should alias boolean methods on Thing' do
212
- expect(thing.enabled?).to be true
213
- end
214
-
215
- it 'should return a Hash for properties' do
216
- expect(thing.properties).to be_instance_of(Hash)
217
- end
218
-
219
- it 'should set hash elements' do
220
- expect(thing.properties).to include('prop_a' => 'value_a')
221
- end
222
-
223
- it 'should return the correct variant type for hat' do
224
- expect(thing.hat).to be_instance_of(Google::Apis::TestV1::BaseballHat)
225
- end
226
-
227
- it 'should return the correct variant properties for hat' do
228
- expect(thing.hat.color).to eql 'red'
229
- end
230
-
231
- it 'should return a photo' do
232
- expect(thing.photo).to be_instance_of(Google::Apis::TestV1::Thing::Photo)
233
- end
234
-
235
- it 'should return photo properties' do
236
- expect(thing.photo.filename).to eql 'image.jpg'
237
- end
238
- end
239
-
240
- context 'with the create_thing method' do
241
- before(:example) do
242
- json = <<EOF
243
- {
244
- "id" : "123",
245
- "name" : "A thing",
246
- "properties": {
247
- "prop_a" : "value_a"
248
- },
249
- "photo": {
250
- "filename": "image.jpg"
251
- },
252
- "hat": {
253
- "type": "topHat",
254
- "height": 100
255
- }
256
- }
257
- EOF
258
- stub_request(:post, 'https://www.googleapis.com/test/v1/things')
259
- .to_return(headers: { 'Content-Type' => 'application/json' }, body: json)
260
- end
261
-
262
- let(:thing) do
263
- thing = Google::Apis::TestV1::Thing.new(name: 'A thing', properties: { 'prop_a' => 'value_a' })
264
- thing.photo = Google::Apis::TestV1::Thing::Photo.new(filename: 'image.jpg')
265
- thing.hat = Google::Apis::TestV1::TopHat.new(type: 'topHat', height: 100)
266
- service.create_thing(thing)
267
- end
268
-
269
- it 'should serialize the thing' do
270
- expected_body = <<EOF
271
- {
272
- "name" : "A thing",
273
- "properties": {
274
- "prop_a" : "value_a"
275
- },
276
- "photo": {
277
- "filename": "image.jpg"
278
- },
279
- "hat": {
280
- "type": "topHat",
281
- "height": 100
282
- }
283
- }
284
- EOF
285
- expect(thing).to be_instance_of(Google::Apis::TestV1::Thing)
286
- expect(a_request(:post, 'https://www.googleapis.com/test/v1/things')
287
- .with { |req| expect(req.body).to be_json_eql(expected_body) }).to have_been_made
288
- end
289
-
290
- it 'should an updated id' do
291
- expect(thing.id).to eql '123'
292
- end
293
- end
294
-
295
- context 'with the query method' do
296
- before(:example) do
297
- body = %({"rows": [{"value": "hello"}, {"value": "world"}]})
298
- stub_request(:get, 'https://www.googleapis.com/test/v1/query')
299
- .to_return(headers: { 'Content-Type' => 'application/json' }, body: body)
300
- end
301
-
302
- it 'should return query results' do
303
- results = service.query
304
- expect(results).to be_instance_of(Google::Apis::TestV1::QueryResults)
305
- end
306
-
307
- it 'should return an array for items' do
308
- results = service.query
309
- expect(results.rows).to be_instance_of(Array)
310
- end
311
-
312
- it 'should return items of type Row' do
313
- results = service.query
314
- expect(results.rows.first).to be_instance_of(Google::Apis::TestV1::Row)
315
- end
316
-
317
- it 'should return values for rows' do
318
- results = service.query
319
- expect(results.rows[1].value).to eql('world')
320
- end
321
- end
322
- end
323
- end
324
- end
@@ -1,100 +0,0 @@
1
- # Copyright 2015 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 'spec_helper'
16
- require 'google/apis'
17
- require 'google/apis/core/logging'
18
-
19
-
20
- RSpec.describe Google::Apis do
21
- it 'should have a default logger' do
22
- expect(Google::Apis.logger).to be_an_instance_of(Logger)
23
- end
24
-
25
- context 'with service' do
26
- let(:service) do
27
- Class.new do
28
- include Google::Apis::Core::Logging
29
- end.new
30
- end
31
-
32
- it 'should have a logger' do
33
- expect(service.logger).to be_an_instance_of(Logger)
34
- end
35
-
36
- it 'should use the default logger' do
37
- expect(service.logger).to be Google::Apis.logger
38
- end
39
-
40
- it 'should allow custom loggers' do
41
- Google::Apis.logger = Logger.new(STDERR)
42
- expect(service.logger).to be Google::Apis.logger
43
- end
44
- end
45
-
46
- context 'with Rails' do
47
-
48
- before(:example) do
49
- Google::Apis.logger = nil
50
- Kernel.const_set('Rails', Module.new) unless defined?(::Rails)
51
- end
52
-
53
- let(:logger) { Logger.new(STDERR) }
54
-
55
- let(:service) do
56
- Class.new do
57
- include Google::Apis::Core::Logging
58
- end.new
59
- end
60
-
61
- context 'with logger present' do
62
- before(:example) do
63
- allow(::Rails).to receive(:logger).and_return(logger)
64
- end
65
-
66
- it 'should use the Rails logger' do
67
- expect(service.logger).to be Rails.logger
68
- end
69
- end
70
-
71
- context 'with ENV bypass' do
72
- before(:example) do
73
- allow(::Rails).to receive(:logger).and_return(logger)
74
- allow(::ENV).to receive(:fetch).and_return('false')
75
- end
76
-
77
- it 'should use own logger' do
78
- expect(service.logger).not_to be Rails.logger
79
- end
80
-
81
- it 'should have a logger' do
82
- expect(service.logger).to be_an_instance_of(Logger)
83
- end
84
- end
85
-
86
- context 'with logger not present' do
87
- before(:example) do
88
- allow(::Rails).to receive(:logger).and_return(nil)
89
- end
90
-
91
- it 'should use own logger' do
92
- expect(service.logger).not_to be Rails.logger
93
- end
94
-
95
- it 'should have a logger' do
96
- expect(service.logger).to be_an_instance_of(Logger)
97
- end
98
- end
99
- end
100
- end