lib/simplegdata.rb in simplegdata-0.0.1 vs lib/simplegdata.rb in simplegdata-0.0.2
- old
+ new
@@ -24,16 +24,16 @@
# Automatically converts the request to JSON and accepts a
# a ruby hash to convert to JSON to send for post data. Returns
# results back as a ruby array.
def request(rest, url, data = nil, options = nil)
# Default get requests to json
- if rest == :get
+ if rest == :get && @site == 'https://www.google.com'
unless url.include? 'alt=json'
if url.include? '?'
- url = url + '&alt=json'
+ url = url + '&alt=jsonc'
else
- url = url + '?alt=json'
+ url = url + '?alt=jsonc'
end
end
end
# Default post requests to json
@@ -59,11 +59,9 @@
# done by the user. Deals with the unique issue of GData
# API's sometimes returning 302 redirects with gsessionids
# appended to them.
def request_raw(rest, url, data = nil, options = nil)
response = access_token.request(rest, url, data, options)
- #if(rest == :post)
- # raise response.to_yaml
#end
case response
when Net::HTTPSuccess then response.body
when Net::HTTPRedirection then access_token.request(rest, response['location'], data, options).body
else