Sha256: d5677e25e340e628be0ed3561946ecbd1fab790ef7004e52dd9edf5efd85447a
Contents?: true
Size: 930 Bytes
Versions: 5
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true require 'peddler/flat_file_parser' require 'peddler/xml_response_parser' module Peddler # @api private module Parser class << self # The inevitable-seeming messiness of massaging data produced by a motley # army of Amazon developers def new(res, encoding) # Don't parse if there's no body return res unless res.body if xml?(res) XMLResponseParser.new(res) else # Amazon returns a variety of content types for flat files, so we # simply assume that anything not XML is a flat file rather than code # defensively and check content type again. FlatFileParser.new(res, encoding) end end def xml?(res) return true if res.headers['Content-Type'].start_with?('text/xml') return true if res.body.start_with?('<?xml') false end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
peddler-2.0.0 | lib/peddler/parser.rb |
peddler-1.6.7 | lib/peddler/parser.rb |
peddler-1.6.6 | lib/peddler/parser.rb |
peddler-1.6.5 | lib/peddler/parser.rb |
peddler-1.6.4 | lib/peddler/parser.rb |