lib/satisfaction/loader.rb in ruby-satisfaction-0.2.0 vs lib/satisfaction/loader.rb in ruby-satisfaction-0.3.0

- old
+ new

@@ -1,10 +1,10 @@ require 'net/http' require 'uri' -class Satisfaction::Loader +class Sfn::Loader require 'satisfaction/cache/hash' require 'satisfaction/cache/memcache' CacheRecord = Struct.new(:url, :etag, :body) attr_reader :cache @@ -32,11 +32,11 @@ if cache_record && !options[:force] request["If-None-Match"] = cache_record.etag end http = Net::HTTP.new(uri.host, uri.port) - add_authentication(request, options) + add_authentication(request, http, options) response = execute(http, request) case response when Net::HTTPNotModified return [:ok, cache_record.body] @@ -71,11 +71,11 @@ request = method_klass.new(uri.request_uri) request.set_form_data(form) http = Net::HTTP.new(uri.host, uri.port) - add_authentication(request, options) + add_authentication(request, http, options) response = execute(http, request) case response when Net::HTTPUnauthorized [:unauthorized, response.body] @@ -102,10 +102,10 @@ else raise ArgumentError, "Invalid uri, please use a String or URI object" end end - def add_authentication(request, options) + def add_authentication(request, http, options) if options[:user] request.basic_auth(options[:user], options[:password]) elsif options[:consumer] request.oauth!(http, options[:consumer], options[:token]) end