From 321533455c39d687b32a9c4d09416c6752b89c96 Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Fri, 2 Dec 2011 16:43:55 +0300 Subject: [PATCH] Fixed some YARD documentation issues and changed how the user-agent is built. --- lib/google/api_client.rb | 20 +++++++++++++------ lib/google/api_client/discovery/api.rb | 1 + lib/google/api_client/discovery/method.rb | 1 + lib/google/api_client/discovery/resource.rb | 1 + lib/google/api_client/discovery/schema.rb | 1 + lib/google/api_client/environment.rb | 15 ++++++++++++++ lib/google/api_client/parser.rb | 1 + .../api_client/parsers/json/error_parser.rb | 1 + .../api_client/parsers/json/pagination.rb | 1 + lib/google/api_client/parsers/json_parser.rb | 1 + lib/google/api_client/reference.rb | 2 ++ lib/google/api_client/result.rb | 1 + lib/google/api_client/version.rb | 2 ++ 13 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/google/api_client.rb b/lib/google/api_client.rb index d68f53120..f01a8d93e 100644 --- a/lib/google/api_client.rb +++ b/lib/google/api_client.rb @@ -24,6 +24,7 @@ require 'google/api_client/discovery' require 'google/api_client/reference' require 'google/api_client/result' + module Google # TODO(bobaman): Document all this stuff. @@ -47,8 +48,9 @@ module Google # @option options [String] :host ("www.googleapis.com") # The API hostname used by the client. This rarely needs to be changed. # @option options [String] :application_name - # The name and version of the application using the client. This should - # be given in the form `"{name}/{version}"`. + # The name of the application using the client. + # @option options [String] :application_version + # The version number of the application using the client. # @option options [String] :user_agent # ("{app_name} google-api-ruby-client/{version} {os_name}/{os_version}") # The user agent used by the client. Most developers will want to @@ -63,10 +65,16 @@ module Google self.host = options["host"] || 'www.googleapis.com' # Most developers will want to leave this value alone and use the # application_name option. + application_string = ( + options["application_name"] ? ( + "#{options["application_name"]}/" + + "#{options["application_version"] || '0.0.0'}" + ) : "" + ) self.user_agent = options["user_agent"] || ( - (options["application_name"] || '') - 'google-api-ruby-client/' + VERSION::STRING + - ' ' + ENV::OS_VERSION + "#{application_string} " + + "google-api-ruby-client/#{VERSION::STRING} " + + ENV::OS_VERSION ).strip # The writer method understands a few Symbols and will generate useful # default authentication mechanisms. @@ -148,7 +156,7 @@ module Google ## # The application's API key issued by the API console. # - # @return [String] The API key.. + # @return [String] The API key. attr_accessor :key ## diff --git a/lib/google/api_client/discovery/api.rb b/lib/google/api_client/discovery/api.rb index 8abea2d04..57ca339bb 100644 --- a/lib/google/api_client/discovery/api.rb +++ b/lib/google/api_client/discovery/api.rb @@ -19,6 +19,7 @@ require 'google/inflection' require 'google/api_client/discovery/resource' require 'google/api_client/discovery/method' + module Google class APIClient ## diff --git a/lib/google/api_client/discovery/method.rb b/lib/google/api_client/discovery/method.rb index 945e4809a..6c326d60c 100644 --- a/lib/google/api_client/discovery/method.rb +++ b/lib/google/api_client/discovery/method.rb @@ -18,6 +18,7 @@ require 'addressable/template' require 'google/api_client/errors' + module Google class APIClient ## diff --git a/lib/google/api_client/discovery/resource.rb b/lib/google/api_client/discovery/resource.rb index 649ba3052..ecd94e365 100644 --- a/lib/google/api_client/discovery/resource.rb +++ b/lib/google/api_client/discovery/resource.rb @@ -18,6 +18,7 @@ require 'addressable/uri' require 'google/inflection' require 'google/api_client/discovery/method' + module Google class APIClient ## diff --git a/lib/google/api_client/discovery/schema.rb b/lib/google/api_client/discovery/schema.rb index 86f7ed397..9421be1e1 100644 --- a/lib/google/api_client/discovery/schema.rb +++ b/lib/google/api_client/discovery/schema.rb @@ -23,6 +23,7 @@ require 'addressable/template' require 'google/inflection' require 'google/api_client/errors' + module Google class APIClient module Schema diff --git a/lib/google/api_client/environment.rb b/lib/google/api_client/environment.rb index dbdb2d8eb..e5abe9334 100644 --- a/lib/google/api_client/environment.rb +++ b/lib/google/api_client/environment.rb @@ -1,3 +1,18 @@ +# Copyright 2010 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + module Google class APIClient module ENV diff --git a/lib/google/api_client/parser.rb b/lib/google/api_client/parser.rb index e91351673..c8cb5365d 100644 --- a/lib/google/api_client/parser.rb +++ b/lib/google/api_client/parser.rb @@ -15,6 +15,7 @@ require 'json' + module Google class APIClient module Parser diff --git a/lib/google/api_client/parsers/json/error_parser.rb b/lib/google/api_client/parsers/json/error_parser.rb index 719317a39..3a8a9256f 100644 --- a/lib/google/api_client/parsers/json/error_parser.rb +++ b/lib/google/api_client/parsers/json/error_parser.rb @@ -15,6 +15,7 @@ require 'google/api_client/parsers/json_parser' + module Google class APIClient module JSON diff --git a/lib/google/api_client/parsers/json/pagination.rb b/lib/google/api_client/parsers/json/pagination.rb index cc4e2aa5a..69581e2d0 100644 --- a/lib/google/api_client/parsers/json/pagination.rb +++ b/lib/google/api_client/parsers/json/pagination.rb @@ -15,6 +15,7 @@ require 'google/api_client/parsers/json_parser' + module Google class APIClient module JSON diff --git a/lib/google/api_client/parsers/json_parser.rb b/lib/google/api_client/parsers/json_parser.rb index ff828bf33..b7c366ac7 100644 --- a/lib/google/api_client/parsers/json_parser.rb +++ b/lib/google/api_client/parsers/json_parser.rb @@ -16,6 +16,7 @@ require 'json' require 'google/api_client/parser' + module Google class APIClient ## diff --git a/lib/google/api_client/reference.rb b/lib/google/api_client/reference.rb index 572d33ddb..0a24b0c59 100644 --- a/lib/google/api_client/reference.rb +++ b/lib/google/api_client/reference.rb @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. + require 'stringio' require 'json' require 'addressable/uri' require 'google/api_client/discovery' + module Google class APIClient class Reference diff --git a/lib/google/api_client/result.rb b/lib/google/api_client/result.rb index 72c396881..0abc1ac67 100644 --- a/lib/google/api_client/result.rb +++ b/lib/google/api_client/result.rb @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + module Google class APIClient ## diff --git a/lib/google/api_client/version.rb b/lib/google/api_client/version.rb index 7e4890c52..7b6fae529 100644 --- a/lib/google/api_client/version.rb +++ b/lib/google/api_client/version.rb @@ -15,6 +15,8 @@ # Used to prevent the class/module from being loaded more than once if !defined?(::Google::APIClient::VERSION) + + module Google class APIClient module VERSION