Archive

Posts Tagged ‘ruby’

Available Fields from FeedNormalizer Gem

July 8th, 2009 mindtonic No comments

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
Categories: Gems Tags: , , ,

How To Start the Gem Server for Local Gem Rdocs

July 8th, 2009 mindtonic No comments

To view the rdoc documentation for all of your locally installed gems, at the command line run:

$ gem server

This will start the gem server at port 8808, so to access the html from your browser, use the following url:

http://localhost:8808/

Note that this only access the documentation for Gems that are installed locally on your server.

Categories: Gems Tags: ,

Shoulda Testing With Ultrasphinx

June 24th, 2009 mindtonic 2 comments

I use the Shoulda testing framework for my Rails applications. After installing and beginning to use the Ultrasphinx plugin, I needed to figure out how to configure and run in a testing environment. This blog entry held the answer: Stephen Celis: Testing with Ultrasphinx

Ultrasphinx MySql Location Error

June 24th, 2009 mindtonic 1 comment

After installing all of the necessary elements for Spinx and Ultrasphinx, I began following the instructions from Snax Fauna to get the system up and running.

rake ultrasphinx:configure

worked fine, but I encountered the following error upon attempting to index my models:

rake ultrasphinx:index
...
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /usr/local/bin/indexer
Reason: image not found

In my configuration for development, I use the MAMP MySql server. The rake configure command correctly pulled all of the connection information from database.yml, so that was not the problem.

I searched around and finally encountered this solution from Michael Hartl:

$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

It worked brilliantly. Thanks Michael.