lib/geocoder/lookups/base.rb in geocoder-1.0.5 vs lib/geocoder/lookups/base.rb in geocoder-1.1.0

- old
+ new

@@ -89,17 +89,21 @@ def result_class Geocoder::Result.const_get(self.class.to_s.split(":").last) end ## - # Raise exception instead of warning for specified exceptions. + # Raise exception if configuration specifies it should be raised. + # Return false if exception not raised. # - def raise_error(err) - raise err if Geocoder::Configuration.always_raise.include?(err.class) + def raise_error(error, message = nil) + if Geocoder::Configuration.always_raise.include?(error.class) + raise error, message + else + false + end end - ## # Returns a parsed search result (Ruby hash). # def fetch_data(query, reverse = false) begin @@ -139,11 +143,14 @@ # Fetches a raw search result (JSON string). # def fetch_raw_data(query, reverse = false) timeout(Geocoder::Configuration.timeout) do url = query_url(query, reverse) + uri = URI.parse(url) unless cache and response = cache[url] - response = http_client.get_response(URI.parse(url)).body + client = http_client.new(uri.host, uri.port) + client.use_ssl = true if Geocoder::Configuration.use_https + response = client.get(uri.request_uri).body if cache cache[url] = response end end response