Sha256: ff12a432392cae974f8ca2cfa41ece1db1c238c8861e0926e422b004ebd42e6f

Contents?: true

Size: 795 Bytes

Versions: 17

Compression:

Stored size: 795 Bytes

Contents

require 'peddler/flat_file_parser'
require 'peddler/xml_parser'

module Peddler
  # @api private
  module Parser
    class << self
      # The inevitable messiness of massaging data produced by a motley army of
      # Amazon developers
      def parse(res, encoding = 'ISO-8859-1')
        # Don't parse if there's no body
        return res unless res.body

        content_type = res.headers['Content-Type']
        if content_type.start_with?('text/xml')
          XMLParser.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
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
peddler-0.12.7 lib/peddler/parser.rb
peddler-0.12.5 lib/peddler/parser.rb
peddler-0.12.4 lib/peddler/parser.rb
peddler-0.12.2 lib/peddler/parser.rb
peddler-0.12.1 lib/peddler/parser.rb
peddler-0.12.0 lib/peddler/parser.rb
peddler-0.11.1 lib/peddler/parser.rb
peddler-0.11.0 lib/peddler/parser.rb
peddler-0.10.0 lib/peddler/parser.rb
peddler-0.9.2 lib/peddler/parser.rb
peddler-0.9.1 lib/peddler/parser.rb
peddler-0.9.0 lib/peddler/parser.rb
peddler-0.8.0 lib/peddler/parser.rb
peddler-0.7.11 lib/peddler/parser.rb
peddler-0.7.10 lib/peddler/parser.rb
peddler-0.7.9 lib/peddler/parser.rb
peddler-0.7.8 lib/peddler/parser.rb