Sha256: 6ce7fb713b97757fa95abfefa378b1f588da177e2944dc601b0d48f78df0d067

Contents?: true

Size: 704 Bytes

Versions: 6

Compression:

Stored size: 704 Bytes

Contents

require 'patron'

module Animoto
  class HTTPEngine
    class PatronAdapter < Animoto::HTTPEngine
      
      def request method, url, body = nil, headers = {}, options = {}
        session = build_session options
        response = session.request method, url, headers, :data => body
        check_response response.status, response.body
        response.body
      end
      
      private
      
      def build_session options
        session = ::Patron::Session.new
        session.timeout = options[:timeout]
        session.username = options[:username]
        session.password = options[:password]
        session
      end
    end
    
    adapter_map.merge! :patron => PatronAdapter
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
animoto-0.0.0.alpha9 ./lib/animoto/http_engines/patron_adapter.rb
animoto-0.0.0.alpha8 ./lib/animoto/http_engines/patron_adapter.rb
animoto-0.0.0.alpha7 ./lib/animoto/http_engines/patron_adapter.rb
animoto-0.0.0.alpha6 ./lib/animoto/http_engines/patron_adapter.rb
animoto-0.0.0.alpha5 ./lib/animoto/http_engines/patron_adapter.rb
animoto-0.0.0.alpha4 ./lib/animoto/http_engines/patron_adapter.rb