Skip to content

Rails plugin to load feeds or XML resources into an ActiveRecord model

License

Notifications You must be signed in to change notification settings

thecocktail/feedsucker

Repository files navigation

Feedsucker
==========

Rails plugin to load feeds (using FeedTools) or XML resources (using REXML::XPath expressions) into an ActiveRecord model (called FeedsuckerPost).

Feedsucker uses another AR model (called FeedsuckerFeed) to store the settings of the different sources it should suck from.

FeedsuckerPost model currently has the following fields: title, content, date, url, blog_title and blog_url (and the foreign key of the FeedsuckerFeed from which the data was sucked).

FeedsuckerFeed model has the following fields: title, url, number_of_posts, xpath_post_title, xpath_post_content, xpath_post_date, xpath_post_url, xpath_blog_title and xpath_blog_url.

Example
=======
To create a RSS/Atom feed to suck from:

    FeedsuckerFeed.create(
      :title => 'RSS/Atom example',
      :nicetitle => 'atom-example',
      :number_of_posts => 3, # optional (all posts in feed if blank),
	  :delete_preview => true, # optional: delete all posts from a feed, before it´s sucked (default -> true)
      :url => 'http://example.com/posts.atom')

To create it but sucking from XML resouce index: 

    FeedsuckerFeed.create(
      :title => 'XML resource index example',
      :nicetitle => 'xml-example',
      :url => 'http://example.com/temas/arte-y-arquitectura/xml',
      :number_of_posts => 3, # optional (all posts if blank)
      :xpath_post_title => '//post-title/text()',
      :xpath_post_content => '//post-body/text()',
      :xpath_post_date => '//post-date/text()',
      :xpath_post_url => '//post-id/text()',
      :xpath_blog_title => '//blog-title/text()',
      :xpath_blog_url => '//blog-url/text()')

To suck a feed:

    FeedsuckerFeed.find_by_title('atom-example').suck!

To suck them all:

    FeedsuckerFeed.suck_all!

To show sucked items in a view:

    <% FeedsuckerFeed.find_by_title('Calippo').posts.each do |post| %>
    <h3><%= post.title %></h3>
    [...]
    <% end %>


Installation
============

With:

    script/plugin install git://github.com/thecocktail/feedsucker.git

Or:

    git submodule add git://github.com/thecocktail/feedsucker.git vendor/plugins/feedsucker

And then:

    script/generate feedsucker


Bugs & feedback
===============

ruby at listas dot the-cocktail dot com

Copyright (c) 2009 The Cocktail Experience S.L., released under the MIT license

About

Rails plugin to load feeds or XML resources into an ActiveRecord model

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages