Merge branch 'master' of github.com:sporkmonger/google-api-ruby-client
This commit is contained in:
commit
af61568cbe
|
@ -47,8 +47,8 @@ module Google
|
|||
# <li><code>:oauth_1</code></li>
|
||||
# <li><code>:oauth_2</code></li>
|
||||
# </ul>
|
||||
# @option options [String] :host ("www.googleapis.com")
|
||||
# The API hostname used by the client. This rarely needs to be changed.
|
||||
# @option options [String] :baseURI ("https://www.googleapis.com/discovery/v1")
|
||||
# The base API URI used by the client. This rarely needs to be changed.
|
||||
# @option options [String] :application_name
|
||||
# The name of the application using the client.
|
||||
# @option options [String] :application_version
|
||||
|
@ -63,8 +63,9 @@ module Google
|
|||
accu[key.to_s] = value
|
||||
accu
|
||||
end
|
||||
# Almost all API usage will have a host of 'www.googleapis.com'.
|
||||
self.host = options["host"] || 'www.googleapis.com'
|
||||
# Almost all API usage will have this base URI
|
||||
self.baseURI = options["baseURI"] || "https://www.googleapis.com/discovery/v1"
|
||||
|
||||
# Most developers will want to leave this value alone and use the
|
||||
# application_name option.
|
||||
application_string = (
|
||||
|
@ -80,7 +81,7 @@ module Google
|
|||
).strip
|
||||
# The writer method understands a few Symbols and will generate useful
|
||||
# default authentication mechanisms.
|
||||
self.authorization = options["authorization"] || :oauth_2
|
||||
self.authorization = options.key?("authorization") ? options["authorization"] : :oauth_2
|
||||
self.key = options["key"]
|
||||
self.user_ip = options["user_ip"]
|
||||
@discovery_uris = {}
|
||||
|
@ -165,7 +166,7 @@ module Google
|
|||
#
|
||||
# @return [String]
|
||||
# The API hostname. Should almost always be 'www.googleapis.com'.
|
||||
attr_accessor :host
|
||||
attr_accessor :baseURI
|
||||
|
||||
##
|
||||
# The user agent used by the client.
|
||||
|
@ -174,15 +175,16 @@ module Google
|
|||
# The user agent string used in the User-Agent header.
|
||||
attr_accessor :user_agent
|
||||
|
||||
def relative_uri(path, expand={})
|
||||
Addressable::Template.new(baseURI+path).expand(expand)
|
||||
end
|
||||
|
||||
##
|
||||
# Returns the URI for the directory document.
|
||||
#
|
||||
# @return [Addressable::URI] The URI of the directory document.
|
||||
def directory_uri
|
||||
template = Addressable::Template.new(
|
||||
"https://{host}/discovery/v1/apis"
|
||||
)
|
||||
return template.expand({"host" => self.host})
|
||||
relative_uri('/apis')
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -208,15 +210,7 @@ module Google
|
|||
api = api.to_s
|
||||
version = version || 'v1'
|
||||
return @discovery_uris["#{api}:#{version}"] ||= (begin
|
||||
template = Addressable::Template.new(
|
||||
"https://{host}/discovery/v1/apis/" +
|
||||
"{api}/{version}/rest"
|
||||
)
|
||||
template.expand({
|
||||
"host" => self.host,
|
||||
"api" => api,
|
||||
"version" => version
|
||||
})
|
||||
relative_uri("/apis/{api}/{version}/rest", 'api' => api, 'version' => version)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -596,7 +590,7 @@ module Google
|
|||
unless headers.kind_of?(Enumerable)
|
||||
# We need to use some Enumerable methods, relying on the presence of
|
||||
# the #each method.
|
||||
class <<headers
|
||||
class << headers
|
||||
include Enumerable
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ module Google
|
|||
def initialize(document_base, discovery_document)
|
||||
@document_base = Addressable::URI.parse(document_base)
|
||||
@discovery_document = discovery_document
|
||||
metaclass = (class <<self; self; end)
|
||||
metaclass = (class << self; self; end)
|
||||
self.discovered_resources.each do |resource|
|
||||
method_name = Google::INFLECTOR.underscore(resource.name).to_sym
|
||||
if !self.respond_to?(method_name)
|
||||
|
|
|
@ -47,7 +47,7 @@ module Google
|
|||
# and excess object creation, but this hopefully shouldn't be an
|
||||
# issue since it should only be called only once per schema per
|
||||
# process.
|
||||
if data.kind_of?(Hash) && data['$ref']
|
||||
if data.kind_of?(Hash) && data['$ref'].is_a?(String)
|
||||
reference = data['$ref']
|
||||
reference = '#' + reference if reference[0..0] != '#'
|
||||
data.merge({
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
module Google
|
||||
class APIClient
|
||||
module ENV
|
||||
OS_VERSION = if RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/
|
||||
OS_VERSION = begin
|
||||
if RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/
|
||||
# TODO(bobaman)
|
||||
# Confirm that all of these Windows environments actually have access
|
||||
# to the `ver` command.
|
||||
|
@ -26,6 +27,9 @@ module Google
|
|||
else
|
||||
`uname -sr`.sub(' ', '/')
|
||||
end
|
||||
rescue Exception
|
||||
RUBY_PLATFORM
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue