Introducing the Polyrex-feed-reader gem

This is an old article from Jun-2010 however I want to study the project and hopefully get the gem working again soon.

The Polyrex-feed-reader gem reads RSS feeds and stores the items in a Polyrex document. The aim is to use this for retrieving internal RSS feeds relating to personal organisation, and then later publish it to a newspaper style web page.

installation

sudo gem1.9.1 install polyrex-feed-reader

Successfully installed polyrex-feed-reader-0.1.0
Successfully installed rubyforge-2.0.4
2 gems installed
Installing ri documentation for polyrex-feed-reader-0.1.0...
Installing ri documentation for rubyforge-2.0.4...
Updating class cache with 3183 classes...
Installing RDoc documentation for polyrex-feed-reader-0.1.0...
Installing RDoc documentation for rubyforge-2.0.4...
</pre>

## example: creating a new PolyrexFeedReader document


    require 'polyrex-feed-reader'

    lines =<<LINES
    1
      http://feeds.wired.com/wired/index wired
      http://rss.slashdot.org/Slashdot/slashdot slashdot
    2
      http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml BBC-News important
      http://www.iftf.org/rss.xml Institute-for-the-future unimportant friday
      http://www.linux.com/rss/feeds.php linux
    LINES

    # creating a new document

    xml = PolyrexFeedReader.new('feeds.xml').parse(lines).read
    puts xml


output:

<pre>
<?xml version="1.0" encoding="UTF-8"?>
<feeds>
  <summary>
    <recordx_type>polyrex</recordx_type>
  </summary>
  <records>
    <feed>
      <summary>  
        <title>wired</title>
        <last_modified>2010-06-13 20:39:58 +0100</last_modified>
        <recent>hot</recent>
        <important></important>
      </summary> 
      <records>  
        <item>   
          <summary><title>Blowback: &apos;True Blood&apos; Vampires Make Raunchy Return</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>Concept Video Shows Tablet That Only Ultra-Geeks Could Love</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>Top 5 Songs From Wired.com&apos;s Crowdsourced Music Experiment</title>
          <description></description></summary><records/>
        </item>  
      </records> 
    </feed>
    <feed>
      <summary>  
        <title>linux</title>
        <last_modified>2010-06-13 20:40:01 +0100</last_modified>
        <recent>hot</recent>
        <important></important>
      </summary> 
      <records>  
        <item>   
          <summary><title>Weekend Project: One-Time Passwords for Extra Linux Security</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>Will Oracle Drop AMD for Sun x86 Servers?</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>Mobile Developers Say Collaboration Apps Are No. 1</title>
          <description></description></summary><records/>
        </item>  
      </records> 
    </feed>
    <feed>
      <summary>  
        <title>slashdot</title>
        <last_modified>2010-06-13 20:39:57 +0100</last_modified>
        <recent>hot</recent>
        <important></important>
      </summary> 
      <records>  
        <item>   
          <summary><title>NASA Aircraft Videos Hayabusa Re-Entry</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>North Korean Flash Games For Export</title>
          <description></description></summary><records/>
        </item>  
        <item>   
          <summary><title>A Battle of Wits On the Net&apos;s Effect On the Mind</title>
          <description></description></summary><records/>
        </item>  
      </records> 
    </feed>
    <feed>
      <summary>  
        <title>BBC-News</title>
        <last_modified>2010-06-13 20:40:01 +0100<last_modified>
        <recent>hot</recent>
        <important>important</important>
      </summary>
      <records>
        <item>
          <title>Troop numbers cut not ruled out</title>
          <description>Defence Secretary Liam Fox refuses to rule out a cut in troop numbers as part of this year&apos;s strategic defence review.</description></summary><records/>
        </item>
        <item>
          <title>Thousands flee Kyrgyzstan unrest</title>
          <description></description></summary><records/>
        </item>
        <item>
          <title>Blair hopeful over Gaza blockade</title>
          <description></description></summary><records/>
        </item>
      </records>
    </feed>
  </records>
</feeds>
</pre>

Notes:
<pre>
  1) The <recent/> element can be either :

     - hot: less than 5 mins old
     - warm: less than half a day old
     - cold: more than half a day old
     - or colder with more options.

  2) The <important/> element if specified as 'important' means the 
     1st feed item includes the description.

  3) The <recent/> and <important/>  elements may be used by CSS to 
     hilglight its current state or relevance.

  4) The document is designed to work best with 3 columns, each which
     will be 200px in width to fit within a 650px wide page.

  5) The output Polyrex document contains column feeds which are interleaved,
     as a result when the feed divs are floated left they will align 
     to columns.

  6) The PolyrexFeedReader document is created internally using the 
     following schema:

     'feeds/column[id]/feed[rss_url,title,important,occurrence,recent,url, 
      xhtml, xhtml_mobile, last_modified]/item[title,link,description]'

  7) The <occurrence/> element specifies whether the feed should 
     be read or not.  Here are a few example options:

      - example 1: mon
      - example 2: mon, wed, friday evening
      - example 3: wed 1pm

     If a time or period is specified then the duration varies 
     from 3 hours upwards.  
</pre>

*update: 13-Jun-2010 @ 10:10pm*


<pre><code>require 'polyrex-feed-reader'

# opening and reading the feeds from an existing document
xml = PolyrexFeedReader.new('feeds.xml').read

</code>

The latest version is 0.1.1 which correctly outputs the Polyrex document.

update: 14-Jun-2010 @ 9:56am

Resources:

Tags:
Source:
1922hrs.txt
Published:
06-12-2013 19:22