Module: Peddler::Parser Private
- Defined in:
- lib/peddler/parser.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
-
.new(res, encoding) ⇒ Object
private
The inevitable-seeming messiness of massaging data produced by a motley army of Amazon developers.
- .xml?(res) ⇒ Boolean private
Class Method Details
.new(res, encoding) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The inevitable-seeming messiness of massaging data produced by a motley army of Amazon developers
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/peddler/parser.rb', line 10 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 |
.xml?(res) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 |
# File 'lib/peddler/parser.rb', line 24 def xml?(res) return true if res.headers['Content-Type'].start_with?('text/xml') return true if res.body.start_with?('<?xml') false end |