lib/pupa/processor/client.rb in pupa-0.0.6 vs lib/pupa/processor/client.rb in pupa-0.0.7

- old
+ new

@@ -4,10 +4,16 @@ require 'pupa/processor/middleware/logger' require 'pupa/processor/middleware/parse_html' require 'pupa/refinements/faraday_middleware' +begin + require 'multi_xml' +rescue LoadError + # pass +end + module Pupa class Processor # An HTTP client factory. class Client # Returns a configured Faraday HTTP client. @@ -24,10 +30,12 @@ # @see http://tools.ietf.org/html/rfc3236 connection.use Middleware::ParseHtml, content_type: %w(text/html application/xhtml+xml) # @see http://tools.ietf.org/html/rfc4627 connection.use FaradayMiddleware::ParseJson, content_type: /\bjson$/ # @see http://tools.ietf.org/html/rfc3023 - connection.use FaradayMiddleware::ParseXml, content_type: /\bxml$/ + if defined?(MultiXml) + connection.use FaradayMiddleware::ParseXml, content_type: /\bxml$/ + end if cache_dir connection.response :caching do ActiveSupport::Cache::FileStore.new(cache_dir, expires_in: expires_in) end end