Sha256: 1febd15273f28f233efcfa9f9157640cd2214b5f6bccf218f16aa947523085da

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 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)
        elsif content_type == 'application/octet-stream'
          FlatFileParser.new(res, encoding)
        else
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peddler-0.7.7 lib/peddler/parser.rb