Updated to avoid deprecation of encode and decode methods in multi_json gem.

This commit is contained in:
Bob Aman 2012-04-24 14:39:25 +03:00
parent 96b697bd5f
commit c651d69674
6 changed files with 10 additions and 10 deletions

View File

@ -281,7 +281,7 @@ module Google
"Expected String or StringIO, got #{discovery_document.class}."
end
@discovery_documents["#{api}:#{version}"] =
MultiJson.decode(discovery_document)
MultiJson.load(discovery_document)
end
##
@ -297,7 +297,7 @@ module Google
)
response = self.transmit(:request => request)
if response.status >= 200 && response.status < 300
MultiJson.decode(response.body)
MultiJson.load(response.body)
elsif response.status >= 400
case response.status
when 400...500
@ -331,7 +331,7 @@ module Google
)
response = self.transmit(:request => request)
if response.status >= 200 && response.status < 300
MultiJson.decode(response.body)
MultiJson.load(response.body)
elsif response.status >= 400
case response.status
when 400...500
@ -484,7 +484,7 @@ module Google
response = self.transmit(:request => request)
if response.status >= 200 && response.status < 300
@certificates.merge!(
Hash[MultiJson.decode(response.body).map do |key, cert|
Hash[MultiJson.load(response.body).map do |key, cert|
[key, OpenSSL::X509::Certificate.new(cert)]
end]
)

View File

@ -39,7 +39,7 @@ module Google
search_path = File.expand_path(File.join(search_path, '..'))
end
end
data = File.open(filename, 'r') { |file| MultiJson.decode(file.read) }
data = File.open(filename, 'r') { |file| MultiJson.load(file.read) }
return self.new(data)
end
@ -77,7 +77,7 @@ module Google
)
def to_json
return MultiJson.encode({
return MultiJson.dump({
self.flow => ({
'client_id' => self.client_id,
'client_secret' => self.client_secret,

View File

@ -103,7 +103,7 @@ module Google
def serialize_body(body)
return body.to_json if body.respond_to?(:to_json)
return MultiJson.encode(options[:body_object].to_hash) if body.respond_to?(:to_hash)
return MultiJson.dump(options[:body_object].to_hash) if body.respond_to?(:to_hash)
raise TypeError, 'Could not convert body object to JSON.' +
'Must respond to :to_json or :to_hash.'
end

View File

@ -63,7 +63,7 @@ module Google
data = self.body
case media_type
when 'application/json'
data = MultiJson.decode(data)
data = MultiJson.load(data)
# Strip data wrapper, if present
data = data['data'] if data.has_key?('data')
else

View File

@ -289,7 +289,7 @@ describe Google::APIClient do
result = @client.execute(
@prediction.training.insert,
{},
MultiJson.encode({"id" => "bucket/object"}),
MultiJson.dump({"id" => "bucket/object"}),
{'Content-Type' => 'application/json'}
)
result.request.headers['Content-Type'].should == 'application/json'

View File

@ -28,7 +28,7 @@ namespace :gem do
s.add_runtime_dependency('addressable', '>= 2.2.3')
s.add_runtime_dependency('autoparse', '>= 0.3.1')
s.add_runtime_dependency('faraday', '~> 0.7.0')
s.add_runtime_dependency('multi_json', '>= 1.0.0')
s.add_runtime_dependency('multi_json', '>= 1.3.0')
s.add_runtime_dependency('extlib', '>= 0.9.15')
# Dependencies used in the CLI