Merge branch 'seuros-more'

This commit is contained in:
Steven Bazyl 2014-12-15 11:54:03 -08:00
commit d6d8ec7884
26 changed files with 54 additions and 106 deletions

View File

@ -1,14 +1,10 @@
language: ruby language: ruby
rvm: rvm:
- 1.8.7
- 1.9.2
- 1.9.3 - 1.9.3
- 2.0.0 - 2.0.0
- 2.1.0 - 2.1.0
- rbx-2 - rbx-2
- jruby-18mode
- jruby-19mode - jruby-19mode
- ree
script: "bundle exec rake spec:all" script: "bundle exec rake spec:all"
before_install: before_install:
- sudo apt-get update - sudo apt-get update

View File

@ -26,12 +26,12 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'signet', '~> 0.6' s.add_runtime_dependency 'signet', '~> 0.6'
s.add_runtime_dependency 'faraday', '~> 0.9' s.add_runtime_dependency 'faraday', '~> 0.9'
s.add_runtime_dependency 'multi_json', '~> 1.10' s.add_runtime_dependency 'multi_json', '~> 1.10'
s.add_runtime_dependency 'uuidtools', "~> 2.1"
s.add_runtime_dependency 'autoparse', "~> 0.3" s.add_runtime_dependency 'autoparse', "~> 0.3"
s.add_runtime_dependency 'extlib', '~> 0.9' s.add_runtime_dependency 'extlib', '~> 0.9'
s.add_runtime_dependency 'launchy', '~> 2.4' s.add_runtime_dependency 'launchy', '~> 2.4'
s.add_runtime_dependency 'retriable', '~> 1.4' s.add_runtime_dependency 'retriable', '~> 1.4'
s.add_runtime_dependency 'activesupport', '~> 3.2'
s.add_development_dependency 'rake', '~> 10.0' s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'yard', '~> 0.8' s.add_development_dependency 'yard', '~> 0.8'
s.add_development_dependency 'rspec', '~> 3.1' s.add_development_dependency 'rspec', '~> 3.1'

View File

@ -32,7 +32,7 @@ require 'google/api_client/service_account'
require 'google/api_client/batch' require 'google/api_client/batch'
require 'google/api_client/gzip' require 'google/api_client/gzip'
require 'google/api_client/client_secrets' require 'google/api_client/client_secrets'
require 'google/api_client/railtie' if defined?(Rails::Railtie) require 'google/api_client/railtie' if defined?(Rails)
module Google module Google
@ -692,5 +692,3 @@ module Google
end end
end end
require 'google/api_client/version'

View File

@ -42,7 +42,7 @@ module Google
## ##
# Attempt to read in credentials from the specified file. # Attempt to read in credentials from the specified file.
def load_credentials def load_credentials
if File.exist? self.path if File.exists? self.path
File.open(self.path, 'r') do |file| File.open(self.path, 'r') do |file|
cached_credentials = JSON.load(file) cached_credentials = JSON.load(file)
@authorization = Signet::OAuth2::Client.new(cached_credentials) @authorization = Signet::OAuth2::Client.new(cached_credentials)

View File

@ -14,7 +14,7 @@
require 'addressable/uri' require 'addressable/uri'
require 'google/api_client/reference' require 'google/api_client/reference'
require 'uuidtools' require 'securerandom'
module Google module Google
class APIClient class APIClient
@ -90,8 +90,7 @@ module Google
@global_callback = block if block_given? @global_callback = block if block_given?
@last_auto_id = 0 @last_auto_id = 0
# TODO(sgomes): Use SecureRandom.uuid, drop UUIDTools when we drop 1.8 @base_id = SecureRandom.uuid
@base_id = UUIDTools::UUID.random_create.to_s
options[:uri] ||= 'https://www.googleapis.com/batch' options[:uri] ||= 'https://www.googleapis.com/batch'
options[:http_method] ||= 'POST' options[:http_method] ||= 'POST'

View File

@ -13,7 +13,6 @@
# limitations under the License. # limitations under the License.
require 'multi_json'
require 'compat/multi_json' require 'compat/multi_json'
@ -63,7 +62,7 @@ module Google
end end
while filename == nil while filename == nil
search_path ||= File.expand_path('.') search_path ||= File.expand_path('.')
if File.exist?(File.join(search_path, 'client_secrets.json')) if File.exists?(File.join(search_path, 'client_secrets.json'))
filename = File.join(search_path, 'client_secrets.json') filename = File.join(search_path, 'client_secrets.json')
elsif search_path == '/' || search_path =~ /[a-zA-Z]:[\/\\]/ elsif search_path == '/' || search_path =~ /[a-zA-Z]:[\/\\]/
raise ArgumentError, raise ArgumentError,

View File

