ArghSs

This is a simple RSS feed reader Gem using Ruby's built in library. It can also read most OPML files to import existing feeds.

Installation

Add this line to your application's Gemfile:

gem 'argh_ss'

And then execute:

$ bundle

Or install it yourself as:

$ gem install argh_ss

RSS Feeds

2 options for RSS feeds, RSSFeed.feed and RSSFeed.options_feed

To output a simple hash with the feed title and feed url:

{"Article Title"=>"https://www.article.com/feed_url"}

Simply run:

url = "https://www.theguardian.com/world/rss"
RSSFeed.feed(url)

To give you more options you can output an array with a hash of your options:

[
  {
    :title     => "Headline here",
    :link      => "http://my_url.here",
    :content   => "All of the posted articles RSS content here",
    :published => "date object from feed here"
  }
]
url = "https://www.theguardian.com/world/rss"
RSSFeed.options_feed(url)

By default, the options will give you: :title, :link, :content, :published. But, you can choose your options. For example, if you only wanted the title, link and content, you would do the following:

url = "https://www.theguardian.com/world/rss"
RSSFeed.options_feed(url, :title, :link, :content)

Resolving URL

The best way to avoid errors when parsing RSS feeds is having the correct URL. ResolveURL will help with this, by following the redirects.

url = 'http://www.newyorktimes.com'
ResolveURL.resolve(url)

This code is mostly from here.

This will raise exception after 10 redirects.

OPML Import

For OPML import it will once again output a hash as "title": "url"

file = "./my_important.opml"
OPMLImport.new(file).to_hash

Note, opml import will be in perpetual alpha due to low use.

The gem is designed to skip over errors, so if you have an RSS feed url that isn't standard, or an OPML file that doesn't proprly parse with nokogiri, it will fail quietly and move on.

License

The gem is available as open source under the terms of the MIT License.