diff --git a/.travis.yml b/.travis.yml index d66aa8a98..be99f1c36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,10 @@ language: ruby rvm: - - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - 2.1.0 - rbx-2 - - jruby-18mode - jruby-19mode - - ree script: "bundle exec rake spec:all" before_install: - sudo apt-get update diff --git a/google-api-client.gemspec b/google-api-client.gemspec index bae8bec14..17927c4c9 100644 --- a/google-api-client.gemspec +++ b/google-api-client.gemspec @@ -26,7 +26,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'signet', '~> 0.6' s.add_runtime_dependency 'faraday', '~> 0.9' 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 'extlib', '~> 0.9' s.add_runtime_dependency 'launchy', '~> 2.4' diff --git a/lib/google/api_client.rb b/lib/google/api_client.rb index 50aeeefe9..90d3e5e74 100644 --- a/lib/google/api_client.rb +++ b/lib/google/api_client.rb @@ -32,7 +32,7 @@ require 'google/api_client/service_account' require 'google/api_client/batch' require 'google/api_client/gzip' 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 @@ -692,5 +692,3 @@ module Google end end - -require 'google/api_client/version' diff --git a/lib/google/api_client/auth/file_storage.rb b/lib/google/api_client/auth/file_storage.rb index 049ef965a..fca4ea39a 100644 --- a/lib/google/api_client/auth/file_storage.rb +++ b/lib/google/api_client/auth/file_storage.rb @@ -42,7 +42,7 @@ module Google ## # Attempt to read in credentials from the specified file. def load_credentials - if File.exist? self.path + if File.exists? self.path File.open(self.path, 'r') do |file| cached_credentials = JSON.load(file) @authorization = Signet::OAuth2::Client.new(cached_credentials) diff --git a/lib/google/api_client/batch.rb b/lib/google/api_client/batch.rb index 0a7e6b78c..1082516ad 100644 --- a/lib/google/api_client/batch.rb +++ b/lib/google/api_client/batch.rb @@ -14,7 +14,7 @@ require 'addressable/uri' require 'google/api_client/reference' -require 'uuidtools' +require 'securerandom' module Google class APIClient @@ -90,8 +90,7 @@ module Google @global_callback = block if block_given? @last_auto_id = 0 - # TODO(sgomes): Use SecureRandom.uuid, drop UUIDTools when we drop 1.8 - @base_id = UUIDTools::UUID.random_create.to_s + @base_id = SecureRandom.uuid options[:uri] ||= 'https://www.googleapis.com/batch' options[:http_method] ||= 'POST' diff --git a/lib/google/api_client/client_secrets.rb b/lib/google/api_client/client_secrets.rb index 93b0046a8..792f1b7cf 100644 --- a/lib/google/api_client/client_secrets.rb +++ b/lib/google/api_client/client_secrets.rb @@ -13,7 +13,6 @@ # limitations under the License. -require 'multi_json' require 'compat/multi_json' @@ -63,7 +62,7 @@ module Google end while filename == nil 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') elsif search_path == '/' || search_path =~ /[a-zA-Z]:[\/\\]/ raise ArgumentError, diff --git a/lib/google/api_client/discovery/api.rb b/lib/google/api_client/discovery/api.rb index 4c58d7e10..be83f6279 100644 --- a/lib/google/api_client/discovery/api.rb +++ b/lib/google/api_client/discovery/api.rb @@ -15,7 +15,7 @@ require 'addressable/uri' require 'multi_json' -require 'google/inflection' +require 'active_support/inflector' require 'google/api_client/discovery/resource' require 'google/api_client/discovery/method' require 'google/api_client/discovery/media' @@ -41,13 +41,13 @@ module Google @discovery_document = discovery_document metaclass = (class << self; self; end) 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) metaclass.send(:define_method, method_name) { resource } end end 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) metaclass.send(:define_method, method_name) { method } end diff --git a/lib/google/api_client/discovery/resource.rb b/lib/google/api_client/discovery/resource.rb index f6493ff40..9b757c684 100644 --- a/lib/google/api_client/discovery/resource.rb +++ b/lib/google/api_client/discovery/resource.rb @@ -15,7 +15,7 @@ require 'addressable/uri' -require 'google/inflection' +require 'active_support/inflector' require 'google/api_client/discovery/method' @@ -45,13 +45,13 @@ module Google @discovery_document = discovery_document metaclass = (class < 1 diff --git a/lib/google/api_client/version.rb b/lib/google/api_client/version.rb index a979647d9..ee12fd33b 100644 --- a/lib/google/api_client/version.rb +++ b/lib/google/api_client/version.rb @@ -13,19 +13,14 @@ # limitations under the License. -# Used to prevent the class/module from being loaded more than once -if !defined?(::Google::APIClient::VERSION) - - - module Google - class APIClient - module VERSION - MAJOR = 0 - MINOR = 7 - TINY = 1 - PATCH = nil - STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.') - end +module Google + class APIClient + module VERSION + MAJOR = 0 + MINOR = 7 + TINY = 1 + PATCH = nil + STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.') end end end diff --git a/lib/google/inflection.rb b/lib/google/inflection.rb deleted file mode 100644 index cdf71ab4b..000000000 --- a/lib/google/inflection.rb +++ /dev/null @@ -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 diff --git a/rakelib/wiki.rake b/rakelib/wiki.rake index 12bfe4bf0..3e0d97d2e 100644 --- a/rakelib/wiki.rake +++ b/rakelib/wiki.rake @@ -38,7 +38,7 @@ WIKI output.gsub!(/-32\./, "-16.") wiki_path = File.expand_path( 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.write(output) end diff --git a/spec/google/api_client/batch_spec.rb b/spec/google/api_client/batch_spec.rb index 0df184e56..3aa95a88b 100644 --- a/spec/google/api_client/batch_spec.rb +++ b/spec/google/api_client/batch_spec.rb @@ -14,9 +14,8 @@ require 'spec_helper' 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) after do diff --git a/spec/google/api_client/discovery_spec.rb b/spec/google/api_client/discovery_spec.rb index 4ec5f99e5..d1c23759f 100644 --- a/spec/google/api_client/discovery_spec.rb +++ b/spec/google/api_client/discovery_spec.rb @@ -22,9 +22,8 @@ require 'multi_json' require 'compat/multi_json' require 'signet/oauth_1/client' require 'google/api_client' -require 'google/api_client/version' -describe Google::APIClient do +RSpec.describe Google::APIClient do include ConnectionHelpers CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) diff --git a/spec/google/api_client/gzip_spec.rb b/spec/google/api_client/gzip_spec.rb index 36d7fd6ca..9448b009f 100644 --- a/spec/google/api_client/gzip_spec.rb +++ b/spec/google/api_client/gzip_spec.rb @@ -15,9 +15,8 @@ require 'spec_helper' require 'google/api_client' -require 'google/api_client/version' -describe Google::APIClient::Gzip do +RSpec.describe Google::APIClient::Gzip do def create_connection(&block) Faraday.new do |b| diff --git a/spec/google/api_client/media_spec.rb b/spec/google/api_client/media_spec.rb index 8c6515ea5..f32b31efc 100644 --- a/spec/google/api_client/media_spec.rb +++ b/spec/google/api_client/media_spec.rb @@ -15,11 +15,10 @@ require 'spec_helper' require 'google/api_client' -require 'google/api_client/version' 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 expect(lambda do media = Google::APIClient::UploadIO.new('doesnotexist', 'text/plain') @@ -57,7 +56,7 @@ describe Google::APIClient::UploadIO do end end -describe Google::APIClient::RangedIO do +RSpec.describe Google::APIClient::RangedIO do before do @source = StringIO.new("1234567890abcdef") @io = Google::APIClient::RangedIO.new(@source, 1, 5) @@ -105,7 +104,7 @@ describe Google::APIClient::RangedIO do end -describe Google::APIClient::ResumableUpload do +RSpec.describe Google::APIClient::ResumableUpload do CLIENT = Google::APIClient.new(:application_name => 'API Client Tests') unless defined?(CLIENT) after do diff --git a/spec/google/api_client/request_spec.rb b/spec/google/api_client/request_spec.rb index d70e217e3..c63f750dc 100644 --- a/spec/google/api_client/request_spec.rb +++ b/spec/google/api_client/request_spec.rb @@ -15,9 +15,8 @@ require 'spec_helper' 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) it 'should normalize parameter names to strings' do diff --git a/spec/google/api_client/result_spec.rb b/spec/google/api_client/result_spec.rb index 757730386..67c63b77c 100644 --- a/spec/google/api_client/result_spec.rb +++ b/spec/google/api_client/result_spec.rb @@ -15,9 +15,8 @@ require 'spec_helper' 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) describe 'with the plus API' do diff --git a/spec/google/api_client/service_account_spec.rb b/spec/google/api_client/service_account_spec.rb index 51945b8e8..6314cea6b 100644 --- a/spec/google/api_client/service_account_spec.rb +++ b/spec/google/api_client/service_account_spec.rb @@ -18,7 +18,7 @@ require 'google/api_client' 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 if RUBY_PLATFORM == 'java' && RUBY_VERSION.start_with?('1.8') pending "Reading from PKCS12 not supported on jruby 1.8.x" @@ -53,7 +53,7 @@ describe Google::APIClient::KeyUtils do end -describe Google::APIClient::JWTAsserter do +RSpec.describe Google::APIClient::JWTAsserter do include ConnectionHelpers before do @@ -146,7 +146,7 @@ describe Google::APIClient::JWTAsserter do end end -describe Google::APIClient::ComputeServiceAccount do +RSpec.describe Google::APIClient::ComputeServiceAccount do include ConnectionHelpers it 'should query metadata server' do diff --git a/spec/google/api_client/service_spec.rb b/spec/google/api_client/service_spec.rb index e9c216454..e5184372c 100644 --- a/spec/google/api_client/service_spec.rb +++ b/spec/google/api_client/service_spec.rb @@ -21,7 +21,7 @@ require 'google/api_client/service' fixtures_path = File.expand_path('../../../fixtures', __FILE__) -describe Google::APIClient::Service do +RSpec.describe Google::APIClient::Service do include ConnectionHelpers APPLICATION_NAME = 'API Client Tests' @@ -288,7 +288,7 @@ describe Google::APIClient::Service do end -describe Google::APIClient::Service::Result do +RSpec.describe Google::APIClient::Service::Result do describe 'with the plus API' do before do @@ -492,7 +492,7 @@ describe Google::APIClient::Service::Result do end end -describe Google::APIClient::Service::BatchRequest do +RSpec.describe Google::APIClient::Service::BatchRequest do describe 'with the discovery API' do before do @discovery = Google::APIClient::Service.new('discovery', 'v1', diff --git a/spec/google/api_client/simple_file_store_spec.rb b/spec/google/api_client/simple_file_store_spec.rb index f041c4293..cb7d89847 100644 --- a/spec/google/api_client/simple_file_store_spec.rb +++ b/spec/google/api_client/simple_file_store_spec.rb @@ -18,14 +18,10 @@ require 'spec_helper' 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' - before(:all) do - File.delete(FILE_NAME) if File.exists?(FILE_NAME) - end - describe 'with no cache file' do before(:each) do File.delete(FILE_NAME) if File.exists?(FILE_NAME) diff --git a/spec/google/api_client_spec.rb b/spec/google/api_client_spec.rb index 88c2cf63a..6cd4c8ee4 100644 --- a/spec/google/api_client_spec.rb +++ b/spec/google/api_client_spec.rb @@ -17,7 +17,6 @@ require 'spec_helper' require 'faraday' require 'signet/oauth_1/client' require 'google/api_client' -require 'google/api_client/version' shared_examples_for 'configurable user agent' do include ConnectionHelpers @@ -55,7 +54,7 @@ shared_examples_for 'configurable user agent' do end end -describe Google::APIClient do +RSpec.describe Google::APIClient do include ConnectionHelpers let(:client) { Google::APIClient.new(:application_name => 'API Client Tests') } @@ -191,7 +190,7 @@ describe Google::APIClient do end client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection ) end @@ -210,7 +209,7 @@ describe Google::APIClient do end client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection ) end @@ -227,7 +226,7 @@ describe Google::APIClient do end client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection ) end @@ -243,7 +242,7 @@ describe Google::APIClient do end client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection, :authenticated => false ) @@ -262,7 +261,7 @@ describe Google::APIClient do end expect(client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection ).status).to eq(200) @@ -279,7 +278,7 @@ describe Google::APIClient do end expect(client.execute( - :uri => 'https://www.gogole.com/foo', + :uri => 'https://www.google.com/foo', :connection => @connection ).status).to eq(500) expect(count).to eq(3)