lib/gov_kit-ca/represent.rb in govkit-ca-0.0.7 vs lib/gov_kit-ca/represent.rb in govkit-ca-0.0.8

- old
+ new

@@ -1,10 +1,15 @@ module GovKit module CA # A Ruby wrapper for the Represent API. # @see http://represent.opennorth.ca/api/ class Represent + # @param [Faraday::Connection] connection a Faraday connection + def initialize(connection = nil) + @client = connection || Faraday + end + # Get boundary sets. # # @param [Hash] opts optional arguments # @option opts [String] :boundary_set a boundary set # @option opts [Integer] :limit @@ -90,10 +95,10 @@ private def request(parts, opts) begin url = "http://represent.opennorth.ca/#{parts.compact.join('/')}/" - response = Faraday.get(url, opts) + response = @client.get(url, opts) case response.status when 200 JSON.parse(response.body) when 404 raise ResourceNotFound, "#{response.status} #{url}?#{opts.map{|k,v| "#{k}=#{v}"}.join('&')}"