@ -15,7 +15,7 @@
require 'addressable/uri' require 'addressable/uri'
require 'multi_json' require 'multi_json'
require 'google/inflection' require 'active_support/inflector'
require 'google/api_client/discovery/resource' require 'google/api_client/discovery/resource'
require 'google/api_client/discovery/method' require 'google/api_client/discovery/method'
require 'google/api_client/discovery/media' require 'google/api_client/discovery/media'
@ -41,13 +41,13 @@ module Google
@discovery_document = discovery_document @discovery_document = discovery_document
metaclass = (class << self; self; end) metaclass = (class << self; self; end)
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|
method_name = Google::INFLECTOR.underscore(resource.name).to_sym method_name = ActiveSupport::Inflector.underscore(resource.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { resource } metaclass.send(:define_method, method_name) { resource }
end end
end end
self.discovered_methods.each do |method| self.discovered_methods.each do |method|
method_name = Google::INFLECTOR.underscore(method.name).to_sym method_name = ActiveSupport::Inflector.underscore(method.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { method } metaclass.send(:define_method, method_name) { method }
end end

View File

@ -15,7 +15,7 @@
require 'addressable/uri' require 'addressable/uri'
require 'google/inflection' require 'active_support/inflector'
require 'google/api_client/discovery/method' require 'google/api_client/discovery/method'
@ -45,13 +45,13 @@ module Google
@discovery_document = discovery_document @discovery_document = discovery_document
metaclass = (class <<self; self; end) metaclass = (class <<self; self; end)
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|
method_name = Google::INFLECTOR.underscore(resource.name).to_sym method_name = ActiveSupport::Inflector.underscore(resource.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { resource } metaclass.send(:define_method, method_name) { resource }
end end
end end
self.discovered_methods.each do |method| self.discovered_methods.each do |method|
method_name = Google::INFLECTOR.underscore(method.name).to_sym method_name = ActiveSupport::Inflector.underscore(method.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { method } metaclass.send(:define_method, method_name) { method }
end end

View File

@ -21,7 +21,7 @@ require 'autoparse'
require 'addressable/uri' require 'addressable/uri'
require 'addressable/template' require 'addressable/template'
require 'google/inflection' require 'active_support/inflector'
require 'google/api_client/errors' require 'google/api_client/errors'
@ -78,10 +78,8 @@ module Google
# puts schema_data.inspect # puts schema_data.inspect
if schema_name if schema_name
api_name_string = api_name_string = ActiveSupport::Inflector.camelize(api.name)
Google::INFLECTOR.camelize(api.name) api_version_string = ActiveSupport::Inflector.camelize(api.version).gsub('.', '_')
api_version_string =
Google::INFLECTOR.camelize(api.version).gsub('.', '_')
# This is for compatibility with Ruby 1.8.7. # This is for compatibility with Ruby 1.8.7.
# TODO(bobaman) Remove this when we eventually stop supporting 1.8.7. # TODO(bobaman) Remove this when we eventually stop supporting 1.8.7.
args = [] args = []

View File

@ -1,3 +1,4 @@
require 'rails/railtie'
require 'google/api_client/logging' require 'google/api_client/logging'
module Google module Google
@ -9,7 +10,7 @@ module Google
# #
class Railtie < Rails::Railtie class Railtie < Rails::Railtie
initializer 'google-api-client' do |app| initializer 'google-api-client' do |app|
Google::APIClient.logger = Rails.logger Google::APIClient.logger = app.logger
end end
end end
end end

View File

@ -14,7 +14,6 @@
require 'faraday' require 'faraday'
require 'faraday/request/multipart' require 'faraday/request/multipart'
require 'multi_json'
require 'compat/multi_json' require 'compat/multi_json'
require 'addressable/uri' require 'addressable/uri'
require 'stringio' require 'stringio'

View File

@ -120,7 +120,7 @@ module Google
if options.include? :cache_store if options.include? :cache_store
@cache_store = options[:cache_store] @cache_store = options[:cache_store]
else else
cache_exists = File.exist?(DEFAULT_CACHE_FILE) cache_exists = File.exists?(DEFAULT_CACHE_FILE)
if (cache_exists && File.writable?(DEFAULT_CACHE_FILE)) || if (cache_exists && File.writable?(DEFAULT_CACHE_FILE)) ||
(!cache_exists && File.writable?(Dir.pwd)) (!cache_exists && File.writable?(Dir.pwd))
@cache_store = Google::APIClient::Service::SimpleFileStore.new( @cache_store = Google::APIClient::Service::SimpleFileStore.new(

View File

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
require 'active_support/inflector'
module Google module Google
class APIClient class APIClient
class Service class Service
@ -25,7 +27,7 @@ module Google
# Handle resources. # Handle resources.
root.discovered_resources.each do |resource| root.discovered_resources.each do |resource|
method_name = Google::INFLECTOR.underscore(resource.name).to_sym method_name = ActiveSupport::Inflector.underscore(resource.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) do metaclass.send(:define_method, method_name) do
Google::APIClient::Service::Resource.new(service, resource) Google::APIClient::Service::Resource.new(service, resource)
@ -35,7 +37,7 @@ module Google
# Handle methods. # Handle methods.
root.discovered_methods.each do |method| root.discovered_methods.each do |method|
method_name = Google::INFLECTOR.underscore(method.name).to_sym method_name = ActiveSupport::Inflector.underscore(method.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) do |*args| metaclass.send(:define_method, method_name) do |*args|
if args.length > 1 if args.length > 1

View File

@ -13,19 +13,14 @@
# limitations under the License. # limitations under the License.
# Used to prevent the class/module from being loaded more than once module Google
if !defined?(::Google::APIClient::VERSION) class APIClient
module VERSION
MAJOR = 0
module Google MINOR = 7
class APIClient TINY = 1
module VERSION PATCH = nil
MAJOR = 0 STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
MINOR = 7
TINY = 1
PATCH = nil
STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
end
end end
end end
end end

View File

@ -1,28 +0,0 @@
# 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
if defined?(ActiveSupport::Inflector)
INFLECTOR = ActiveSupport::Inflector
else
begin
require 'extlib/inflection'
INFLECTOR = Extlib::Inflection
rescue LoadError
require 'active_support/inflector'
INFLECTOR = ActiveSupport::Inflector
end
end
end

View File

@ -38,7 +38,7 @@ WIKI
output.gsub!(/-32\./, "-16.") output.gsub!(/-32\./, "-16.")
wiki_path = File.expand_path( wiki_path = File.expand_path(
File.join(File.dirname(__FILE__), '../wiki/')) File.join(File.dirname(__FILE__), '../wiki/'))
Dir.mkdir(wiki_path) if !File.exist?(wiki_path) Dir.mkdir(wiki_path) unless File.exists?(wiki_path)
File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file| File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file|
file.write(output) file.write(output)
end end

View File

@ -14,9 +14,8 @@
require 'spec_helper' require 'spec_helper'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
describe Google::APIClient::BatchRequest do RSpec.describe Google::APIClient::BatchRequest do
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)
after do after do

View File

@ -22,9 +22,8 @@ require 'multi_json'
require 'compat/multi_json' require 'compat/multi_json'
require 'signet/oauth_1/client' require 'signet/oauth_1/client'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
describe Google::APIClient do RSpec.describe Google::APIClient do
include ConnectionHelpers include ConnectionHelpers
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)

View File

@ -15,9 +15,8 @@
require 'spec_helper' require 'spec_helper'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
describe Google::APIClient::Gzip do RSpec.describe Google::APIClient::Gzip do
def create_connection(&block) def create_connection(&block)
Faraday.new do |b| Faraday.new do |b|

View File

@ -15,11 +15,10 @@
require 'spec_helper' require 'spec_helper'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
fixtures_path = File.expand_path('../../../fixtures', __FILE__) fixtures_path = File.expand_path('../../../fixtures', __FILE__)
describe Google::APIClient::UploadIO do RSpec.describe Google::APIClient::UploadIO do
it 'should reject invalid file paths' do it 'should reject invalid file paths' do
expect(lambda do expect(lambda do
media = Google::APIClient::UploadIO.new('doesnotexist', 'text/plain') media = Google::APIClient::UploadIO.new('doesnotexist', 'text/plain')
@ -57,7 +56,7 @@ describe Google::APIClient::UploadIO do
end end
end end
describe Google::APIClient::RangedIO do RSpec.describe Google::APIClient::RangedIO do
before do before do
@source = StringIO.new("1234567890abcdef") @source = StringIO.new("1234567890abcdef")
@io = Google::APIClient::RangedIO.new(@source, 1, 5) @io = Google::APIClient::RangedIO.new(@source, 1, 5)
@ -105,7 +104,7 @@ describe Google::APIClient::RangedIO do
end end
describe Google::APIClient::ResumableUpload do RSpec.describe Google::APIClient::ResumableUpload do
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)
after do after do

View File

@ -15,9 +15,8 @@
require 'spec_helper' require 'spec_helper'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
describe Google::APIClient::Request do RSpec.describe Google::APIClient::Request do
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)
it 'should normalize parameter names to strings' do it 'should normalize parameter names to strings' do

View File

@ -15,9 +15,8 @@
require 'spec_helper' require 'spec_helper'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
describe Google::APIClient::Result do RSpec.describe Google::APIClient::Result do
CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT)
describe 'with the plus API' do describe 'with the plus API' do

View File

@ -18,7 +18,7 @@ require 'google/api_client'
fixtures_path = File.expand_path('../../../fixtures', __FILE__) fixtures_path = File.expand_path('../../../fixtures', __FILE__)
describe Google::APIClient::KeyUtils do RSpec.describe Google::APIClient::KeyUtils do
it 'should read PKCS12 files from the filesystem' do it 'should read PKCS12 files from the filesystem' do
if RUBY_PLATFORM == 'java' && RUBY_VERSION.start_with?('1.8') if RUBY_PLATFORM == 'java' && RUBY_VERSION.start_with?('1.8')
pending "Reading from PKCS12 not supported on jruby 1.8.x" pending "Reading from PKCS12 not supported on jruby 1.8.x"
@ -53,7 +53,7 @@ describe Google::APIClient::KeyUtils do
end end
describe Google::APIClient::JWTAsserter do RSpec.describe Google::APIClient::JWTAsserter do
include ConnectionHelpers include ConnectionHelpers
before do before do
@ -146,7 +146,7 @@ describe Google::APIClient::JWTAsserter do
end end
end end
describe Google::APIClient::ComputeServiceAccount do RSpec.describe Google::APIClient::ComputeServiceAccount do
include ConnectionHelpers include ConnectionHelpers
it 'should query metadata server' do it 'should query metadata server' do

View File

@ -21,7 +21,7 @@ require 'google/api_client/service'
fixtures_path = File.expand_path('../../../fixtures', __FILE__) fixtures_path = File.expand_path('../../../fixtures', __FILE__)
describe Google::APIClient::Service do RSpec.describe Google::APIClient::Service do
include ConnectionHelpers include ConnectionHelpers
APPLICATION_NAME = 'API Client Tests' APPLICATION_NAME = 'API Client Tests'
@ -288,7 +288,7 @@ describe Google::APIClient::Service do
end end
describe Google::APIClient::Service::Result do RSpec.describe Google::APIClient::Service::Result do
describe 'with the plus API' do describe 'with the plus API' do
before do before do
@ -492,7 +492,7 @@ describe Google::APIClient::Service::Result do
end end
end end
describe Google::APIClient::Service::BatchRequest do RSpec.describe Google::APIClient::Service::BatchRequest do
describe 'with the discovery API' do describe 'with the discovery API' do
before do before do
@discovery = Google::APIClient::Service.new('discovery', 'v1', @discovery = Google::APIClient::Service.new('discovery', 'v1',

View File

@ -18,14 +18,10 @@ require 'spec_helper'
require 'google/api_client/service/simple_file_store' require 'google/api_client/service/simple_file_store'
describe Google::APIClient::Service::SimpleFileStore do RSpec.describe Google::APIClient::Service::SimpleFileStore do
FILE_NAME = 'test.cache' FILE_NAME = 'test.cache'
before(:all) do
File.delete(FILE_NAME) if File.exists?(FILE_NAME)
end
describe 'with no cache file' do describe 'with no cache file' do
before(:each) do before(:each) do
File.delete(FILE_NAME) if File.exists?(FILE_NAME) File.delete(FILE_NAME) if File.exists?(FILE_NAME)

View File

@ -17,7 +17,6 @@ require 'spec_helper'
require 'faraday' require 'faraday'
require 'signet/oauth_1/client' require 'signet/oauth_1/client'
require 'google/api_client' require 'google/api_client'
require 'google/api_client/version'
shared_examples_for 'configurable user agent' do shared_examples_for 'configurable user agent' do
include ConnectionHelpers include ConnectionHelpers
@ -55,7 +54,7 @@ shared_examples_for 'configurable user agent' do
end end
end end
describe Google::APIClient do RSpec.describe Google::APIClient do
include ConnectionHelpers include ConnectionHelpers
let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') } let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') }
@ -191,7 +190,7 @@ describe Google::APIClient do
end end
client.execute( client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection :connection => @connection
) )
end end
@ -210,7 +209,7 @@ describe Google::APIClient do
end end
client.execute( client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection :connection => @connection
) )
end end
@ -227,7 +226,7 @@ describe Google::APIClient do
end end
client.execute( client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection :connection => @connection
) )
end end
@ -243,7 +242,7 @@ describe Google::APIClient do
end end
client.execute( client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection, :connection => @connection,
:authenticated => false :authenticated => false
) )
@ -262,7 +261,7 @@ describe Google::APIClient do
end end
expect(client.execute( expect(client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection :connection => @connection
).status).to eq(200) ).status).to eq(200)
@ -279,7 +278,7 @@ describe Google::APIClient do
end end
expect(client.execute( expect(client.execute(
:uri => 'https://www.gogole.com/foo', :uri => 'https://www.google.com/foo',
:connection => @connection :connection => @connection
).status).to eq(500) ).status).to eq(500)
expect(count).to eq(3) expect(count).to eq(3)