From 5572a73fdf5e64ae2b9e4993aa5d1c1008b6e3ea Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Wed, 13 Oct 2010 21:16:07 +0000 Subject: [PATCH] Fixed incompatibilities with Ruby 1.8.6 git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@71 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef --- lib/google/api_client/discovery.rb | 20 ++++++++++++-------- spec/google/api_client/discovery_spec.rb | 4 ++-- tasks/gem.rake | 4 ++-- tasks/spec.rake | 4 +++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/google/api_client/discovery.rb b/lib/google/api_client/discovery.rb index 5191e3f34..cb33d28f6 100644 --- a/lib/google/api_client/discovery.rb +++ b/lib/google/api_client/discovery.rb @@ -442,7 +442,9 @@ module Google # # @return [Hash] The parameter descriptions. def parameter_descriptions - @parameter_descriptions ||= Hash[self.description['parameters'] || {}] + @parameter_descriptions ||= ( + self.description['parameters'] || {} + ).inject({}) { |h,(k,v)| h[k]=v; h } end ## @@ -450,7 +452,9 @@ module Google # # @return [Array] The parameters. def parameters - @parameters ||= Hash[self.description['parameters'] || {}].keys + @parameters ||= (( + self.description['parameters'] || {} + ).inject({}) { |h,(k,v)| h[k]=v; h }).keys end ## @@ -463,9 +467,9 @@ module Google # # A list of all required parameters. # method.required_parameters def required_parameters - @required_parameters ||= Hash[self.parameter_descriptions.select do |k, v| + @required_parameters ||= ((self.parameter_descriptions.select do |k, v| v['required'] - end].keys + end).inject({}) { |h,(k,v)| h[k]=v; h }).keys end ## @@ -478,9 +482,9 @@ module Google # # A list of all optional parameters. # method.optional_parameters def optional_parameters - @optional_parameters ||= Hash[self.parameter_descriptions.reject do |k, v| + @optional_parameters ||= ((self.parameter_descriptions.reject do |k, v| v['required'] - end].keys + end).inject({}) { |h,(k,v)| h[k]=v; h }).keys end ## @@ -493,9 +497,9 @@ module Google # @return [NilClass] nil if validation passes. def validate_parameters(parameters={}) parameters = self.normalize_parameters(parameters) - required_variables = Hash[self.parameter_descriptions.select do |k, v| + required_variables = ((self.parameter_descriptions.select do |k, v| v['required'] - end].keys + end).inject({}) { |h,(k,v)| h[k]=v; h }).keys missing_variables = required_variables - parameters.keys if missing_variables.size > 0 raise ArgumentError, diff --git a/spec/google/api_client/discovery_spec.rb b/spec/google/api_client/discovery_spec.rb index e3f73fbd7..46d628101 100644 --- a/spec/google/api_client/discovery_spec.rb +++ b/spec/google/api_client/discovery_spec.rb @@ -173,7 +173,7 @@ describe Google::APIClient, 'configured for the prediction API' do method.should == 'POST' uri.should == 'https://www.googleapis.com/prediction/v1/training?query=12345' - Hash[headers].should == {} + (headers.inject({}) { |h,(k,v)| h[k]=v; h }).should == {} body.should respond_to(:each) end @@ -207,7 +207,7 @@ describe Google::APIClient, 'configured for the prediction API' do {'query' => '12345'} ) method, uri, headers, body = request - headers = Hash[headers] + headers = headers.inject({}) { |h,(k,v)| h[k]=v; h } headers.keys.should include('Authorization') headers['Authorization'].should =~ /^OAuth/ end diff --git a/tasks/gem.rake b/tasks/gem.rake index 87339ec53..4ac10bdb2 100644 --- a/tasks/gem.rake +++ b/tasks/gem.rake @@ -19,14 +19,14 @@ namespace :gem do s.extra_rdoc_files = %w( README ) s.rdoc_options.concat ['--main', 'README'] - s.add_runtime_dependency('signet', '>= 0.1.1') + s.add_runtime_dependency('signet', '>= 0.1.3') s.add_runtime_dependency('addressable', '>= 2.2.2') s.add_runtime_dependency('httpadapter', '>= 0.2.0') s.add_runtime_dependency('json', '>= 1.1.9') s.add_runtime_dependency('extlib', '>= 0.9.15') s.add_development_dependency('rake', '>= 0.7.3') - s.add_development_dependency('rspec', '~> 1.3.0') + s.add_development_dependency('rspec', '~> 1.2.9') s.add_development_dependency('launchy', '>= 0.3.2') s.add_development_dependency('diff-lcs', '>= 1.1.2') diff --git a/tasks/spec.rake b/tasks/spec.rake index 4f3789b6a..d0a321bc6 100644 --- a/tasks/spec.rake +++ b/tasks/spec.rake @@ -7,7 +7,9 @@ namespace :spec do if RCOV_ENABLED if `which rcov`.strip == "" STDERR.puts "Please install rcov:" - STDERR.puts "sudo gem install relevance-rcov" + STDERR.puts( + "sudo gem install relevance-rcov --source http://gems.github.com/" + ) exit(1) end t.rcov = true