google-api-client 0.3.0 → 0.4.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.md +43 -0
- data/README.md +4 -5
- data/bin/google-api +12 -7
- data/lib/google/api_client.rb +179 -161
- data/lib/google/api_client/discovery/api.rb +1 -0
- data/lib/google/api_client/discovery/method.rb +11 -8
- data/lib/google/api_client/discovery/resource.rb +1 -0
- data/lib/google/api_client/discovery/schema.rb +2 -1
- data/lib/google/api_client/environment.rb +15 -0
- data/lib/google/api_client/reference.rb +41 -31
- data/lib/google/api_client/result.rb +5 -10
- data/lib/google/api_client/version.rb +3 -1
- data/spec/google/api_client/discovery_spec.rb +44 -51
- data/spec/google/api_client_spec.rb +19 -10
- data/tasks/gem.rake +7 -6
- data/tasks/git.rake +1 -1
- data/tasks/rdoc.rake +5 -8
- data/tasks/spec.rake +3 -2
- data/tasks/wiki.rake +48 -7
- data/tasks/yard.rake +7 -4
- metadata +11 -17
- data/CHANGELOG +0 -36
- data/lib/google/api_client/parser.rb +0 -59
- data/lib/google/api_client/parsers/json/error_parser.rb +0 -34
- data/lib/google/api_client/parsers/json/pagination.rb +0 -40
- data/lib/google/api_client/parsers/json_parser.rb +0 -119
- data/spec/google/api_client/parsers/json_parser_spec.rb +0 -55
- data/tasks/clobber.rake +0 -2
@@ -14,9 +14,12 @@
|
|
14
14
|
|
15
15
|
require 'spec_helper'
|
16
16
|
|
17
|
+
gem 'faraday', '~> 0.7.0'
|
18
|
+
require 'faraday'
|
19
|
+
require 'faraday/utils'
|
20
|
+
|
21
|
+
gem 'signet', '~> 0.3.0'
|
17
22
|
require 'signet/oauth_1/client'
|
18
|
-
require 'httpadapter/adapters/net_http'
|
19
|
-
require 'httpadapter/adapters/mock'
|
20
23
|
|
21
24
|
require 'google/api_client'
|
22
25
|
require 'google/api_client/version'
|
@@ -44,16 +47,22 @@ shared_examples_for 'configurable user agent' do
|
|
44
47
|
|
45
48
|
it 'should transmit a User-Agent header when sending requests' do
|
46
49
|
@client.user_agent = 'Custom User Agent/1.2.3'
|
47
|
-
request =
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
request = Faraday::Request.new(:get) do |req|
|
51
|
+
req.url('http://www.google.com/')
|
52
|
+
end
|
53
|
+
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
|
54
|
+
stub.get('/') do |env|
|
55
|
+
headers = env[:request_headers]
|
56
|
+
headers.should have_key('User-Agent')
|
57
|
+
headers['User-Agent'].should == @client.user_agent
|
58
|
+
[200, {}, ['']]
|
53
59
|
end
|
54
|
-
[200, [], ['']]
|
55
60
|
end
|
56
|
-
|
61
|
+
connection = Faraday.new(:url => 'https://www.google.com') do |builder|
|
62
|
+
builder.adapter(:test, stubs)
|
63
|
+
end
|
64
|
+
@client.transmit(:request => request, :connection => connection)
|
65
|
+
stubs.verify_stubbed_calls
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
data/tasks/gem.rake
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'rubygems/package_task'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
CLOBBER.include('pkg')
|
2
5
|
|
3
6
|
namespace :gem do
|
4
7
|
GEM_SPEC = Gem::Specification.new do |s|
|
@@ -21,11 +24,11 @@ namespace :gem do
|
|
21
24
|
s.rdoc_options.concat ['--main', 'README.md']
|
22
25
|
|
23
26
|
# Dependencies used in the main library
|
24
|
-
s.add_runtime_dependency('signet', '~> 0.
|
25
|
-
s.add_runtime_dependency('addressable', '~> 2.2.
|
26
|
-
s.add_runtime_dependency('httpadapter', '~> 1.0.1')
|
27
|
+
s.add_runtime_dependency('signet', '~> 0.3.1')
|
28
|
+
s.add_runtime_dependency('addressable', '~> 2.2.3')
|
27
29
|
s.add_runtime_dependency('autoparse', '~> 0.2.0')
|
28
|
-
s.add_runtime_dependency('
|
30
|
+
s.add_runtime_dependency('faraday', '~> 0.7.0')
|
31
|
+
s.add_runtime_dependency('multi_json', '>= 1.0.0')
|
29
32
|
s.add_runtime_dependency('extlib', '>= 0.9.15')
|
30
33
|
|
31
34
|
# Dependencies used in the CLI
|
@@ -93,5 +96,3 @@ end
|
|
93
96
|
|
94
97
|
desc 'Alias to gem:package'
|
95
98
|
task 'gem' => 'gem:package'
|
96
|
-
|
97
|
-
task 'clobber' => ['gem:clobber_package']
|
data/tasks/git.rake
CHANGED
@@ -10,7 +10,7 @@ namespace :git do
|
|
10
10
|
|
11
11
|
desc 'Create a new tag in the Git repository'
|
12
12
|
task :create do
|
13
|
-
changelog = File.open('CHANGELOG', 'r') { |file| file.read }
|
13
|
+
changelog = File.open('CHANGELOG.md', 'r') { |file| file.read }
|
14
14
|
puts '-' * 80
|
15
15
|
puts changelog
|
16
16
|
puts '-' * 80
|
data/tasks/rdoc.rake
CHANGED
@@ -6,6 +6,10 @@ rescue Gem::LoadError
|
|
6
6
|
end unless defined?(RDoc)
|
7
7
|
|
8
8
|
require 'rdoc/task'
|
9
|
+
require 'rake/clean'
|
10
|
+
|
11
|
+
CLOBBER.include('doc', 'ri')
|
12
|
+
CLOBBER.uniq!
|
9
13
|
|
10
14
|
namespace :doc do
|
11
15
|
desc 'Generate RDoc documentation'
|
@@ -15,7 +19,7 @@ namespace :doc do
|
|
15
19
|
rdoc.options << '--line-numbers' << 'cattr_accessor=object' <<
|
16
20
|
'--charset' << 'utf-8'
|
17
21
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
18
|
-
rdoc.rdoc_files.include('README.md', 'CHANGELOG', 'LICENSE')
|
22
|
+
rdoc.rdoc_files.include('README.md', 'CHANGELOG.md', 'LICENSE')
|
19
23
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
20
24
|
end
|
21
25
|
|
@@ -23,11 +27,4 @@ namespace :doc do
|
|
23
27
|
task :ri do
|
24
28
|
sh 'rdoc --ri -o ri .'
|
25
29
|
end
|
26
|
-
|
27
|
-
desc 'Remove ri products'
|
28
|
-
task :clobber_ri do
|
29
|
-
rm_r 'ri' rescue nil
|
30
|
-
end
|
31
30
|
end
|
32
|
-
|
33
|
-
task 'clobber' => ['doc:clobber_rdoc', 'doc:clobber_ri']
|
data/tasks/spec.rake
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'spec/rake/verify_rcov'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
CLOBBER.include('coverage', 'specdoc')
|
2
5
|
|
3
6
|
namespace :spec do
|
4
7
|
Spec::Rake::SpecTask.new(:rcov) do |t|
|
@@ -79,5 +82,3 @@ else
|
|
79
82
|
desc 'Alias to spec:all'
|
80
83
|
task 'spec' => 'spec:all'
|
81
84
|
end
|
82
|
-
|
83
|
-
task 'clobber' => ['spec:clobber_rcov']
|
data/tasks/wiki.rake
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'google/api_client'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
|
5
|
+
CLOBBER.include('wiki')
|
2
6
|
|
3
7
|
CACHE_PREFIX =
|
4
8
|
"http://www.gmodules.com/gadgets/proxy/container=default&debug=0&nocache=0/"
|
5
9
|
|
6
10
|
namespace :wiki do
|
7
11
|
desc 'Autogenerate wiki pages'
|
8
|
-
task :
|
12
|
+
task :supported_apis do
|
9
13
|
output = <<-WIKI
|
10
14
|
#summary The list of supported APIs
|
11
15
|
|
@@ -23,12 +27,15 @@ WIKI
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
for api_name, api in preferred_apis
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
if api.documentation.to_s != "" && api.title != ""
|
31
|
+
output += (
|
32
|
+
"||#{CACHE_PREFIX}#{api['icons']['x16']}||" +
|
33
|
+
"[#{api.documentation} #{api.title}]||" +
|
34
|
+
"#{api.description}||\n"
|
35
|
+
)
|
36
|
+
end
|
31
37
|
end
|
38
|
+
output.gsub!(/-32\./, "-16.")
|
32
39
|
wiki_path = File.expand_path(
|
33
40
|
File.join(File.dirname(__FILE__), '../wiki/'))
|
34
41
|
Dir.mkdir(wiki_path) if !File.exist?(wiki_path)
|
@@ -36,6 +43,40 @@ WIKI
|
|
36
43
|
file.write(output)
|
37
44
|
end
|
38
45
|
end
|
46
|
+
|
47
|
+
task 'generate' => ['wiki:supported_apis']
|
39
48
|
end
|
40
49
|
|
41
|
-
|
50
|
+
begin
|
51
|
+
$LOAD_PATH.unshift(
|
52
|
+
File.expand_path(File.join(File.dirname(__FILE__), '../yard/lib'))
|
53
|
+
)
|
54
|
+
$LOAD_PATH.unshift(File.expand_path('.'))
|
55
|
+
$LOAD_PATH.uniq!
|
56
|
+
|
57
|
+
require 'yard'
|
58
|
+
require 'yard/rake/wikidoc_task'
|
59
|
+
|
60
|
+
namespace :wiki do
|
61
|
+
desc 'Generate Wiki Documentation with YARD'
|
62
|
+
YARD::Rake::WikidocTask.new do |yardoc|
|
63
|
+
yardoc.name = 'reference'
|
64
|
+
yardoc.options = [
|
65
|
+
'--verbose',
|
66
|
+
'--markup', 'markdown',
|
67
|
+
'-e', 'yard/lib/yard-google-code.rb',
|
68
|
+
'-p', 'yard/templates',
|
69
|
+
'-f', 'wiki',
|
70
|
+
'-o', 'wiki'
|
71
|
+
]
|
72
|
+
yardoc.files = [
|
73
|
+
'lib/**/*.rb', 'ext/**/*.c', '-', 'README.md', 'CHANGELOG.md'
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
task 'generate' => ['wiki:reference', 'wiki:supported_apis']
|
78
|
+
end
|
79
|
+
rescue LoadError
|
80
|
+
# If yard isn't available, it's not the end of the world
|
81
|
+
warn('YARD unavailable. Cannot fully generate wiki.')
|
82
|
+
end
|
data/tasks/yard.rake
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
CLOBBER.include('doc', '.yardoc')
|
5
|
+
CLOBBER.uniq!
|
2
6
|
|
3
7
|
begin
|
4
8
|
require 'yard'
|
@@ -8,15 +12,14 @@ begin
|
|
8
12
|
desc 'Generate Yardoc documentation'
|
9
13
|
YARD::Rake::YardocTask.new do |yardoc|
|
10
14
|
yardoc.name = 'yard'
|
11
|
-
yardoc.options = ['--verbose']
|
15
|
+
yardoc.options = ['--verbose', '--markup', 'markdown']
|
12
16
|
yardoc.files = [
|
13
|
-
'lib/**/*.rb', 'ext/**/*.c', '
|
17
|
+
'lib/**/*.rb', 'ext/**/*.c', '-',
|
18
|
+
'README.md', 'CHANGELOG.md', 'LICENSE'
|
14
19
|
]
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
task 'clobber' => ['doc:clobber_yard']
|
19
|
-
|
20
23
|
desc 'Alias to doc:yard'
|
21
24
|
task 'doc' => 'doc:yard'
|
22
25
|
rescue LoadError
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: google-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Bob Aman
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-01-30 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: signet
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.3.1
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -31,40 +31,40 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 2.2.
|
34
|
+
version: 2.2.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: autoparse
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.2.0
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: faraday
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.7.0
|
57
57
|
type: :runtime
|
58
58
|
version_requirements: *id004
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
60
|
+
name: multi_json
|
61
61
|
prerelease: false
|
62
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 1.
|
67
|
+
version: 1.0.0
|
68
68
|
type: :runtime
|
69
69
|
version_requirements: *id005
|
70
70
|
- !ruby/object:Gem::Dependency
|
@@ -163,21 +163,15 @@ files:
|
|
163
163
|
- lib/google/api_client/discovery.rb
|
164
164
|
- lib/google/api_client/environment.rb
|
165
165
|
- lib/google/api_client/errors.rb
|
166
|
-
- lib/google/api_client/parser.rb
|
167
|
-
- lib/google/api_client/parsers/json/error_parser.rb
|
168
|
-
- lib/google/api_client/parsers/json/pagination.rb
|
169
|
-
- lib/google/api_client/parsers/json_parser.rb
|
170
166
|
- lib/google/api_client/reference.rb
|
171
167
|
- lib/google/api_client/result.rb
|
172
168
|
- lib/google/api_client/version.rb
|
173
169
|
- lib/google/api_client.rb
|
174
170
|
- lib/google/inflection.rb
|
175
171
|
- spec/google/api_client/discovery_spec.rb
|
176
|
-
- spec/google/api_client/parsers/json_parser_spec.rb
|
177
172
|
- spec/google/api_client_spec.rb
|
178
173
|
- spec/spec.opts
|
179
174
|
- spec/spec_helper.rb
|
180
|
-
- tasks/clobber.rake
|
181
175
|
- tasks/gem.rake
|
182
176
|
- tasks/git.rake
|
183
177
|
- tasks/metrics.rake
|
@@ -185,7 +179,7 @@ files:
|
|
185
179
|
- tasks/spec.rake
|
186
180
|
- tasks/wiki.rake
|
187
181
|
- tasks/yard.rake
|
188
|
-
- CHANGELOG
|
182
|
+
- CHANGELOG.md
|
189
183
|
- LICENSE
|
190
184
|
- Rakefile
|
191
185
|
- README.md
|
data/CHANGELOG
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
== 0.3.0
|
2
|
-
|
3
|
-
* updated to use v1 of the discovery API
|
4
|
-
* updated to use httpadapter 1.0.0
|
5
|
-
* added OAuth 2 support to the command line tool
|
6
|
-
* renamed some switches in the command line tool
|
7
|
-
* added additional configuration capabilities
|
8
|
-
* fixed a few deprecation warnings from dependencies
|
9
|
-
* added gemspec to source control
|
10
|
-
|
11
|
-
== 0.2.0
|
12
|
-
|
13
|
-
* updated to use v1 of the discovery API
|
14
|
-
* updated to use httpadapter 1.0.0
|
15
|
-
* added OAuth 2 support to the command line tool
|
16
|
-
* renamed some switches in the command line tool
|
17
|
-
* added additional configuration capabilities
|
18
|
-
|
19
|
-
== 0.1.3
|
20
|
-
|
21
|
-
* added support for manual overrides of the discovery URI
|
22
|
-
* added support for manual overrides of the API base
|
23
|
-
* added support for xoauth_requestor_id
|
24
|
-
|
25
|
-
== 0.1.2
|
26
|
-
|
27
|
-
* added support for two-legged OAuth
|
28
|
-
* moved some development dependencies into runtime
|
29
|
-
|
30
|
-
== 0.1.1
|
31
|
-
|
32
|
-
* substantial improvements to the command line interface
|
33
|
-
|
34
|
-
== 0.1.0
|
35
|
-
|
36
|
-
* initial release
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright 2010 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
|
-
|
16
|
-
require 'json'
|
17
|
-
|
18
|
-
module Google
|
19
|
-
class APIClient
|
20
|
-
module Parser
|
21
|
-
def content_type(content_type)
|
22
|
-
@@content_type_mapping ||= {}
|
23
|
-
@@content_type_mapping[content_type] = self
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.match_content_type(content_type)
|
27
|
-
# TODO(bobaman): Do this more efficiently.
|
28
|
-
mime_type_regexp = /^([^\/]+)(?:\/([^+]+\+)?([^;]+))?(?:;.*)?$/
|
29
|
-
if @@content_type_mapping[content_type]
|
30
|
-
# Exact match
|
31
|
-
return @@content_type_mapping[content_type]
|
32
|
-
else
|
33
|
-
media_type, extension, sub_type =
|
34
|
-
content_type.scan(mime_type_regexp)[0]
|
35
|
-
for pattern, parser in @@content_type_mapping
|
36
|
-
# We want to match on subtype first
|
37
|
-
pattern_media_type, pattern_extension, pattern_sub_type =
|
38
|
-
pattern.scan(mime_type_regexp)[0]
|
39
|
-
next if pattern_extension != nil
|
40
|
-
if media_type == pattern_media_type && sub_type == pattern_sub_type
|
41
|
-
return parser
|
42
|
-
end
|
43
|
-
end
|
44
|
-
for pattern, parser in @@content_type_mapping
|
45
|
-
# We failed to match on the subtype
|
46
|
-
# Try to match only on the media type
|
47
|
-
pattern_media_type, pattern_extension, pattern_sub_type =
|
48
|
-
pattern.scan(mime_type_regexp)[0]
|
49
|
-
next if pattern_extension != nil || pattern_sub_type != nil
|
50
|
-
if media_type == pattern_media_type
|
51
|
-
return parser
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
return nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# Copyright 2010 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
|
-
|
16
|
-
require 'google/api_client/parsers/json_parser'
|
17
|
-
|
18
|
-
module Google
|
19
|
-
class APIClient
|
20
|
-
module JSON
|
21
|
-
##
|
22
|
-
# A module which provides a parser for error responses.
|
23
|
-
class ErrorParser
|
24
|
-
include Google::APIClient::JSONParser
|
25
|
-
|
26
|
-
matches_fields 'error'
|
27
|
-
|
28
|
-
def error
|
29
|
-
return self['error']['message']
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|