Available Fields from FeedNormalizer Gem
The FeedNormalizer Gem does an excellent job of returning a single unified object from many of several different syndicated feed types. This saves you from having to worry about whether you are dealing with an rss, atom or some other kind of feed.
The following is a list of the available fields for both the Feed object itself and the Entries objects associated as articles in the channel.
FeedNormalizer::Feed
- title
- description
- id
- last_updated
- copyright
- authors / author
- urls / url
- image
- generator
- items / channel
FeedNormalizer::Entry
- content
- description
- title
- date_published
- urls / url
- id
- authors / author
- copyright
- categories
Etags
Etags and last_modified are crucial elements to sending proper request headers if you hope to receive conditional get responses and save yourself some overhead in feed processing. FeedNormalizer does not provide access to these elements as they are actually part of the http response headers, and not the feed itself.
While heavily studying the art of feed processing, I encountered Feezirra and Feedtosis, both excellent libraries for feed processing. My own application required a modified version of their concept, but there was a lot to learn in their code.
Feedtosis uses the HttpHeaders process to collect this information from a Curl::Easy object. I adapted the Feedtosis code to meet my needs like this:
require 'http_headers'
class Feed < ActiveRecord::Base
def store_header_information
headers = HttpHeaders.new(curl.header_str)
self.response_code = curl.response_code
self.etag = headers.etag unless headers.etag.nil?
self.last_modified = headers.last_modified unless headers.last_modified.nil?
end
end